Skip to content

feat: add sessions and refresh-tokens command resources - #1603

Open
developerkunal wants to merge 6 commits into
mainfrom
feat/sessions-refresh-tokens-commands
Open

feat: add sessions and refresh-tokens command resources#1603
developerkunal wants to merge 6 commits into
mainfrom
feat/sessions-refresh-tokens-commands

Conversation

@developerkunal

Copy link
Copy Markdown
Contributor

🔧 Changes

Adds two new top-level command groups, auth0 sessions and auth0 refresh-tokens, along with user-scoped subcommands under auth0 users. All are built on the go-auth0 v3 Management SDK.

auth0 sessions

  • show — display a session's device, clients, and expiry
  • update — set or clear session metadata
  • delete — delete a session by id
  • revoke — revoke a session and all of its associated refresh tokens

auth0 refresh-tokens

  • show — display a refresh token's client, session, device, and expiry
  • update — set or clear refresh token metadata
  • delete — delete a refresh token by id
  • revoke — revoke tokens by id, by user, by user + client, or by user + client + audience

auth0 users sessions and auth0 users refresh-tokens

  • list — list a user's sessions / refresh tokens (cursor-paginated)
  • delete — delete all of a user's sessions / refresh tokens

Also adds the read/update/delete scopes for both resources to the login flow, a collectV3Pages helper that drains v3 cursor-paginated endpoints, and shared date-formatting that renders future expiry timestamps as absolute dates.

📚 References

Depends on #1597 (go-auth0 v3 migration); this PR is based on that branch.

🔬 Testing

  • Table-driven unit tests for every new command, covering success paths, API-error wrapping, the revoke validation guards, and the number-flag bounds. User-scoped interfaces use generated gomock mocks (a core.Page type alias keeps mockgen able to parse the generic return).
  • Integration test cases (test/integration/sessions-test-cases.yaml, refresh-tokens-test-cases.yaml) for the non-destructive paths: empty-list rendering, invalid --number, not-found, and the revoke validation guards.
  • Manually verified end-to-end against a live tenant: list, show, update (set and clear metadata), delete, and revoke for both resources, plus the session-revoke cascade to refresh tokens and all three revoke narrowing modes.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

Update all go-auth0/v2 imports to go-auth0/v3 and rename the v2-flavored
identifiers (APIV2, apiv2, managementv2 alias, NewAPIV2,
initializeManagementClientV2) to their v3 equivalents. Regenerate the
phone-notification-template mock and drop go-auth0/v2 from go.mod. No
command surface or behavior changes; v3 is a near drop-in for v2 and none
of the tightened v3 types are referenced.
Add `auth0 sessions` and `auth0 refresh-tokens` command groups, plus user-scoped `auth0 users sessions` and `auth0 users refresh-tokens` subcommands, built on the go-auth0 v3 Management SDK.

Sessions: show, update (metadata), delete, and revoke a session by id; list and delete all sessions for a user. Refresh tokens: show, update (metadata), delete, and revoke by id, user, user+client, or user+client+audience; list and delete all refresh tokens for a user.

Add the read/update/delete scopes for both resources to the login flow, a collectV3Pages helper for v3 cursor pagination, and integration test cases for the non-destructive paths.
@developerkunal
developerkunal requested a review from a team as a code owner August 10, 2026 04:33
Base automatically changed from feat/go-auth0-v3-migration to main August 10, 2026 04:46
developerkunal and others added 3 commits August 10, 2026 10:25
Add a --csv flag to the users sessions list and users refresh-tokens
list commands, mutually exclusive with --json and --json-compact.
Bump go-auth0 to v1.46.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant