Comprehensive guides and references for the OpenFrame platform
The Security Oauth Bff And Shared Jwt module provides the foundational security building blocks for the OpenFrame platform. It combines:
This module acts as the glue between:
It standardizes how JWTs are issued, validated, refreshed, and transported across services.
flowchart LR
Browser["Browser Client"] -->|"/oauth/login"| BFF["OAuth BFF Controller"]
BFF -->|"Authorize Redirect"| AuthServer["Authorization Server"]
AuthServer -->|"code + state"| BFF
BFF -->|"Token Exchange"| AuthServer
AuthServer -->|"access + refresh tokens"| BFF
BFF -->|"HTTP Only Cookies"| Browser
Browser -->|"API Request + Cookie"| Gateway["API Gateway"]
Gateway -->|"Validate JWT"| JwtDecoder["JwtDecoder"]
JwtEncoder["JwtEncoder"] -->|"Signs Tokens"| JwtDecoder
Class: JwtSecurityConfig
Defines Spring beans for:
JwtEncoder (RSA private key based signing)JwtDecoder (RSA public key verification)flowchart TD
Config["JwtConfig"] -->|"loadPublicKey()"| Decoder["JwtDecoder"]
Config -->|"loadPublicKey()"| Encoder
Config -->|"loadPrivateKey()"| Encoder["JwtEncoder"]
Encoder -->|"JWKSet"| Nimbus["NimbusJwtEncoder"]
Decoder -->|"Public Key"| NimbusDecoder["NimbusJwtDecoder"]
This ensures:
Class: JwtConfig
Bound to configuration prefix:
jwt.publicKey
jwt.privateKey
jwt.issuer
jwt.audience
Responsibilities:
This configuration ensures consistent JWT validation across services.
Class: SecurityConstants
Defines shared constant values used across gateway and OAuth flows:
ACCESS_TOKENREFRESH_TOKENACCESS_TOKEN_HEADERREFRESH_TOKEN_HEADERAUTHORIZATION_QUERY_PARAMThis prevents duplication and mismatch across modules.
Utility class for OAuth2 PKCE support.
generateState() → CSRF protection (128-bit random)generateCodeVerifier() → PKCE verifier (256-bit random)generateCodeChallenge() → SHA256 based challengeflowchart TD
Verifier["Code Verifier"] -->|"SHA256"| Hash["Hash"]
Hash -->|"Base64Url"| Challenge["Code Challenge"]
Challenge -->|"Sent to Auth Server"| AuthServer["Authorization Server"]
Verifier -->|"Sent during token exchange"| AuthServer
This protects public browser clients from authorization code interception attacks.
Class: OAuthBffController
Base path:
/oauth
Enabled only when:
openframe.gateway.oauth.enable=true
| Endpoint | Method | Purpose |
|---|---|---|
/login |
GET | Start OAuth authorization flow |
/continue |
GET | Continue OAuth flow without clearing cookies |
/callback |
GET | Handle authorization code callback |
/refresh |
POST | Refresh access token |
/logout |
GET | Revoke refresh token and clear cookies |
/dev-exchange |
GET | Development token exchange |
sequenceDiagram
participant Browser
participant BFF as "OAuth BFF Controller"
participant Auth as "Authorization Server"
Browser->>BFF: GET /oauth/login
BFF->>Auth: Redirect to authorize endpoint
Auth->>Browser: Redirect with code + state
Browser->>BFF: GET /oauth/callback
BFF->>Auth: Exchange code for tokens
Auth->>BFF: Return access + refresh
BFF->>Browser: Set HTTP Only Cookies
This design:
flowchart TD
Browser["Browser"] -->|"POST /oauth/refresh"| BFF["OAuth BFF Controller"]
BFF -->|"Lookup tenant"| Service["OAuthBffService"]
Service -->|"Call Authorization Server"| AuthServer
AuthServer -->|"New tokens"| BFF
BFF -->|"Update Cookies"| Browser
If refresh token is missing → returns 401.
This ensures server-side token invalidation.
Class: InMemoryOAuthDevTicketStore
Used only in development environments.
flowchart TD
Tokens["TokenResponse"] -->|"createTicket()"| Store["InMemory Store"]
Client["Client"] -->|"/dev-exchange?ticket=id"| BFF
BFF -->|"consumeTicket()"| Store
Store -->|"Return Tokens"| BFF
BFF -->|"Add Access-Token Header"| Client
This is disabled if:
openframe.gateway.oauth.dev-ticket-enabled=false
Class: DefaultRedirectTargetResolver
Resolves final redirect destination using:
redirectTo parameter/Ensures safe and deterministic redirect handling.
flowchart LR
Frontend["Frontend"] -->|"OAuth Flow"| BFF
BFF --> AuthServer["Authorization Server"]
Frontend -->|"API Calls"| Gateway
Gateway -->|"JWT Validation"| JwtSecurity
JwtSecurity -->|"Public Key"| AuthServer
jwt.publicKey
jwt.privateKey
jwt.issuer
jwt.audience
openframe.gateway.oauth.enable
openframe.gateway.oauth.state-cookie-ttl-seconds
openframe.gateway.oauth.dev-ticket-enabled
The Security Oauth Bff And Shared Jwt module provides:
It is the foundation of authentication and token trust across the OpenFrame platform.