r/SpringBoot • • Dec 29 '25

Question How should RBAC be implemented in Spring Boot Microservices?

13 Upvotes

I am working on a Spring Boot microservices architecture. I am currently using email and password authentication with JWT.

I want to understand the recommended way to enforce role based access control in a microservices setup using Spring Security. I am not sure whether role based authorization should be handled at the API Gateway level or inside each individual service.

If it is done at the gateway, should the gateway validate the JWT, extract roles, and then forward the request with user details in headers? If the role is wrong then block the request.

If it is done at the service level, should each service independently validate the JWT and apply role based rules using Spring Security annotations(PreAuthorize) or filters?

I am looking for best practices. How are roles typically propagated across services, and what is the preferred Spring Security configuration for enforcing role based authorization in a microservices environment? Code examples or sample configurations would be greatly appreciated.