bug: Cognito access token scope is always aws.cognito.signin.user.admin in authorization code flow #46
zahedulhossain
started this conversation in
Bugs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Current Behavior
In an authorization-code flow where the
authorizerequest asks forscope=openid email profile, andthe app client is created with
AllowedOAuthScopes: ["openid","email","profile"], the access tokenreturned by
/_aws/cognito-idp/oauth2/tokencarries:{ "token_use": "access", "scope": "aws.cognito.signin.user.admin", "client_id": "<client id>", "iss": "http://localhost.localstack.cloud:4566/<pool id>" }The requested
openid,emailandprofilescopes are absent, and a scope that was neverrequested is present instead.
This breaks any relying party that validates the
openidscope on the access token beforetrusting it — a standard check, since
openidis what marks the token as OIDC-issued.Expected Behavior
Amazon Cognito returns the granted scopes from the authorize request. For
scope=openid email profilethe access tokenscopeclaim should contain those values.openidis a system-reserved scope in Cognito, documented alongsideemail,phone,profileand
aws.cognito.signin.user.admin:https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html
Steps To Reproduce
Setup (
SERVICES=cognito-idp, port 4566):Then complete an authorization-code + PKCE flow (login form at
/_aws/cognito-idp/login, CSRF field value istest123) and exchange the code at/_aws/cognito-idp/oauth2/token. Decode the returned tokens:Environment:
All reactions