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

Keycloak roles and services under roles #1476

Closed
viachaslau-latushkin opened this issue Jun 17, 2024 · 1 comment
Closed

Keycloak roles and services under roles #1476

viachaslau-latushkin opened this issue Jun 17, 2024 · 1 comment

Comments

@viachaslau-latushkin
Copy link

Hi Dear 3scale!

I am using 3scale apicast as api-getway - combining a lot of microservices and keycloak's token validation. Also configured validation for access to endpoints of each microservice according special roles from keycloak's token.

Right now each endpoint for each role covered by next lines

- methods:
  - GET
    resource_type: plain
    resource: ENDPOINT
  client_roles:
    - name: ROLE_FROM_KEYCLOAK_TOKEN
        client_type: plain
        client: KEYCLOAK_ROLE
        name_type: plain

3scale policies.yaml extremely big in this case.
Is there any way to combine each endpoint from each microservice under list of roles without duplicating line above?
Thank you in advance for any help.

@tkan145
Copy link
Contributor

tkan145 commented Jun 18, 2024

Hi, unfortunately the policy evaluate per ENDPOINT resource so it's necessary to include each config block per ENDPOINT.

Perhaps you can group similar endpoint together under resource ? i.e

example.com/foo/bar
example.con/foo/baz
example.com/foo/

to

example.com/foo/

or apply settings dynamically by changing resource_type to liquid and getting the endpoint from the claim. For example:

{
"client_roles": [
 {
    "name": "{{ jwt.aud }}",
    "name_type": "liquid",
    "client": "{{ jwt.aud }}",
    "client_type": "liquid"
   }
 ],
 "resource": "/{{ jwt.aud }}",
 "resource_type": "liquid"
}

Also I believe you already known this but if you are using an operator to deploy the gateway, you can also read from the configuration from the secret
https://github.com/3scale/3scale-operator/blob/master/doc/product-reference.md#PolicyConfigSpec

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

No branches or pull requests

2 participants