mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 07:11:11 -05:00
POST /cognito-idp/oauth2/token, and /oauth2/token on a custom domain, now renew a session with grant_type=refresh_token through the refresh that GetTokensFromRefreshToken uses, answering as AWS does. As on AWS, the grant requires neither ALLOW_REFRESH_TOKEN_AUTH nor any OAuth setting on the client. The client is checked before the token: a Basic header names it whatever the body says. A public client's Basic credentials are refused, and its body client_secret is ignored. Errors are 400 without WWW-Authenticate: invalid_client for a missing or unknown client, a public client's Basic credentials with an empty secret, or another pool's client on a custom domain; invalid_client with invalid_client_secret for a missing or wrong secret, or a public client's Basic credentials with a secret; invalid_request with invalid_refresh_token for an empty or absent token; and invalid_grant for a token that is not valid, expired, revoked, or another client's. The answer has access_token, expires_in, token_type, and an id_token exactly when the original sign-in issued one, and no refresh_token, as rotation is not implemented. A request without grant_type is now invalid_request with no description, as on AWS. A code grant's refresh token now carries its granted scopes, base64url encoded in a field after the family id, so a refresh keeps them instead of falling back to aws.cognito.signin.user.admin, and the pre token generation trigger is told them. API sign-ins and tokens minted before this change have no such field and refresh as before. A refresh keeps the sign-in's auth_time and origin_jti. InitiateAuth REFRESH_TOKEN_AUTH and GetTokensFromRefreshToken mint the same tokens as the token endpoint. As on AWS, a refresh of a grant holding a scope the client no longer allows is refused rather than narrowed: invalid_grant on the token endpoint, and NotAuthorizedException "Client is not allowed to request these scopes" on both APIs. The refresh token is parsed from both ends, so a username holding a pipe refreshes too. GetTokensFromRefreshToken and InitiateAuth REFRESH_TOKEN_AUTH now refuse a refresh token issued to another client with NotAuthorizedException "Refresh Token has different Client".