auth: show user profile in `auth status` via core GET /me · Entire
auth: show user profile in auth status via core GET /me
c2cea0a · toothbrush · 1mo ago · 2 files · +195 added/-49 removed
entire auth status now calls the core API's GET /me, which both validates the stored token (liveness) and supplies a profile header:
Logged in to https://us.auth.entire.io
User: Alice Smith (@alice) alice@example.com
Identity: github/alice
Token: stored in OS keychain
Active sessions: ...
/me is the primary liveness gate (a 401 surfaces as *coreapi.ErrorModelStatusCode, now recognised by isKeychainTokenRejected). The active-sessions list runs after, on the data API; since the token is already known good, a list failure degrades to a stderr warning instead of failing the command. Empty profile fields are omitted.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
5ca10643dc53View transcript
?\ Refactor Auth Commands for Session Management Claude Code · Opus 4.8[1m] · 1 step
Changes
2
cmd/entire/cli
Mauth.go +96/-14
Mauth_test.go +99/-35
12 unmodified lines
...
return newSessionsClient(token).ListSessions(ctx) //nolint:wrapcheck // ListSessions already wraps with action context
func runAuthStatus(ctx context.Context, w io.Writer, store tokenStore, list sessionLister, baseURL string) error {
...
Token: stored in OS keychain
// authProfile is the subset of the core API's GET /me that `entire auth status` renders.
type authProfile struct {
Handle string
DisplayName string
Email string
Provider string
ProviderUserID string
}
func defaultFetchProfile(ctx context.Context) (*authProfile, error) {
...
return p, nil
}
func defaultListSessions(ctx context.Context) ([]api.Session, error) {
...
}
func writeProfileLines(w io.Writer, p *authProfile) {
...
}
// TestRunAuthStatus_NotLoggedIn tests the scenario where the user is not logged in.
func TestRunAuthStatus_NotLoggedIn(t *testing.T) {
t.Parallel()
store := newMockTokenStore()
listCalled := false
profileCalled, listCalled := false, false
fetchProfile := func(context.Context) (*authProfile, error) {
profileCalled = true
return &authProfile{}, nil
}
list := func(context.Context) ([]api.Session, error) {
listCalled = true
return nil, nil
}
var out bytes.Buffer
if err := runAuthStatus(context.Background(), &out, store, list, testBaseURL); err != nil {
}
...
}