Skip to content
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

Support the dynamic KeycloakPolicyEnforcerAuthorizer tenants #17664

Closed
sberyozkin opened this issue Jun 3, 2021 · 1 comment · Fixed by #39643
Closed

Support the dynamic KeycloakPolicyEnforcerAuthorizer tenants #17664

sberyozkin opened this issue Jun 3, 2021 · 1 comment · Fixed by #39643

Comments

@sberyozkin
Copy link
Member

sberyozkin commented Jun 3, 2021

Description

KeycloakPolicyEnforcerAuthorizer tenants configured in application.properties are supported in 2.0.0.x but it is not possible to create them programmatically yet as can be done for OIDC tenants with TenantConfigResolver.

Implementation ideas

Add TenantPolicyConfigResolver which would accept RoutingContext and the current OIDC tenantId and return KeycloakPolicyEnforcerTenantConfig and have it injected in PolicyEnforcerResolver.

PolicyEnforcerResolver would check TenantPolicyConfigResolver first - if it returns KeycloakPolicyEnforcerTenantConfig then Function will be used to convert it to PolicyEnforcer - this function will be passed from KeycloakRecorder to PolicyEnforcerResolver in its constructor similarly to how it is done in OidcRecorder.

It should be enforced for web-app tenants only (as is already done for the configured web-app tenants) that the current OidcTenantConfig also has quarkus.oidc.roles.source=accesstoken. The current dynamic OidcTenantConfig is available as RoutingContext dynamic.tenant.config attribute.

A simple test would have to be added to integration-tests/keycloak-authorization - it already has one test for the configured non-default tenant - so another similar test should be added for the dynamically created one

CC @pedroigor

@ethan-gallant
Copy link
Contributor

Hello!

I currently have a working implementation of this in #17750. Please let me know if anything should be changed or modified. The code is heavily inspired by the OIDC library which implements a very similar system.

Thank you for the guidance on how to implement this! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants