Replies: 6 comments 14 replies
-
After reading through the access logs for HTTP request from application I noticed that the link containing the verification token showed a GET request from a "Barracuda" network IP address before the login email hit my inbox. See this discussion Do mail servers follow links in emails as part of a security scan before inbox delivery? Are there any suggestion on how to get around this? |
Beta Was this translation helpful? Give feedback.
-
Is there any convenient way to make the VerificationToken allow for multiple uses within a certain window (or generally)? It's less secure, but in outlet case that isn't a concern. This issue is very aggravating. |
Beta Was this translation helpful? Give feedback.
-
I see a similar issue when clicking a link in Gmail (Inside Shift.app which could be a factor), the original URL has more added. From what I can see, Google is performing a malicious link check - https://support.google.com/mail/answer/10173182?hl=en So for example, this link:
Becomes this when it hits the browser:
So as mentioned above, (From what I can gather) the link is being followed by Google when I click it, and the verification token is being deleted before the real user can use it after the redirect. The difference to the original poster is that I can see the verification token in the database before clicking the link. If I copy and paste the link from the email, it works fine every time. |
Beta Was this translation helpful? Give feedback.
-
As a temporary solution, I have created a wrapper for the main adapter and overridden the Bear in mind the tokens still have an expiry date so become useless after that time. This is for DynamoDB but I think the concept would be similar for the other adapters as
|
Beta Was this translation helpful? Give feedback.
-
We ended up having to do a similar thing, though against the Ultimately, we chose to redirect the user to a hosted confirmation page which requires a final button click to confirm verification, where the button then sends the actual GET against the NextAuth API. Then we implemented a custom We had to add a pair of columns to the When We can then await an update for the verification token provided, incrementing This combination has fixed even the most egregious issues with corporate link checkers and extensions which check navigation safety, with the drawback that we create sessions for each of those systems as well (though that was happening already). Technically this could also facilitate some link sharing, though that's a pretty minimal issue IMO if you structure the expiry and uses appropriately. It'd be absolutely amazing for this approach to be an optional feature out of the box. We had far too many poor customer experiences before coming to a full solution which would work across the most aggressive of environments. |
Beta Was this translation helpful? Give feedback.
-
Update: 2024-10-04 People have reported that the method suggested in the docs below does not prevent all link checkers from consuming the token. Update: 2024-03-16 Ignore everything else I said. The correct answer is in the docs: https://next-auth.js.org/tutorials/avoid-corporate-link-checking-email-provider Update: 2023-10-25 I decided to take a different approach. Instead I'm changing the link sent to users to a page where the user can click a button that uses the magic link generated by next-auth. I prefer this solution over modifying the behavior of the adapter. So the link inside the email looks something like Clicking Continue sends a request to Original Spent a couple hours trying to figure out why some users couldn't login. Glad I found this. I'm working around this by customizing the See: lukevella/rallly#909 I know this probably isn't ideal but at least it doesn't require a database migration. Looking forward to a proper solution for this. |
Beta Was this translation helpful? Give feedback.
-
Question 💬
I'm having an issue where after our app has been deployed to run on our server (Ubuntu / Apache2) the verificationToken will immediately get utilized after the user submits their email to login on the sign-in page. The prevents them from login using the link sent to the user in their email because the token has already been used and deleted from the database. We are using the Email provider only.
I noticed in the debug logs that [next-auth][debug][adapter_useVerificationToken] is being called instantly after the user logs in. This never occurred on any builds deployed locally.
Any thoughts on why this is happening? Log below
[next-auth][debug][adapter_createVerificationToken] { args: [ { identifier: '[email protected]', token: '59ce8a420596af22c7d4a98650654a917547f313a6ae7e6658520abbfd0683e2', expires: 2022-05-19T19:14:14.725Z } ] }
[next-auth][debug][adapter_useVerificationToken] { args: [ { identifier: '[email protected]', token: '59ce8a420596af22c7d4a98650654a917547f313a6ae7e6658520abbfd0683e2' } ] }
[next-auth][debug][adapter_getUserByEmail] { args: [ '[email protected] ] } { email: '[email protected]' } [next-auth][debug][adapter_getUserByEmail] { args: [ '[email protected]' ] } [next-auth][debug][adapter_createUser] { args: [ { email: '[email protected]', emailVerified: 2022-05-18T19:14:18.372Z } ] }
How to reproduce ☕️
Sign In using the "Email" provider
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions