-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Ability to apply UserDetailsChecker to OAuth2 Resource Server flows #6237
Comments
@edeandrea Thanks for your proposal! The tricky part is that there isn't a Likely, any converter we roll into master should play nicely with these semantics. For example, the default, As you can imagine, it's confusing for users to hear "remember that if you use this converter, then the token is no longer the principal, meaning that such-and-such features will work differently for you now." (And to be clear, none of the above means that the implementation you are proposing is wrong-headed. It just may mean that it isn't a fit to be rolled into master. I am going to mark this ticket for team discussion, though, to see what @rwinch et al think.) Happily, though, as you have discovered, you can do this with your own |
Thanks @jzheaux No at this moment I'm not blocked - I just hate having to write my own custom stuff when (in theory) things really belong "up" a level :) As a framework developer here at my company we always prefer to not have to write custom code and instead "wire" spring code together to make things work the way we want to work. At first when I was implementing this I was under the same impression as you - that everything you should need to perform authorization/authentication should be on the token. Then after looking at how some of our applications behave - we have some applications which use more than one identity source (meaning in OAuth-speak a single resource server with multiple authorization servers). When a request comes in, the resource server needs to determine from the issuer which authorization server can authorize the request. In our situation (which may not be completely ideal and not 100% true OAuth2) some of our applications maintain their own role-based authentication mappings in their own data sources outside of the authorization server. This means that the concept of a Its somewhat of a hybrid solution between custom authentication & pure/true OAuth, but I think you'll find many large organizations have a mix of legacy & new and they have to have something in-between. This would allow the application to then apply the At the end of the day the I have this all built out in our framework here within our organization - so if submitting a PR for you & the team to look at and talk about would make things easier I'm happy to do that. |
@edeandrea Are you aware that you can override For example, by overriding I'm also not sure if integrating |
Yes I saw that - but how would that work on the reactive side when we're dealing with a Like I mentioned what we're doing isn't 100% OAuth2 stuff - we have a hybrid where we are using Jwt tokens as an authentication mechanism as a bridge between old siteminder-based authentication and cloud-based authentication. We're trying to use Spring Security's new oauth2 resource server abstractions as an implementation while trying to assemble some of the building blocks together. |
@edeandrea it might be nice to see what you are doing, though I don't think we are ready for a PR. Would you mind checking something into a branch in your fork and linking to that here in the ticket? |
I can certainly do that. I will get something up today. |
I pushed commit edeandrea/spring-security@b6b9037 to the gh-6237 branch in my local repo. This was done in a way to be completely non-intrusive at all to the way current things work. It just offers a different Let me know your thoughts. |
@edeandrea Thanks again for all the information you provided for this ticket. Based on your branch, it appears that you just need a hook for refining the list of authorities. To that end, I've created a ticket to create a As for the proposal, to have an official implementation that supports a If we go down the other route for the moment and imagine trading out the JWT for a representation of the user in the To your comment about bridges, I understand. In a previous life, I had similar experiences with Cognito and needing to bridge bearer token authentication into our existing |
Thanks @jzheaux for the feedback. I'd also say another thing that would be nice to have is the ability to decorate the The Cognito example you brought up above is a great use case. The access token, while having a subject (which is the primary key in identifying the user in Cognito), doesn't have what the application needs as its primary identifier (i.e. an active directory user name, email, etc). What we end up having to do is once the token is decoded & validated, we have to call Cognito's What we've done is to decorate the We've had to do it in a clunky way due to the fact that It would be nice maybe to add a |
I created somehow related issue #7834. I think, if it will be implemented, then we obtain an ability to use @jzheaux, you say:
Can you explain a bit? I don't understand the point. Yes, authorities play a big role in Resource Server semantics, but User (subject) is also important. They both complement each other. For example: a token contain scopes that you, as an owner, grant to an application to load your photos. But resource server doesn't contain only your photos. So, it usually needs to check not only scopes from the token, but also a userId, and also a user authorities. Yes, user authorities, which are totally different thing than scopes.
If token have "read:photos" scope, but user (subject of the token) doesn't have authorities to read his photos from this resource server (maybe he is banned or his premium membership is ended), then resource server must not respond to request, authenticated with this token, with user photos. Because even if user allowed it (granting scopes), the resource server don't allow it for this user anymore. Does this make any sense? |
Yes, it does make sense to differentiate between the two types of authorities; that is, authorities that the resource server grants to the user and authorities that the user grants to the client. These are authority-based concerns that already fit nicely into the current model (e.g. with a granted authorities converter).
For sure!
Like I said earlier in this ticket, it's not necessarily wrong-headed to use That said, I took a look at #7834 and like the idea. I think that either exposing the principal constructor parameter or possibly making |
Spun out from #6219.
We need the ability to apply a
UserDetailsChecker
to the OAuth2 Resource Server flows.My initial thoughts on implementation would be to have converters (i.e.
Converter<Jwt, AbstractAuthenticationToken>
&Converter<Jwt, Mono<AbstractAuthenticationToken>>
) that can take an underlyingConverter
and apply aUserDetailsChecker
to it before returning theAbstractAuthenticationToken
/Mono<AbstractAuthenticationToken>
.That way in the configuration DSL a consumer could choose to have this ability or not via something like
I'm open to discussing the correct approach on how best to integrate it and am happy to supply a PR for the correct approach.
If you'd rather me submit a PR with what I have and discuss the approach on the PR thats fine too.
The text was updated successfully, but these errors were encountered: