Description
Context
Tokens that OAuth clients obtain through the provider's authorization code flow (/oidc/authorization, then /oidc/token) have no expiration date. OIDCConsentStore#createAccessToken(BaseObjectOIDCConsent) passes null as the expiration date (it carries a TODO: set a configurable default lifespan ?), so the consent's accessToken_expire stays empty and the token response has no expires_in. The token endpoint only supports the authorization_code grant, so it never issues a refresh token.
Consequences
- A token stays valid until the user deletes it in the "Applications" section of their profile.
- When the wiki signs users in through an external identity provider (Token Authenticator with oidc.token.authenticator set to the OpenID Connect Authenticator), disabling the user in the identity provider does not revoke the tokens already issued. Reproduced with Keycloak 26.4 and OIDC 2.29.1: after disabling the user in Keycloak and deleting their Keycloak sessions, a request carrying the token still authenticated as that user.
- Logging out of the wiki does not revoke them either.
This affects the MCP clients (AI agents) of the LLM Application, which get their token through this flow.
Proposal
- Add a configuration property for the lifetime of tokens issued by the token endpoint, applied in createAccessToken, and return expires_in. Expired tokens are already refused when a token is validated (OIDCConsentStore#getConsent(XWikiBearerAccessToken)).
- Return a refresh token from the token endpoint, support grant_type=refresh_token (ideally with rotation), and list the supported grants in grant_types_supported of the provider metadata, so clients can renew short-lived tokens without asking the user again.
- Keep the current behavior for tokens created manually in the profile, where the user picks the expiration.
Attachments
Issue Links
- duplicates
-
OIDC-335 Give access tokens issued by the provider's token endpoint a configurable lifetime and support refresh tokens
-
- Open
-