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

Update DevServices for Keycloak to create authorization policies #21276

Conversation

sberyozkin
Copy link
Member

Fixes #21040

This PR attempts to support running keycloak-authorization with DevServices for Keycloak without having to import a custom realm.
DevServices for Keycloak creates a default realm, client, users, roles when no custom realm is added. With this PR, authorization permissions will also be added, so given only a configuration like this one:

quarkus.keycloak.policy-enforcer.enable=true
quarkus.keycloak.devservices.authorization.paths.user=/api/users/me
quarkus.keycloak.devservices.authorization.paths.admin=/api/admin

quarkus-quickstarts/security-keycloak-authoroization-quickstart just works in the dev mode - a default user alice who has both admin and user roles can access both api/admin and api/users/me, while bob - with only a user role - can only access api/users/me.

@pedroigor, I've copied some code from integration-tests/keycloak-authorization/.../KeycloakTestResource to set up the basic permissions - for every configured role and path pair in quarkus.keycloak.devservices.authorization.paths this code is run, and more specifically this one (I'll clean it up a bit more - will try to generate unique names).

Now, starting quarkus-quickstarts/security-keycloak-authoroization-quickstart with the above configuration and mvn quarkus:dev produces:

Could not obtain configuration from server [http://localhost:32783/auth/realms/quarkus/.well-known/uma2-configuration].
	at org.keycloak.authorization.client.AuthzClient.<init>(AuthzClient.java:266)
	at org.keycloak.authorization.client.AuthzClient.create(AuthzClient.java:105)
	at org.keycloak.adapters.authorization.PolicyEnforcer.<init>(PolicyEnforcer.java:65)
	at io.quarkus.keycloak.pep.runtime.KeycloakPolicyEnforcerRecorder.createPolicyEnforcer(KeycloakPolicyEnforcerRecorder.java:101)

Pedro, can you help a bit and recommend what else may have to be added to the client registration code ? I guess I need to copy something else from KeycloakTestResource but I'm not sure what :-)

thanks

@pedroigor
Copy link
Contributor

@sberyozkin Can we hold this one a bit? The reason is that make this happen is a bit too complex due to how you configure resources/scopes/permissions/policies.

Secondly, we are planning some changes next year in authz and this area is one we should focus more to improve. For instance, have a more easy/clear spec to configure things.

@gsmet
Copy link
Member

gsmet commented Feb 2, 2023

@sberyozkin I'm leaning towards closing this one? WDYT?

@gsmet gsmet added triage/needs-feedback We are waiting for feedback. triage/needs-rebase This PR needs to be rebased first because it has merge conflicts labels Feb 2, 2023
@sberyozkin
Copy link
Member Author

I'm going to close this PR for now

@sberyozkin sberyozkin closed this Jan 2, 2024
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/keycloak area/oidc triage/invalid This doesn't seem right triage/needs-feedback We are waiting for feedback. triage/needs-rebase This PR needs to be rebased first because it has merge conflicts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend Dev Services for Keycloak in Keycloak Authorization
3 participants