OIDC adapter has to provide HttpPermissionChecker
See original GitHub issueDescription
Example of the original quarkus-keycloak
configuration:
quarkus.keycloak.policy-enforcer.claim-information-point.claims.request-uri={request.relativePath}
quarkus.keycloak.policy-enforcer.claim-information-point.claims.request-method={request.method}
quarkus.keycloak.policy-enforcer.lazy-load-paths=true
quarkus.keycloak.policy-enforcer.paths.1.path=/asset-service/resources/tenants
quarkus.keycloak.policy-enforcer.paths.1.methods.1.method=POST
quarkus.keycloak.policy-enforcer.paths.1.methods.1.scopes=tenants:create
quarkus.keycloak.policy-enforcer.paths.10.path=/asset-service/resources/tenants/{tenantId}
quarkus.keycloak.policy-enforcer.paths.10.methods.1.method=PUT
quarkus.keycloak.policy-enforcer.paths.10.methods.1.scopes=tenant:edit
quarkus.keycloak.policy-enforcer.paths.10.methods.2.method=DELETE
quarkus.keycloak.policy-enforcer.paths.10.methods.2.scopes=tenant:delete
quarkus.keycloak.policy-enforcer.paths.11.path=/asset-service/resources/tenants/{tenantId}/disable
quarkus.keycloak.policy-enforcer.paths.11.methods.1.method=PUT
quarkus.keycloak.policy-enforcer.paths.11.methods.1.scopes=tenant:disable
quarkus.keycloak.policy-enforcer.paths.12.path=/asset-service/resources/tenants/{tenantId}/enable
quarkus.keycloak.policy-enforcer.paths.12.methods.1.method=PUT
quarkus.keycloak.policy-enforcer.paths.12.methods.1.scopes=tenant:enable
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.
var attributes = context.getAttributes();
var httpUri = attributes.getValue('request-uri');
function isInTenantGroup(tenantId) {
var result = false;
var wanted = "/" + tenantId + "/users";
var identity = context.getIdentity();
var userGroups = identity.getAttributes().getValue('user-groups');
if (userGroups !== null) {
for(var i=0; i < userGroups.size(); i++) {
if(wanted === userGroups.asString(i)) {
result = true;
break;
}
}
}
return result;
}
if (httpUri) {
var uriParts = httpUri.asString(0).split('/');
if (isInTenantGroup(uriParts[4])) {
$evaluation.grant();
}
}
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 needed
Issue Analytics
- State:
- Created 4 years ago
- Comments:51 (41 by maintainers)
Top Results From Across the Web
Authorization Services Guide - Keycloak
Provides a set of UIs based on the Keycloak Administration Console to manage ... The adapter configuration is displayed in JSON format.
Read more >PermissionChecker | Android Developers
This class provides permission check APIs that verify both the permission and the associated app op for this permission if such is defined....
Read more >Using OpenID Connect (OIDC) and Keycloak to Centralize ...
This guide demonstrates how your Quarkus application can authorize a bearer token access to protected resources using Keycloak Authorization Services. The ...
Read more >Chapter 2. Using OpenID Connect to secure applications and ...
Each application has a client-id that is used to identify the application. ... Default is session, which means that adapter stores account info...
Read more >Make your own Permission Checker app in Android Studio
Or which apps have been given permission to access your device location? ... app name as well as the app icon to bind...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pedroigor Hi Pedro, it is pulled in from somewhere in the dev mode I guess, @gsmet - do you know why ? IMHO, it should not block the PR, we can have a follow up issue (fix for the dev mode, etc). It all looks good to me, the configuration example. Please rename the module as you’ve suggested above (hope Stian @stianst would be OK with it).
@dfranssen FYI, as Pedro said, you will be able to get all the information about the token from
JsonWebToken
which can be either directly injected or accessed via QuarkusSecurityIdentity
- we will be updating the docs. And indeed as Pedro mentioned, we’ll definitely proceed with something interesting with new annotations related to the claim-based authorization concept. It is just that the adapter stabilization is more of the immediate priority 😃Thanks
@dfranssen it should be able to replace config properties by setting system properties. I guess the behavior is the same when using quarkus.profile.