entire auth logout --everywhere · Entire
entire auth logout --everywhere
a0edbc1·
toothbrush·1mo ago·3 files·+7 added/-7 removed
Better name for the flag.
Sessions
0eb8618db00dView transcript
Changes
3
cmd/entire/cli
Mauth.go+2/-2
Mauth_test.go+1/-1
Mlogout.go+4/-4
273 unmodified lines
274
275
276
277
277
278
279
280
28 unmodified lines
309
310
311
312
312
313
314
315
273 unmodified lines
// runAuthStatus reports auth state against the target core: GET /me validates
// the token and supplies the profile header, the active login context is shown
// locally, and the active sessions (refresh-token families) on that core are
// listed so the effect of `logout` / `logout --all` is visible.
// listed so the effect of `logout` / `logout --everywhere` is visible.
func runAuthStatus(ctx context.Context, w io.Writer, fetchProfile profileFetcher, listSessions sessionLister, t statusTarget) error {
if t.token == "" {
fmt.Fprintf(w, "Not logged in to %s\n", t.coreURL)
28 unmodified lines
sortSessionsByRecency(sessions)
fmt.Fprintf(w, "\nActive sessions (%d):\n", len(sessions))
renderSessionsTable(w, newAuthTableStyles(w), sessions)
fmt.Fprintln(w, "\nRun 'entire logout' to end this session, or 'entire logout --all' to end all of them.")
fmt.Fprintln(w, "\nRun 'entire logout' to end this session, or 'entire logout --everywhere' to end all of them.")
}
if t.totalContexts > 1 {
Mcmd/entire/cli/auth.go+2/-2
120 unmodified lines
121
122
123
124
124
125
126
127
120 unmodified lines
t.Fatalf("output = %q, want table to contain %q", got, want)
}
}
if !strings.Contains(got, "entire logout --all") {
if !strings.Contains(got, "entire logout --everywhere") {
t.Fatalf("output = %q, want logout hint tying the table to logout", got)
}
}
Mcmd/entire/cli/auth_test.go+1/-1
32 unmodified lines
33
34
35
36
36
37
38
39
26 unmodified lines
66
67
68
69
69
70
71
72
73
74
75
76
76
77
78
79
23 unmodified lines
103
104
105
106
106
107
108
109
32 unmodified lines
func newLogoutCmd() *cobra.Command {
var insecureHTTPAuth bool
var all bool
var everywhere bool
cmd := &cobra.Command{
Use: "logout",
Short: "Log out of Entire",
26 unmodified lines
outW, errW := cmd.OutOrStdout(), cmd.ErrOrStderr()
if err := runLogout(cmd.Context(), outW, errW,
auth.NewContextStore(), revokeCurrent, revokeAll,
auth.RemoveCurrentContext, api.AuthBaseURL(), all); err != nil {
auth.RemoveCurrentContext, api.AuthBaseURL(), everywhere); err != nil {
return err
}
promoteNextLogin(outW, errW)
return nil
},
}
cmd.Flags().BoolVar(&all, "all", false, "Also revoke every session on the active core server-side, not just the active one")
cmd.Flags().BoolVar(&everywhere, "everywhere", false, "Revoke every session server-side, not just the current one")
addInsecureHTTPAuthFlag(cmd, &insecureHTTPAuth)
return cmd
}
// revokeAllSessions revokes every active login session on coreURL (the
// entire logout --all path): list the families, then delete each by id.
// entire logout --everywhere path): list the families, then delete each by id.
// Best-effort across sessions — it attempts them all and returns the first
// failure, so one stuck session doesn't strand the rest.
func revokeAllSessions(ctx context.Context, coreURL, token string) error {
Mcmd/entire/cli/logout.go+4/-4