-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Session Callback should return the updated session if possible #2560
Comments
You just got the session with In v3 (current stable):
This is very hard to understand from the above code (so I can understand your confusion), but you can see the current built-in Prisma adapter's implementation for reference: https://github.com/nextauthjs/adapters/blob/main/packages/prisma-legacy/src/index.js#L136-L192 In the upcoming version, these responsibilities are moved to the core, see the Prisma adapter with updated And the updated session handler code: next-auth/src/server/routes/session.js Lines 71 to 99 in e06ced5
There is already an issue for discussing session updates #2269 Built-in token rotation is planned in the future. |
Hey @balazsorban44, I see from the upcoming version that there is no accessToken anymore. |
Access tokens come from your provider, and usually saved on accounts. No ETA for token rotation |
My token is not coming from the Provider (also I have multiple provider). Fauna can give me ABAC tokens which I want to sync with the session (which accepts accessToken property atm). const FQL = q.Update(
q.Ref(q.Collection(collections.Session), session.id),
{
ttl: q.TimeAdd(q.Now(), sessionMaxAge, 'milliseconds'),
data: {
// added accessToken prop
accessToken: q.Select(
'secret',
q.Create(q.Tokens(), {
instance: q.Ref(q.Collection('users'), session.userId),
ttl: q.TimeAdd(q.Now(), accessTokenTtl, 'milliseconds'),
}),
),
expires: q.TimeAdd(q.Now(), sessionMaxAge, 'milliseconds'),
updatedAt: q.Now(),
},
},
); |
Tokens are usually unique per provider, so it only makes sense to store them on accounts. I believe OAuth providers are already required to return an The next version will make it possible to override certain adapter methods though, so you will still be able to create your own adapter, based on the official ones. The official Fauna Adapter is already rewritten for the new API, see it here for inspiration: |
Wow magnificent ! EDIT : Oops, it's here : https://github.com/nextauthjs/next-auth/tree/next |
Description 📓
Hello everyone !
We use Next-auth in our company, with a custom adapter for FaunaDB. I already posted a discussion but no answers.
I tried to check again the issue and found that the returning session was always the old one & not the updated one, as you can see here.
So why not return the updated session instead ? It could help with token rotation.
Thank you !
How to reproduce ☕️
Contributing 🙌🏽
Yes, I am willing to help implement this feature in a PR
The text was updated successfully, but these errors were encountered: