Skip to content
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

CORS for public is disabled? #1387

Closed
toddams opened this issue Apr 25, 2019 · 11 comments
Closed

CORS for public is disabled? #1387

toddams opened this issue Apr 25, 2019 · 11 comments

Comments

@toddams
Copy link

toddams commented Apr 25, 2019

Describe the bug
Seems like setting environment variable "SERVE_PUBLIC_CORS_ENABLED" makes no effect. I can not find any message in log that CORS is enabled, even though for Admin part it works with "SERVE_ADMIN_CORS_ENABLED".
Also, I see this line:

EnhanceMiddleware(d, publicmw, d.Configuration().PublicListenOn(), public.Router, false, "public"),
- seems like configuration setting is not taken into account at all (false is passed)

To Reproduce
Run hydra with following environment variables

environment:
      - SERVE_PUBLIC_CORS_ENABLED=true
      - LOG_LEVEL=debug
      - SERVE_PUBLIC_CORS_DEBUG=true
      - SERVE_PUBLIC_CORS_ALLOWED_ORIGINS=*
      - SERVE_ADMIN_CORS_ENABLED=true
      - SERVE_ADMIN_CORS_DEBUG=true
      - SERVE_ADMIN_CORS_ALLOWED_ORIGINS=*
      - CORS_ALLOWED_ORIGINS=*
      - SECRETS_SYSTEM=youReallyNeedToChangeThis
      - DSN=postgres://$POSTGR_USER:$POSTGR_PASSWORD@database:5432/$POSTGR_DB?sslmode=disable
      - URLS_LOGIN=http://localhost:5000/openid/login
      - URLS_CONSENT=http://localhost:5000/openid/consent

Expected behavior
CORS is enabled

Version:

  • Environment: docker
  • Version: v1.0.0-rc.9_oryOS.10
@aeneasr
Copy link
Member

aeneasr commented Apr 25, 2019

What endpoint are you trying to access?

@toddams
Copy link
Author

toddams commented Apr 25, 2019

It's /userinfo

@aeneasr
Copy link
Member

aeneasr commented Apr 25, 2019

What does the log show?

@aeneasr
Copy link
Member

aeneasr commented Apr 25, 2019

CORS is enabled differently at those endpoints as OAuth 2.0 Clients can advertise their own origin. It's most likely something missing, I would include CORS_ALLOWED_HEADERS (with Authorization because you're sending the access token), potentially CORS_ALLOW_CREDENTIALS as well as the methods (POST, GET).

@aeneasr
Copy link
Member

aeneasr commented Apr 25, 2019

You can check if ./well-known/jwks.json responds with CORS headers, if it does it's probably due to you sending an Authorization Header.

@simenandre
Copy link

👋
I'm having issues with this as well. I'm still testing, but I've tested against ./well-known/jwks.json. CORS did not work there either.

@aeneasr
Copy link
Member

aeneasr commented Apr 25, 2019

I just tried it and CORS is working fine, pretty sure it's the header setting.

$ hydra serve all --dangerous-force-http

image

@simenandre
Copy link

I've tested more – and got it working. You just have to make sure to add Authorization to CORS_ALLOWED_HEADERS.

@aeneasr
Copy link
Member

aeneasr commented Apr 26, 2019

Perfect, I'll document that in the docs.

@aeneasr
Copy link
Member

aeneasr commented Apr 26, 2019

I've added this to the docs

@aeneasr aeneasr closed this as completed Apr 26, 2019
@aeneasr
Copy link
Member

aeneasr commented Apr 29, 2019

We'll actually set the defaults to something sane, as per #1400 .

This will hopefully avoid unnecessary work in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants