-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add support for Mozilla Accounts prompt none auth flow #5104
Conversation
Preview URL 🚀 : https://blurts-server-pr-5104-mgjlpikfea-uk.a.run.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. However, if I visit http://localhost:6060/?utm_campaign=settings-promo&utm_content=monitor-free without being logged into FxA (with the flag enabled), I get the Next-Auth error page:
That's me ending up at http://localhost:6060/api/auth/signin?error=Callback
.
Same if I'm signed in to Monitor, then sign out, and then visit that URL again. The only way I can get it to work, is by signing in to Relay, and then visiting the URL.
This also seems like exactly the type of use case where a couple of end-to-end tests would be useful, perhaps?
import { authOptions } from "../../utils/auth"; | ||
|
||
const handler = NextAuth(authOptions); | ||
// There is currently no support for handling OAuth provider callback errors: | ||
// https://github.com/nextauthjs/next-auth/discussions/8209 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment, hopefully they add this eventually.
Thanks for catching this issue @Vinnl! I did not run into this issue myself before, but was able to reproduce it in private browsing mode. If a user is not authenticated with FxA we get a callback error. I’m handling this error now in the NextAuth handler here.
Absolutely! I ran into some limitations around feature flags while adding E2E tests (something we need to introduce a workaround for) for the silent authentication flow. I have an “almost ready to push” branch that addresses the issue around feature flags and I’m adding the E2E tests as a quick follow-up. Edit: Opened PR #5150 for adding the E2E tests. |
Cleanup completed - database 'blurts-server-pr-5104' destroyed, cloud run service 'blurts-server-pr-5104' destroyed |
`${process.env.SERVER_URL}/api/auth/callback/fxa?error=`, | ||
) | ||
) { | ||
return NextResponse.redirect(`${process.env.SERVER_URL}/user/dashboard`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flozia Shouldn't this be going to /
rather than /user/dashboard/
? Now, if I'm not signed in, I get redirected to FxA, then back to Monitor, then to the dashboard, where I see a flash of an error page, before being redirected back to FxA, but this time not a prompt=none
flow, so I'm still asked to sign in. (If that's what we want, we could just not do a prompt=none
flow, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References:
Jira: MNTOR-3492
Description
Adds support for Mozilla Accounts
promt=none
authentication flow. The initial use cases will be a promotional link from Mozilla Accounts. We expect them to link to us with the following UTM parameters that we can use to initiate thepromt=none
authentication flow:utm_source=moz-account
utm_campaign=settings-promo
utm_content=monitor-free
How to test
PromptNoneAuthFlow
Checklist (Definition of Done)