-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Client allowed_cors_origins not working #1754
Comments
Would it be possible for you to provide a server config and client config (JSON or CLI command are ok) to make the reproduction easier? This feature has several tests as it had some issues in the past and it will make bug hunting much easier :) |
huh... I swear I had the server config in my initial post....
Client configuration
|
Nice find, it actually appears that the server-based origin only works if the server config is either serve:
public:
cors:
enabled: true
allowed_origins:
- *
# - you may include additional origins here but since there's already a wildcard it doesn't make sense or serve:
public:
cors:
enabled: true but not if a concrete value is set. That's definitely a bug! Instead of doing a check here https://github.com/ory/hydra/blob/master/driver/cors.go#L60-L70 we should merge these origins with values coming the client and then run the glob matching on top of that. We can still keep the |
I think this issue was incorrectly being kept open and has been resolved since. #1959 added a test case to cover this so hopefully the issue is properly resolved :) |
Unfortunately, this still isn't working as I would expect. (tested with version 1.5.2) Configuring If I set If I set |
Ok, sorry about that - looks like I need to spend some more time debugging this |
Nope, I can't reproduce this. Please upgrade to 1.6+ just in case. Using env vars
and an OAuth2 Client
I get the correct % curl -v --user foobar:bazbar -H "Origin: https://baz.bar.com" -X POST http://127.0.0.1:4444/oauth2/token --form "grant_type=code"
> POST /oauth2/token HTTP/1.1
> Host: 127.0.0.1:4444
> Authorization: Basic Zm9vYmFyOmJhemJhcg==
> User-Agent: curl/7.64.1
> Origin: https://baz.bar.com/
< Access-Control-Allow-Origin: https://baz.bar.com/
< Access-Control-Expose-Headers: Content-Type
< Content-Type: application/json;charset=UTF-8
< Vary: Origin and % curl -v --user foobar:bazbar -H "Origin: https://foo.bar.com" -X POST http://127.0.0.1:4444/oauth2/token --form "grant_type=code"
> POST /oauth2/token HTTP/1.1
> Host: 127.0.0.1:4444
> Authorization: Basic Zm9vYmFyOmJhemJhcg==
> Origin: https://foo.bar.com
< HTTP/1.1 400 Bad Request
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Origin: https://foo.bar.com
< Access-Control-Expose-Headers: Content-Type using any other non-whitelisted origin: % curl -v --user foobar:bazbar -H "Origin: https://not-whitelisted.com" -X POST http://127.0.0.1:4444/oauth2/token --form "grant_type=code"
> POST /oauth2/token HTTP/1.1
> Host: 127.0.0.1:4444
> Authorization: Basic Zm9vYmFyOmJhemJhcg==
> Origin: https://not-whitelisted.com/
< HTTP/1.1 400 Bad Request
< Content-Type: application/json;charset=UTF-8
< Vary: Origin
< Date: Mon, 10 Aug 2020 10:02:17 GMT
< Content-Length: 429
<
* Connection #0 to host 127.0.0.1 left intact So as you can see, and as the tests already confirmed, this all works as expected. |
@aeneasr I'm experiencing the same issue with hydra v1.7.4. I think that your replication attempt failed because @Alt0252 client has It seems like that client-specific |
Right, looks like that could be an issue! Would you be open to provide a fix for this or help investigate the issue further? |
Is it possible to address this in 1.9.0? |
@aeneasr, thank you for the quick fix. I'm aware that it's already freezed, but is there a chance this update will also land on v1.x branch? |
Since it's such a small change please feel free to back port it to v1.x in a PR and we'll get it into the 1.x branch :) |
Hi @aeneasr do you have plan to create v1.x release that contains this fix? thanks |
I'm using hydra v1.11.10 and I'm still having this issue. |
@lortabac I remember having similiar problem... This may or may not solve your problem, but if I remember correctly... Hydra needed the So if you're using old Hydra, even with PKCE, you still need to manually send at least the |
@IronGeek Thanks for your suggestion. Unfortunately I can't include an Authorization header since the client is configured with |
As far as I can see the bug has been fixed for authentication method |
Oh, right... I forgot about that part. |
@IronGeek Sorry I don't understand. Did you have to edit Hydra's source code? Or is it something that can be done just by configuring the client appropriately? If I set |
No, other than having this PR (#3163) merged, I didn't need to edit Hydra's source code... I just need to make sure the client still send the To emphasize again, ONLY THE With the recent PR (#3457), I think you could also sent the |
Ok at last I found the solution! In order to pass the For example:
If you include a dummy password or omit the colon, it will not work. Thank you very much @IronGeek ! |
Describe the bug
Enabling CORS support on the public endpoints seems to be working as expected by enabling the settings in the configuration, however when setting the
allowed_cors_origins
setting in the client, the additional origin URLs are not being allowed.Reproducing the bug
Steps to reproduce the behavior:
my_client
with allowed_cors_origin set to an alternate (additional) Origin URLaccess-control-allow-credentials: true
access-control-allow-origin: https://client-app.example.com
Server logs
Server configuration
Expected behavior
expect https://client-app.example.com to be an allowed origin
Environment
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: