-
-
Notifications
You must be signed in to change notification settings - Fork 965
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
Google OIDC not containing the necessary cookie to resume session when using HTTP API #3384
Comments
References #3074 |
Please make sure to use If the message is saying |
Thanks @mooijtech for your response. Are you referring to my
I also was able to get the Registration, Login, and Logout flow working with this I appreciate your input and I have updated all
Thank you all for your time. |
|
Thanks for your response @mooijtech. That slipped my mind earlier, however I tried it now and it seems to fail. The issue now is due to Google's OAuth 2.0 policy requirements. Mapping
To quickly hack around this I tried mapping Do you think that this experiment is enough to conclude that the issue is not with the Thank you for your time. |
Hi @eddingston - you ticked "This issue affects my Ory Network project." - can you please share the URL with us so we can reproduce? |
Hello @aeneasr, I assumed that "This issue affects my Ory Network project." meant "This issue affects my project which uses an Ory product." since it the hyperlink just brought me to the Ory homepage. The project has not been deployed to a public URL. However, the steps to reproduce are listed in the ticket, which requires running the Sveltekit app locally. Would it be easier for you to investigate if I were to get this deployed to a public URL? I can try to get this deployed if this is the case. Thank you for your time! |
Consider running Caddy (or NGINX) so you have HTTPS locally, possibly cookies are being rejected on HTTP.
Edit: Note that if using NodeJS (I'm using NextJS) there is an environment variable: |
@eddingston I am getting the same issue all of a sudden on a NextJS project with Ory Network (so no self-hosted in my case). It happens on both Apple and Google Oauth flows. On the Ory Network welcome page, I can login successfully, but I cannot do this on a NextJS website either by using localhost, 127.0.0.1 or a custom domain as @mooijtech pointed out. @aeneasr I set up an Ory Network project that can reproduce this with Google sign in. It works when using username and password, but not with Google. Again, I'm using the base code in this example |
@tomcastro Can you try with Caddy for HTTPS? |
@mooijtech just tried with Caddy and correctly have an HTTPS domain, but I get the same error when logging in through any OIDC provider. |
Hello all, I am closing this issue because it is related to an issue in setting up Ory Kratos on localhost with Caddy and other aspects. Thus, it's not a bug in Ory Kratos itself and should not be on the bug tracker. We have some documentation on cookie issues that you may want to check: ps: This feature works fine for hundreds of customers, in tests, in Ory Kratos, and in Ory Network :) |
did you get this working @tomcastro I am facing the exact same issue. |
okay, I was finally able to fix it - okay, I was able to fix it. I had to set |
Preflight checklist
Describe the bug
I am trying to set up Google social login in my Sveltekit Application using the Ory Kratos HTTP API.
So far, I have been successful with setting up Registration, Login, and Logout flows.
But now I am having troubles with the Google OIDC.
I am able to get to the Google sign in page but when I choose my account, I get the following error:
An error occurred with the following message: The browser does not contain the necessary cookie to resume the session. This is a security violation and was blocked. Please clear your browser's cookies and cache and try again!
It is unclear to me what I am missing. Vincent(ORY) has suggested that I need to include the CSRF cookie and the Ory Session cookie. In the other flows (Registration, Login, Logout), I passed the data in the
Set-Cookie
and the body of the HTTP request as'Content-Type': 'application/json'
, but that does not seem to work for this situation.I have a trimmed down version of the issue posted here:
The flow starts at https://github.com/eddingston/ory-kratos-google-issue/blob/master/src/routes/%2Bpage.svelte.
The above is what retrieves the CSRF cookie. I don't think a session is active at this point because we have no logged in with any users.
Finally, at https://github.com/eddingston/ory-kratos-google-issue/blob/master/src/routes/%2Bpage.svelte, if we click the 'Sign in with Google' button, it will run the handler above in the same file. This will make a call to https://github.com/eddingston/ory-kratos-google-issue/blob/master/src/routes/api/auth/google/%2Bserver.ts, which returns a redirection url.
The frontend should now be redirected to the Google sign in page. If we pick an account it will show the error.
An error occurred with the following message: The browser does not contain the necessary cookie to resume the session. This is a security violation and was blocked. Please clear your browser's cookies and cache and try again!
Thank you for your time! I look forward to hearing from the Ory team!
Reproducing the bug
EDIT: At the time of editing this, it is required to add
127.0.0.1 edd-test.com
to/etc/hosts
for the app to work.git clone [email protected]:eddingston/ory-kratos-google-issue.git
cd ory-kratos-google-issue
kratos.yml
and make sure that a valid Google client_id and client_secret has been set.cd kratos && docker-compose up -d
cd .. && npm install && npm run dev
http://localhost:5173/http://edd-test.com:5173Relevant log output
An error occurred with the following message: The browser does not contain the necessary cookie to resume the session. This is a security violation and was blocked. Please clear your browser's cookies and cache and try again!
Relevant configuration
Version
oryd/kratos:v0.13.0
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Docker Compose
Additional Context
No response
The text was updated successfully, but these errors were encountered: