-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Hierarchic scope strategy not working for OAuth2 Introspection authn #377
Comments
Thank you for the detailed report! Have you enabled the hierarchic strategy in hydra as well? |
Are you referencing this setting in the Hydra config?
I haven't enabled that. Basically because it says it's deprecated. I'm a little confused about what that setting does. I assumed it allowed tokens to be granted scopes that are hierarchically below the allowed scopes of the client. For example, a client with the After thinking about it however, I feel like fixing this on the Hydra side shouldn't be the solution since there are many clients of Hydra and they may use different strategies for validating scopes. Its Oathkeepr's job to do scope validation as a part of authentication. Making it also Hydra's job when introspecting a token seems like it blurs the boundaries a bit. What do you think? |
Yeah that's what I meant. We should probably update the The problem is that ORY Oathkeeper sends the scope as part of the introspection request. Hydra processes this scope parameter (which is actually not defined in the OAuth2 Introspection RFC) according to the scope strategy defined in Hydra (hence my question). The scope strategy defined in ORY Oathkeeper serves as a fallback for when OAuth2 servers do not implement this feature. Therefore, these two settings must be kept in sync�. The same problem would arise if you configure your client to be allowed to request scope We'll probably change the naming of |
This is now referenced here: ory/hydra#1760 I think that if you set the right strategy in Hydra, this will all work as you expect it to. To make it less confusing, we'll update the name in Hydra. If you agree with these findings, we can close this issue as all upstream issues have been created. |
Thanks for getting back to me over the weekend. Renaming the The problem is that Hydra cannot satisfy the scope strategy for all clients. What if one client wants to introspect a token and validate it using the Personally, as it is not part of the RFC, I'd prefer that Hydra didn't do any scope validation on the introspection endpoint. Is it possible to configure Hydra to use the If Hydra can't simply be configured to use the Does that sound reasonable to you? |
Yeah, if Oathkeeper enforces a scope strategy it should probably not send the scope in the request as well. All other options are more intrusive / breaking existing behavior :) Would you be up for a PR? |
I'll get a PR in for this soon. If not today, in the next couple of days. |
This patch removes the `scope` key from the OAuth2 Introspection request body when a scope strategy other than `none` is set for the OAuth2 Introspection handler. If the scope strategy is `none`, the `scope` key is included in the body. Closes #377
Describe the bug
I'm running into an issue authenticating a request with oathkeeper using the hierarchic scope strategy.
I'm trying to lock down my hydra introspection endpoint.
I have added the following to the oathkeeper config to enable the oauth2 introspection authenticator
I have added the following rule to protect my hydra introspection endpoint
I have created the following client for administrative purposes
Using that client I have obtained the following token.
I then attempted to introspect that token with the following request (Format from insomnia timeline)
oathkeeper, which is protecting the introspection endpoint, responded with the following
I then inspected the same token again but this time using a different Authorization token which has the scope of
admin.introspect
.This time the request to was successful and I received the following response.
As you can see the introspected token is active and has the
admin
scope. Theadmin
scope should matchadmin.introspect
using the hierarchic scope strategy.I investigated a little further and found that oathkeeper is sending the required_scope to hydra when inspecting the token.
https://github.com/ory/oathkeeper/blob/master/pipeline/authn/authenticator_oauth2_introspection.go#L88
Since
admin.introspect
, the required scope, doesn't equaladmin
, the granted scope, hydra responds with the following when introspecting the tokenOathkeeper sees this response and rejects the request.
It seems the me that the solution is for oathkeeper to not include the scope when introspecting the token and instead validate the scope itself (which it already does further down)
https://github.com/ory/oathkeeper/blob/master/pipeline/authn/authenticator_oauth2_introspection.go#L132-L138
Environment
The text was updated successfully, but these errors were encountered: