huggingface / chat-ui

Open source codebase powering the HuggingChat app
https://huggingface.co/chat
Apache License 2.0
7.41k stars 1.08k forks source link

Can't login to Google using openid - error in chrome due to cross origin !!! #1003

Open nird3d opened 6 months ago

nird3d commented 6 months ago

Hello, I created a docker space for chat-ui. it works great and now i want to add the google openid connection. this is how my .env.local.template file looks like

OPENID_CONFIG={   "PROVIDER_URL": "https://accounts.google.com",   "CLIENT_ID": ****,   "CLIENT_SECRET": ****,   "SCOPES": "openid profile email"   }

i configured the consent screen on my gcp console (i hope i did it right). anyway i get the chatui screen with a Sign In button but if i press it nothing is really hapenning. Thanks for your help, Nir

image

This is what i get when i click on sign-in and nothing happens/. image

madppiper commented 6 months ago

I got openid running pretty well on my end. My config matches yours:

OPENID_CONFIG=`{
  PROVIDER_URL: "https://accounts.google.com",
  CLIENT_ID: "****.apps.googleusercontent.com",
  CLIENT_SECRET: "GOC*********",
  SCOPES: "openid profile email"
}`

Did you at least get forwarded to the google interface for granting the permissions?

For debugging: Can you check the error message in the docker container and perhaps check on google dashboard for the exception message?Also: how did you set up the openid application on google, did you make it a private or a public application?

nird3d commented 6 months ago

The issue seems related to the main URL i acess the space from. If i am accessing from https://huggingface.co/spaces/nirdrang/Anthroposophy-RAG i have the issue. If i am accessing from https://nirdrang-anthroposophy-rag.hf.space i have no issue. Thanks

madppiper commented 6 months ago

It's a bit strange that your frame is pointing to huggingface.co -> can you check that you set the PUBLIC_ORIGIN correctly?

nird3d commented 6 months ago

Hi, I just kept the original .env.local.template " PUBLIC_ORIGIN=${SPACE_HOST} PUBLIC_SHARE_PREFIX=${SPACE_HOST}/r PUBLIC_GOOGLE_ANALYTICS_ID=#G-XXXXXXXX / Leave empty to disable PUBLIC_DEPRECATED_GOOGLE_ANALYTICS_ID=#UA-XXXXXXXX-X / Leave empty to disable "

madppiper commented 6 months ago

Try setting PUBLIC_ORIGIN to your domain in your env.local file

nird3d commented 6 months ago

Hi, I dont have .env.local as i am having the docker from the space creation template. i have only .env.local.template. should i try changing PUBLIC_ORIGIN=https://huggingface.co/ PUBLIC_SHARE_PREFIX=https://nirdrang-chat-ui.hf.space/chat/

@coyotte508 - i think its very similar to bug 236 https://github.com/huggingface/chat-ui/pull/236

Thanks for your suport

coyotte508 commented 6 months ago

The issue seems to come from https://github.com/huggingface/chat-ui/commit/545f27c577d1d6be0f34a73e17f1185e993c3de5 cc @nsarrazin

The iframe's content tries to change the url of the parent window without being allowed.

@nird3d you can try reverting that commit

At least for the part in src/lib/components/LoginModal.svelte

nird3d commented 6 months ago

I tried reverting the file src/lib/components/LoginModal.svelte but still experiencing the same issue.

nsarrazin commented 6 months ago

I think the issue is due to cookies inside of a space in iframe view being treated as 3rd party cookies and being blocked by some browsers. We have a similar issue for the official huggingchat space, it only works when viewing the page from the main URL.

Not sure what we could do about it, other than redirecting users to the main URL in a new tab? 👀