-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
NextAuth Support #2179
Comments
I'd be open to take a look at this if @aeneasr is opento the idea - I'm just getting back into contributing back to OSS, been busy with life. Correct me if I'm wrong though. Isn't this more on next-auth's repo than kratos? |
Hey there! Great idea and we’d love contribs in this area! We also have guides for NextJS already (with video) that will be quite helpful I believe: https://www.ory.sh/login-spa-react-nextjs-authentication-example-api-open-source/ |
Can we use the credentials provider @Immortalin ? In any case, if someone wants to start working on this, I will be very happy to support. |
Any updates on this? |
@ShahriarKh I suppose not. |
The way I integrated with NextAuth is by creating a Custom OAuth Provider using Hydra and then integrating Hydra and Kratos. However, integrating Hydra and Kratos together is a bit of a difficult task by itself 😅 Using the credentials provider to integrate only Kratos with NextAuth seems like a good idea, as @vinckr mentioned. Will code contributions to this issue go to this repo or the example NextJS repo? |
Good question. "Integrations/NextAuth" would make sense IMO, as we also have integration guides for other 3rd party services in the pipeline. Let me know if you would be interested in contributing and if I can help with this. |
I'm also trying to integrate kratos with next-auth and here are some of the approaches I'm considering:
What do you think? Do you have other suggestions for how to integrate kratos and next-auth? |
@vinckr Sorry for not being able to reply sooner regarding this 🙇🏼 I have the following sample repo demonstrating Kratos+Hydra integration that works with Next-Auth. @amorey Thank you for the detailed write-up on all the possible approaches! I did try approaches 1 and 2 and it was just messy, to be honest. From my understanding, Kratos by design is not an OIDC-compliant identity provider. We can however implement one by combining Kratos with Hydra. |
@atreya2011 Thanks for your reply and for sharing your code! Here are some questions:
|
|
@atreya2011 Thanks! This is very helpful. |
Wow great job @atreya2011 !! :) I also wanted to inform you that we are actively working on a native integration between hydra and kratos and expect it to land relatively soon as the core things are working already but still need more testing as well as support for various flows (login, registration, mfa, ...) |
Thank you 🙇🏼 The above flow is actually a combination of the flows already provided in the official documentation of Kratos & Hydra. |
@aeneasr That's great news! Do you have an estimate on when it will be ready to try out? I'm currently working on a hydra+kratos integration and it would be very helpful to have a native solution. |
@aeneasr In case it's useful, here's a Hydra reference implementation for Next.js: Any updates on the hydra+kratos integration? |
Also, here's the same reference implementation with TypeScript: |
@amorey Nice! |
Woah awesome, thanks for sharing those! |
I'd be more than happy to contribute them to /ory/examples! Would you prefer to do a fork or a repo transfer? |
@amorey It looks you can make a PR with your example by creating a folder for it? |
Exactly, you create a folder for each example - apologies for not being clear there. |
@amorey have you made any progress on creating an implementation of Next-Auth + Kratos? i'm specifically interested in your point 3 in response to @atreya2011, as this is exactly what i'm trying to achieve in my setup: "Next-Auth Custom OAuth Provider with Kratos + Hydra (h/t @atreya2011)" |
Yes, I ended up implementing the Kratos consent flow with Next.js and then using the native Kratos+Hydra integration (see https://www.ory.sh/docs/kratos/reference/configuration). I think I used @atreya2011 code as a starting point but it was a while ago so I don't remember and unfortunately the code I'm using is not in a state I could easily open source. If you want to share your progress, maybe I can help. |
@amorey that's great. i'm glad to see someone has done this successfully. as for myself, i don't know what i can share with you that would be useful. basically i just don't understand what i need to do. i'm looking for an example i can look at so i can follow through the code and poke around in it. i managed to take the code from this implementation (https://github.com/ory/kratos-selfservice-ui-react-nextjs) and get it working within my code base, but i don't know what i'm supposed to do next. for a little background, the reason i'm trying to do this is that we've got 3 different sites with different domains that we're trying to get working through the same centralized auth. and the Ory guys told us that we need to use Hydra as authorization via OIDC + Kratos as identity provider. |
|
Preflight checklist
Describe your problem
Ory Kratos does not support https://next-auth.js.org/, Kratos currently requires a lot of custom code to integrate. NextAuth supports FusionAuth, Keycloak, and Auth0 as providers, but not Ory Kratos.
Describe your ideal solution
Ory should create a first party NextAuth provider and send a pull request to the NextAuth repo.
Workarounds or alternatives
N/A
Version
latest
Additional Context
No response
The text was updated successfully, but these errors were encountered: