Identity & access

Building Centralized SSO with Spring Boot: OAuth 2.0, SAML, JWT & RBAC

Connecting identity, roles, and application boundaries, informed by my Spring Boot work at Prokoders.

Conceptual flow
  1. 01Application / sign-in
  2. 02Identity provider
  3. 03Validated identity
  4. 04Service authorization

The work behind the topic

At Prokoders, I led development of a centralized single sign-on platform using Java 21, Spring Boot, Spring Security, OAuth 2.0, SAML, and JWT-based authentication. The scope included role-based access, OTP, device trust, and audit-focused controls. That combination makes identity a platform concern: applications need a shared understanding of who the user is while retaining responsibility for the actions that user can perform.

My work on Britrip’s shared SSO platform connects these identity concerns to a Spring Boot implementation used across the platform.

Keep the responsibilities explicit

A useful design review separates sign-in, session handling, and resource authorization. A successful sign-in should not grant access to every business record. Each service still needs to check its own permissions and resource boundaries. Document which component issues credentials, which validates them, and how changes in a user’s access become effective. Otherwise, different applications can interpret the same identity differently.

Review the complete identity lifecycle

Testing should follow more than the first login. Include expired credentials, changed roles, disabled accounts, failed OTP attempts, and logout across connected applications. Define the expected result for each scenario before implementing the checks. Audit records should help reconstruct an access decision without recording secrets. These are review questions for an identity system, not claims that a particular protocol or token format solves every security requirement.

An authentication flow with explicit trust boundaries

For an illustrative browser flow, the application redirects the user to an identity provider, the provider authenticates the user, and the application processes the protocol response before establishing its session. The diagram is a conceptual boundary map, not the exact production topology. Keep the browser, application, identity provider, and downstream APIs distinct when reviewing where credentials are accepted and where authorization happens.

JWT validation and resource ownership

A token’s presence is not proof that a request is authorized. A Spring Security resource server can validate JWT signatures and issuer and time claims; audience validation should match the intended API. The application must still enforce resource ownership and tenant scope. A valid token for a user in one organization does not by itself permit reading another organization’s customer record. Document these checks as separate layers.

Token lifetime, refresh, and access changes

Treat token lifetime as a design decision with operational consequences. Short access-token lifetimes reduce the period in which an old authorization snapshot remains usable, but they make renewal behavior more important. A refresh token belongs at the authorization boundary, not as a credential sent to every business API. Define what happens when a role is removed or an account is disabled, including how soon existing sessions stop working. Do not assume that changing a database row instantly invalidates every previously issued token.

Logout, OTP, and device trust

Local logout, identity-provider logout, and logout across applications are different events. Write down which sessions must end and how each application learns that change. For OTP, review expiry, attempt limits, and whether a code can be reused. For device trust, review how trust is granted and removed, and which actions still require stronger verification. These controls should have visible state transitions and audit events so a support investigation can explain an access decision.

A boundary-focused test matrix

Use a matrix of identity state, application, role, resource owner, and expected decision. Include an expired token, an unexpected issuer or audience, a removed role, a disabled account, and a request for another tenant’s record. Repeat relevant cases through the API rather than relying only on hidden UI controls. The useful result is a reproducible explanation of why access was allowed or denied, including the stored state and the applicable policy.

Back to all articles →