Replies: 3 comments 1 reply
-
|
I just realized from this question that i might have a missunderstanding. my traefik rule was
and in the middleware i had the callback set to
as i thought my app would be responsible for handling the callback. Thats not correct, right? the oidc middleware deals with the callback via some "overlay magic"? |
Beta Was this translation helpful? Give feedback.
-
|
I don't really know BetterAuth but isn't this a full authentication solution for Next.js, handling the whole authentication flow/state cookies etc. on it's own? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much for your response. I really had a misunderstanding here. I changed the setting to let the middleware handle the whole auth process. Works great. Thank you! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I’ve set up Traefik, Keycloak, and traefik-oidc-auth, and I’m trying to authenticate one of my services which is a Next.js application that uses BetterAuth for the authentication part.
What works:
If I disable traefik-oidc-auth, BetterAuth is able to authenticate directly with Keycloak without any issues.
What doesn’t work:
When I access a route protected by the traefik-oidc-auth middleware, I get redirected to Keycloak as expected, and after a successful login, I’m redirected back to the Next.js app (with the correct callback URL).
However, I then receive the following error:
ERROR [Better Auth]: State Mismatch. OAuth state cookie not foundThis makes sense, since the authentication flow wasn’t initiated by BetterAuth, so the state cookie never existed.
My understanding is that the state cookie is required so the app can verify that the callback corresponds to an authentication request it originally initiated.
Given this, I’m unsure whether traefik-oidc-auth should be responsible for setting such a state cookie, or if this is something I should raise as an issue/discussion in the BetterAuth repository.
Or perhaps I’m misunderstanding something altogether?
Beta Was this translation helpful? Give feedback.
All reactions