Skip to content

Carry the organizations a session must re-authenticate for - #213

Draft
ericmj wants to merge 1 commit into
mainfrom
organization-sso-reauth
Draft

Carry the organizations a session must re-authenticate for#213
ericmj wants to merge 1 commit into
mainfrom
organization-sso-reauth

Conversation

@ericmj

@ericmj ericmj commented Aug 4, 2026

Copy link
Copy Markdown
Member

Carries the organizations a session must re-authenticate for from the token response through to the CLI.

hex_api_oauth parses sso_reauth_required out of a token response and threads it through refresh_token/3 and the device-auth result. hex_cli_auth reports it through a new optional sso_reauth callback, invoked after every token grant with the organizations the server says this session has to authenticate through their identity provider for. Clients that do not register the callback are unaffected.

Needed by hexpm/hex#organization-sso-reauth, which registers the callback and prompts.

An organization can require its members to authenticate through its
identity provider, and that authentication expires on a clock the
organization sets. When it lapses, the token grant drops the organization's
scopes and names them in sso_reauth_required rather than leaving the client
to guess why a fetch started 403ing.

The name is the whole point: a scope dropped because the member was removed
is not named, because authenticating again would not give it back. Only the
ones a browser visit would fix are.

sso_authorization/2 asks for the URL that does the fixing. It is bound to
the session asking, so opening it renews that session rather than starting
a new one, and refresh_tokens/1 is how a build tool picks up the scopes
afterwards without waiting out an access token that has not expired.

The sso_reauth callback is optional and reports the flagged set after every
grant, including as an empty list. Which of them the running command
actually needs is the build tool's question, not this module's.
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