-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
OIDC adapter has to provide HttpPermissionChecker #4495
Comments
See #4487 about |
@pedroigor FYI. Pedro, is all we need to do here is parse the KC specific scope claim to get it going for @dfranssen ? What are those numbers |
@stuartwdouglas, if we have @RolesAllowed, how would the users configure path/verb, as the configuration in your PR activates the default checker ? |
@sberyozkin, it is not really related with the In a nutshell, what we need to do is somehow parse this This is the KC specific feature we talked about (fine-grained/contextual permissions). Although it also has support for UMA specs. Do we want a separate extension for it ? Or have it within the |
@sberyozkin about those numbers. They are the index for each path you are configuring (backed by a list of paths). |
@pedroigor OK, thanks. I believe it should work for any IDP, not only Keycloak, at the adapter level we don't really mind I guess where the token is coming from. |
@pedroigor If it is really Keycloak specific then may be we can introduce I reckon we should try to keep generalizing i.e we can have a simple checker which would work with all IDPs which would say only checks
This obviously does not match the requirement of @dfranssen. To be honest, I don't see a way for a generic equivalent of the original Thanks |
"authorization": {
"permissions": [
{
"scopes": [
"profile:view"
],
"rsid": "8e052f06-a543-4b9c-959d-7b59ca99d1f1",
"rsname": "User Profile Resource"
}
]
} The mapping of resources (rsid/rsname) to paths is what makes possible to enforce access accordingly to the resource/path being requested. The PEP also allows you to enforce access by querying Keycloak in case the token is a regular access token. So that clients don't need beforhand to obtain a token with permissions.
If you make this a priority, I would say that we should start without UMA. |
@pedroigor Thanks (though still not sure how the above But we need to decide what to do for 0.25.0 per my earlier comment. I'm going offline now, but lets try to finalize tomorrow, may be Stian will have some comments too Thanks |
@sberyozkin, sure. Let's sync this. In a nutshell, we just need to re-use the policy enforcer from the Keycloak Adapter. |
As the policy enforcer is very Keycloak specific I think the ideal solution would be to have a quarkus-keycloak-authz extension that depends on quarkus-oidc to do the rest |
@pedroigor, @stianst thanks, so we are going with the keycloak specific extension of the oidc adapter, |
@pedroigor would need to look into how feasible it is to create a pure policy enforcement extension, but for OIDC in general we shouldn't need KC specific stuff. Also, I think if we'd have quarkus-keycloak that would confuse folks thinking that they didn't need quarkus-oidc, and that is somehow did more than just authz |
@stianst +1, we are all in total agreement that |
We are aligned. We should go for a new extension. The name @stianst a generic PEP should be possible and it is pretty much possible based on the permission checker Stuart is doing. So that you can have custom checks or interact with a PDP by providing your custom checker implementation. But yeah, we still need to provide something that works OOTB and that is KC specific (but based on specs). |
@pedroigor |
Hi Pedro, David, copying some comments here: David: "This is just a thought, but I was thinking there might be a point where it's better for the user to specify things using a builder of some sort (like the router API) rather than having super complex configurations" Pedro: "Good point. It would certainly provide a better experience. The configuration I mentioned fits better in a JSON format. But in a properties file, it is not so nice. So, what you are proposing is to basically expect a configuration object instance that is produced by the application (using a builder/fluent API provided by the extension) and used by my custom permission checker during initialization? Do we have something similar in any other extension ?" Sergey: "One possible issue here is that by improving the option for this KC specific configuration we can make it more difficult to eventually migrate users to a generic adapter, especially if they will have something in their code :-). JSON format or a custom builder would be nice, but in this case we are dealing with the users of the original Keycloak adapter who can't just move to the new one yet and already have the configuration prepared. For UMA we can do something really nice with what David and Pedro suggests, perhaps we can prioritize on UMA soon enough for the new users be starting with it. Especially given that quarkus-oidc is expected to work not only with Keycloak" Sergey: "Pedro, you can probably have something like this, have @recorder
}
} |
@stuartwdouglas @sberyozkin In order to plug the policy enforcer, I'm exposing a custom That would mean replace the default authorizer, which I think is fine. Any thoughts? |
I'm also not sure whether or not we should rewrite the implementation we have in Keycloak in order to better fit the reactive model in Quarkus. One of the things being that we use Apache HttpClient and would be nice if we could use vertx client instead. However, it is quite a lot of work (I tried to start something) and error-prone. In addition to having two distinct codebases for the same purposes. I would like then to reuse as much as possible what we have in Keycloak and adjusting where posible the implementation to properly use the async model provided by Vert.x. |
OK, so it's not 0.26 material, will move it to next release, thanks! |
@pedroigor I'm not sure about |
@pedroigor Hi Pedro, re the multi-tenancy, this is also an orthogonal issue (#4448). We have already said |
I've considered it just because this is a Keycloak-specific extension and users are already used to it. No problem if you want to re-use FYI, this enforcer can run in two modes. One mode is all about parsing the granted permission carried by the token. The second mode is exchanging an incoming bearer token with another one with the necessary permissions to access a protected resource. In the second mode, we need to somehow update the security identity with the token that was exchanged. But yeah, the authorizer kicks in after the identity is already established. The permissions granted by Keycloak are stored in a |
@sberyozkin @stuartwdouglas I'm about to send a PR (including quickstart) considering all the suggestions and issues herein suggested. I'm still not sure about how to proceed with the Like I mentioned before, removing the library from the list of excluded deps in Quarkus would make things work. But I'm not sure if that is something I'm allowed to do. What do you suggest ? |
@pedroigor Hi Pedro, I see, I propose that we discuss this concept, to show which permission was granted as part of some follow up PR, because once the oidc adapter will support UMA, etc, the same kind of utility method check should work as well. We'll add some nice typed methods to The other thing, that 2nd part, the token exchange, that should be eventually done at the |
@sberyozkin The part that makes available the granted permissions through the SI is already implemented. I've even added a The exchange part is also working and is a core capability of the extension. The missing bit now is just this |
@pedro, sure, that the KC policy enforcer needs it; but in time we'll have the oidc adapter having a similar requirement, exchange a token (to delegate or impersonate) using the token exchange protocol - the concept has to work with the 3rd party IDPs. At that point we'll most likely want to reuse the code which will be located in the KC extension but without the KC specific API :-) I propose to open a PR for us to discuss for few days, and then once it makes it - add a follow up PR. |
some (@starksm64 @gsmet) have argued that rest calls should be done using the default quarkus jax-rs client. I created #4162 as a result of this feedback. |
[fixes #4495] - Quarkus Keycloak Authorization Extension
@pedroigor @sberyozkin I tested this weekend with v0.27.0 and all remarks I have made have been resolved. Thanks a lot! |
@dfranssen tk u for checking it ! |
Description
Example of the original
quarkus-keycloak
configuration:@dfranssen:
E.g. Keycloak javascript permission using the request-uri. Our path is like /asset-service/resources/tenants/abc where abc is the tenant name (uriPart[4] in the code below) for which we check the actual authenticated user is part of. In Keycloak we have a group per tenant (e.g. /abc/users) where the user is put into.
Implementation ideas
The adapter has to introspect a
scope
claim (or Keycloak specific claim - in this case we should have a claim name configured to avoid tying the adapter to KC - though we can do it later). PolicyEnforcer configuration group can be introduced if neededThe text was updated successfully, but these errors were encountered: