Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add HTTP methods in Keycloak resources for Authorization (Without adapters)

Tags:

keycloak

When using Keycloak for authorization it allows creating protected resources. But it only allows defining the URI. How can I also add the HTTP method for the resource?

Although it seems the policy enforcers allows us to define such details, how is Keycloak able to map the HTTP method with the resource?

Thanks in Advance.

enter image description here

like image 682
Nirojan Selvanathan Avatar asked Sep 11 '25 23:09

Nirojan Selvanathan


1 Answers

If you want scopes to be mapped to HTTP methods then you need to set http-method-as-scope to true.

You can check policy enforcer documentation here

With spring-boot adapter you can set keycloak.policy-enforcer-config.http-method-as-scope=true and your resources would be associated with scopes such as GET, PUT, POST, DELETE, etc.

like image 139
ravthiru Avatar answered Sep 15 '25 19:09

ravthiru