Skip to main content

Protecting REST APIs

Every REST API of a jEAP microservice must be authenticated and authorized, including APIs that are only called internally. The jEAP Security Starter turns a microservice into an OAuth2 resource server: it validates the JWT bearer access token of every request, converts it into a jEAP authentication and lets the application authorize the request against the roles carried in the token. This section describes how a REST API is protected this way, which steps jEAP Security runs through for a request, and the three authorization models the roles of a token can be checked against: simple roles, semantic roles and authorities derived from roles. It also describes how to provide an additional Spring Security configuration for the APIs of a microservice that should not be protected as an OAuth2 resource.

Start with Authentication and authorization for REST APIs. It covers the integration and configuration of the jEAP Security Starter and explains where authorization takes place. Then pick the page of the authorization model your application uses; consult the role concept documentation for choosing between the models.

If your microservice also provides APIs that should not be protected as an OAuth2 resource, but should e.g. be public or protected with basic auth, read Spring Security configuration. It gives guidance on providing the additional Spring Security configuration needed and points to the JME example projects with working example configurations.

Contents​

PageDescription
Authentication and authorization for REST APIsProtecting REST APIs with the jEAP Security Starter: integration, configuration and where authorization takes place
Authorization with simple rolesDeclarative and programmatic authorization checks against simple roles
Authorization with semantic rolesDeclarative and programmatic authorization checks against semantic roles, role and business partner queries
Authorization with authoritiesDeriving fine-grained authorities from roles and authorizing against them
Spring Security configurationProviding an additional Spring Security configuration for APIs that are not protected as an OAuth2 resource, e.g. public or basic auth protected APIs
JWT access token authorization flow in jEAP SecurityThe steps and components jEAP Security runs through when authorizing a request with a JWT bearer token