I have created a Spring Boot app with spring-boot-starter-security and keycloak-spring-security-adapter and authenticating users with Keycloak works as intended.
I now want to use Keycloak's Authorization Services for fine-grained access control to my API.
In Keycloak, I've enabled Authorization for my client. I've created a Role and I've assigned the Role to my test User. I've created a Resource and a Resource-based Permission and I've added a Role-based Policy. Using the Evaluate feature, I've confirmed, that my user has permission to access my resource.
Let's say I have the following controller with one endpoint.
@RestController
class GreetingController {
@GetMapping("/hello")
fun getPatientInfo(principal: Principal): String {
return "Hello, ${principal.name}!"
}
}
Now my question is: How do I associate an endpoint in my Spring Boot application with the given Resource so that the permission is evaluated when a request is made?
