Cognito issued JWT does not contain user roles

0

According to this SO - User roles in Amazon Cognito the user roles should be available in the JWT returned by Cognito. However when inspecting the JWT I don't see any roles nor the cognito:groups claim that is supposedly there.

From what I understood these scopes were needed for this to work:

Enter image description here

Is there a specific option that needs to be enabled as well? Am I supposed to use a Pre authentication Lambda trigger for this?

Notes:

  • We have configured Congito to use IAM Identity Center SAML application as the external identity provider.
已提問 9 個月前檢視次數 610 次
1 個回答
1
已接受的答案

Hi,

While you configured the Client Application to be able to use the scopes aws.cognito.signin.user.admin, Email, OpenID, Profile, you need to request them so that the token issued includes the necessary scopes.

Please ensure that when your Client is doing an Authorization call to Cognito on the /oauth2/authorize endpoint it includes all the necessary scopes in the request as defined in the query string parameter scope - see documentation https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html

Cognito when it receives an authorization request on /oauth2/authorize first checks that the scopes requested are part of the scopes authorized for this client id. Then it issues an authorization code that can be exchanged for JWTs. Those JWTs will only include the scopes requested during the authorize call. If you miss a scope, Cognito will not fill that out based on the list of scopes authorized. An if you miss the scope that can allow to read the group membership / role memebership, those won't be included in the JWTs.

Jeff

AWS
已回答 9 個月前
  • Yep... I was missing the openid scope. Thanks! :)

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南