This is an example Repository to demonstrate how to implement OAuth 2.0 in a Spring Boot application. It is offering simple controllers to test the concept of authentication with specific roles.
Current Endpoints:
/finegrained-auth/[admin,user, no-role & public]
- Controller which demonstrates the finegrained authorization by setting thepreAuthorization
Annotation for each Endpoint/admin/admin
- Controller which sets thepreAuthorization
on Class level, all endpoints will be secured by theadmin
role/user/user
- Controller which sets thepreAuthorization
on Class level, all endpoints will be secured by theuser
role
- Java 21
- Keycloak running an accessible
- Add a realm in Keycloak
- Add a client in Keycloak
- Add a Realm Roles in Keycloak (
admin
,user
) - Add a user in Keycloak and assign the roles
admin
anduser
to the user - Adjust the configuration in
src/main/resources/application.properties
to match your Keycloak configuration