Open howardkitto opened 8 months ago
I wrrited the blog post and sample code. take a look https://dev.to/dango0812/nextauth-with-aws-cognito-email-google-sign-in-5ef6
@dango0812 is your setup compatible with edge middleware or is Cognito in general not compatible?
@dango0812 is your setup compatible with edge middleware or is Cognito in general not compatible?
Middleware and Cognito are unrelated, could you please provide more details or clarification on the topic you want to inquire about?
I was looking at the repository linked at the end of the blog post and found no examples surrounding auth-gating with middleware.
@kylemh I apologize for contacting you late. To handle authentication and redirection after verification in the middleware, you can access it through 'getToken' and process accordingly.
sample code
import { getToken } from "next-auth/jwt";
const session = await getToken({ req, secret: process.env.NEXTAUTH_SECRET });
// your session object key check and redirect
if ...
return NextResponse.redirect(new URL(""))
What is the improvement or update you wish to see?
The docs here: https://next-auth.js.org/providers/cognito
Refer to these settings:
The aws UI must have changed - it took me a while to find these settings - they are in appclient / hosted UI and before you can set them you must set up a cognito domain. They look like this now:
Wasted quite a while figuring that out!
It would also be great to include the cloudformation template for this
Is there any context that might help us understand?
I'm trying to create a secure custom authflow for my AWS SAM backend
Does the docs page already exist? Please link to it.
https://next-auth.js.org/providers/cognito