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

Cognito auth tutorial is faulty #1016

Open
TeoTN opened this issue Dec 31, 2023 · 1 comment
Open

Cognito auth tutorial is faulty #1016

TeoTN opened this issue Dec 31, 2023 · 1 comment

Comments

@TeoTN
Copy link

TeoTN commented Dec 31, 2023

The Cognito auth tutorial is faulty and technically it won't work.

The problem is that up until recently (it changed two weeks ago on the 13/12/2023) Cognito didn't support adding custom claims to access token at all (see this announcement). Now it technically does offer the customisation but the feature requires enabling Advanced Security Shenanigans, which are super duper costly, and the tutorial doesn't cover this at all.

So if you checked your tokens post-authentication like this:

import { fetchAuthSession } from 'aws-amplify/auth';

const session = await fetchAuthSession();
console.log('session', session);

You'll find out that while id token gets updated, the access token doesn't have the claims (unless you're willing to pay up to $2500 for 50k MAU offered by Free Tier Cognito)

@TeoTN
Copy link
Author

TeoTN commented Dec 31, 2023

I think the recommended solution should be to use the claims_map instead of pre-token generation lambda.

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