how can i make keycloak to allow access to resouce with two different permission, one allows and other denies to access a resource?

Viewed 60

i have permisionA for resourceA and with policyA(role based policy for roleA) and permissionB for same resource with policyB(role based policy for roleB).

PemissionA allows me to access resourceA and permissionB denies to access resourceA and when i evaluate on keycloak admin console for a user with roleA then keycloak does not allow to access resource A.

I want keycloak to allow a user to access resource when atleast one of the permission allows to access?

1 Answers

if you have multiple policies in Keycloak you Aggregate the policies and create a single policy.

https://www.keycloak.org/docs/latest/authorization_services/index.html#_policy_aggregated

Or for simple example if the user has permission like Admin OR Super Admin he/she can access the resource for this kind of scenario we can use this.

here is small JSON implementation that might be helpful to implement :

{
        "name" : "PemissionA or PemissionB or PemissionC",
        "type" : "aggregate",
        "logic" : "POSITIVE",
        "decisionStrategy" : "AFFIRMATIVE",
        "config" : {
          "applyPolicies" : "[\"PemissionA\",\"PemissionB\",\"PemissionC\"]"
        }
Related