-
-
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
fix: Dgraph adapter (issues and updated default jwt encoding) #11338
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@adriangalilea is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
While my manual testing works properly with the next-auth example repo and user creation sign-in and sign-out. I've been trying to update the testing methodology currently present for Dgraph, seems like nothing was working so I don't know what to compare it to, see results:
I've reworked the script logic and update the tests to use HS512 (and included the new key), while I can't make it work fully, the whole test.sh script is way more robust and clean, if anyone can point me in the right direction on what could be going wrong, I'd appreciate @ndom91 @ubbe-xyz My results currently are:
|
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.
Could you revert the removal of format
?
This is related to https://authjs.dev/guides/creating-a-database-adapter#official-adapter-guidelines 5.
Hi @ryanfoxtyler! Could you or someone from the Dgraph-js team please get involved in fixing the authorisation adapter for the database? |
☕️ Reasoning
Dgraph adapter is outdated in several ways:
JWT session and @auth directive
This is no longer true so I updated the client and the docs, to favor HS512 as default to match next-auth and simplify, there's no need for custom encoding/decoding nor that section of the docs, respected backwards compatibility, and documented both in code and in the
.mdx
DgraphClientError: unknown field
errorCurrent adapter docs used
ID
while injecting next-auth generated id but Dgraph ID means internally generated ID, so I modified the adapter so that it respects the internal Dgraph ID's rather than using next-auth generated ones. I believe this is the right way, but I also added a warning on the docs a warning about this behaviour and how to opt-out.General rework
I may not be the best typescript programmer, but for instance, every adapter method used
any
, and also removed boilerplate. I'm not sure if all the changes are good and would love for someone to review it.I've tested:
I think many of the code is redundant, things like createSession never seem to trigger, and I guess that's due using jwt always in order for the authz in Dgraph to work. So maybe all that code can be removed and the decision documented.
🧢 Checklist
🎫 Affected issues
Fixes: #11273
#10719
📌 Resources