Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalUserMapper throwing an exception when given IdToken representing unknown local user #13

Open
malkovro opened this issue Nov 27, 2020 · 1 comment

Comments

@malkovro
Copy link
Member

Issue

Currently the LocalUserMapper will fail if provided an idToken and if the callback find_by_cognito_attribute on the UserRepository returned nil.

This is because the gem is trying to fetch the CognitoUser using the token as an accessToken to provide it as input of the after_local_user_not_found callback.

@malkovro
Copy link
Member Author

Potential Solution

Prevent the call to Cognito and returned an error before hand. We can check if the token passed is an idToken by looking at the token_use attribute on it.

Ref: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html#amazon-cognito-user-pools-using-the-id-token

Maybe we should change the input of the callback after_local_user_not_found to accept a PORO representing the user because the id token is supposed to contain all user attributes and such object could be hydrated without having to call Cognito.

@malkovro malkovro changed the title LocalUserMapper LocalUserMapper throwing an exception when given IdToken representing unknown local user Nov 27, 2020
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

No branches or pull requests

1 participant