Hello everyone,
I just started using Keycloak in combination with Spring Boot. Is there a way that I can use annotations in REST controller classes instead of the application.yml configuration for “security-constraints”? What do I have to configure in my Spring Boot application for this or is this not a good idea?
application.yml
keycloak:
[...]
security-constraints:
- authRoles:
- admin
securityCollections:
- patterns:
- /
Versus something like:
GreetingExampleController.java
@RestController
public class GreetingExampleController extends BaseController {
@NecessaryRoles({
"admin"
})
@GetMapping("hello-world")
public String greeting() {
return "Hello World!";
}
}
Thank you in advance.
Gr.
Niklas