Overview
OAuth 2.0 was designed as a delegated authorization framework for consumer web applications. A user grants a third-party app access to their Google calendar — the threat model assumes the access token is short-lived, the damage from theft is bounded, and replay attacks are mitigated by HTTPS. That threat model is wrong for payment initiation. A stolen payment authorization token replayed once drains an account. A tampered redirect parameter redirects the authorization code to an attacker. An insufficient proof-of-possession model means a token stolen from one client can be used by any bearer.
FAPI 2.0 (Financial-grade API Security Profile 2.0) is an OpenID Foundation specification that profiles OAuth 2.0 — building on the OAuth 2.0 Security Best Current Practice (RFC 9700) and closely aligned with the OAuth 2.1 draft — for high-value API use cases. Its Security Profile mandates the controls that fill the gaps plain OAuth 2.0 leaves open: Pushed Authorization Requests for request integrity, PKCE with S256, strong client authentication, and DPoP or mTLS to bind tokens to the client that requested them. Its separate Message Signing profile adds signed requests and JARM-signed authorization responses. Rich Authorization Requests are permitted for fine-grained consent; whether they are required is a scheme decision. Open Banking schemes in a growing number of jurisdictions reference FAPI profiles as the security baseline for Third Party Provider (TPP) access — account information (AIS), payment initiation (PIS), and Confirmation of Funds (CoF).
FAPI 2.0 does not re-invent OAuth. It is a profile that selects specific OAuth extensions, makes optional features mandatory, and bans unsafe options (implicit grant, resource owner password credentials, plain PKCE). You still need a solid OAuth foundation — scopes, token lifecycle, refresh token rotation, introspection — before layering the FAPI-specific controls on top. A team that does not understand OAuth cannot implement FAPI 2.0 correctly.
FAPI 2.0 Requirements
FAPI 2.0 is defined in two parts: the Security Profile (FAPI2SP) and the Message Signing profile (FAPI2MS). Where a scheme requires signed requests and responses for non-repudiation, both apply. The requirements that distinguish a FAPI 2.0 deployment from a standard OAuth 2.0 one:
| Requirement | RFC / Spec | What it prevents | Typical scheme status |
|---|---|---|---|
| PKCE — S256 only | RFC 7636 | Authorization code interception | Mandatory |
| PAR (Pushed Authorization Requests) | RFC 9126 | Request parameter tampering in redirect | Mandatory |
| DPoP sender-constrained tokens | RFC 9449 | Bearer token theft & replay | Mandatory (or mTLS) |
| mTLS-bound access tokens | RFC 8705 | Bearer token theft & replay | Mandatory (or DPoP) |
| RAR (Rich Authorization Requests) | RFC 9396 | Overly broad consent grants | Optional in FAPI 2.0; required by some schemes |
| JARM (JWT Secured Authorization Response) | OIDF spec | Authorization response tampering | Required by the Message Signing profile |
| No implicit grant | RFC 9700; OAuth 2.1 draft | Token exposure in redirect URI | Banned |
| No ROPC grant | RFC 9700; OAuth 2.1 draft | Credential phishing via TPP | Banned |
PKCE S256 (SHA-256 code challenge) is mandatory — plain PKCE is banned because the plain method provides no security benefit. The state parameter is still recommended for CSRF protection at the redirect level, but it is no longer the primary authorization request integrity mechanism — that role moves to PAR.
Pushed Authorization Requests (PAR)
The fundamental problem with the OAuth 2.0 authorization endpoint is that the authorization request parameters are sent as query parameters in a browser redirect URL. The URL is visible in the browser history, referer headers, and server access logs. An attacker who can modify the redirect URL — through an open redirect vulnerability, a misconfigured redirect_uri, or a browser extension — can tamper with the scope, redirect_uri, or state parameters before the authorization server sees them.
PAR (RFC 9126) solves this by moving the authorization request out of the browser. The client POSTs all authorization parameters directly to the server’s /par endpoint, authenticated with its client credentials. The server validates the parameters and returns a request_uri with a short, server-chosen lifetime — FAPI 2.0 requires it to be under 600 seconds, and 60–90 seconds is common. The client then redirects the user to the authorization endpoint using only client_id and the request_uri — no sensitive parameters in the URL.
request_uri is single-use and short-livedThe request_uri returned by the PAR endpoint is designed to be used exactly once. If a user abandons the flow and the TPP retries, it must POST to /par again and obtain a fresh request_uri. A reused request_uri indicates either a replay attack or a buggy client implementation — the authorization server must reject it and the event must be logged as a security alert with the TPP identity, IP address, and timestamp. Under most schemes’ incident-reporting rules, this log is evidence for TPP security incident reporting.
# Step 1: POST authorization_details to PAR endpoint (client auth: private_key_jwt)
POST /par HTTP/1.1
Host: auth.aspsp.example
Content-Type: application/x-www-form-urlencoded
response_type=code
&client_id=tpp-client-id
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=eyJhbGciOiJQUzI1NiJ9...
&redirect_uri=https%3A%2F%2Ftpp.example.com%2Fcallback
&scope=openid+payments
&code_challenge=s256-challenge-value
&code_challenge_method=S256
&authorization_details=%5B%7B
"type"%3A"payment_initiation"%2C
"actions"%3A%5B"initiate"%5D%2C
"locations"%3A%5B"https%3A%2F%2Fapi.aspsp.example%2Fpis"%5D%2C
"instructedAmount"%3A%7B
"amount"%3A"500.00"%2C
"currency"%3A"GBP"
%7D%2C
"creditorAccount"%3A%7B
"iban"%3A"GB53XMPL00000012345678"
%7D%2C
"debtorAccount"%3A%7B
"iban"%3A"GB92XMPL00000087654321"
%7D
%7D%5D
# Server response
HTTP/1.1 201 Created
Content-Type: application/json
{
"request_uri": "urn:ietf:params:oauth:request_uri:bwc4JQ-ESc0w8wM7M9K7w5sNe3vh",
"expires_in": 90
}
# Step 2: redirect user with ONLY client_id + request_uri
GET /authorize?client_id=tpp-client-id
&request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3Abwc4JQ-ESc0w8wM7M9K7w5sNe3vh
HTTP/1.1
Host: auth.aspsp.example
DPoP — Demonstrating Proof of Possession
DPoP (RFC 9449) is the primary mechanism for sender-constraining access tokens in FAPI 2.0 when client certificate infrastructure is not available for every TPP. The core idea: the client holds an asymmetric key pair (typically EC P-256) for as long as its tokens are bound to it, signs a fresh DPoP proof JWT for every request with that key, and sends the proof alongside the access token. The resource server verifies that the proof is valid for this specific HTTP method, URL, and timestamp — and that the token’s cnf claim matches the public key in the proof.
The DPoP proof JWT header carries typ: "dpop+jwt" and the client’s public key (jwk). The payload carries: htm (HTTP method), htu (HTTP URL without query), iat (issued-at), and jti (a unique identifier the server uses to detect replay); when the access token is presented, ath carries its hash, and a server-supplied nonce can be required to limit pre-generated proofs. The proof is valid only for the specific request it is attached to.
jti replay prevention requires a distributed cacheThe jti in the DPoP proof is a unique identifier that the resource server must record and reject if seen again within the proof’s validity window (typically 60–300 seconds, matching the iat skew tolerance). A single in-memory set does not work behind a load-balanced API gateway — a DPoP proof submitted to instance A can be replayed against instance B, which has no record of it. Use a distributed cache (Redis Cluster or Redis Sentinel) with a TTL matching the proof acceptance window, and store each seen jti as the key. On a cache miss, the proof passes this check; on a hit, reject with 401 invalid_dpop_proof.
{
"typ": "dpop+jwt",
"alg": "ES256",
"jwk": {
"kty": "EC",
"crv": "P-256",
"x": "base64url-encoded-x-coordinate",
"y": "base64url-encoded-y-coordinate"
}
}
{
"jti": "e1e24b80-7d1d-4f6a-9cb0-2a5b3c1d4e5f",
"htm": "GET",
"htu": "https://api.aspsp.example/pis/v1/payment-consents",
"iat": 1725494400,
"ath": "fUHyO2r2Z3DZ53EsNrWBb0xWXoaNy59IiKCAqksmQEo"
}
jti— unique per proof; cache it and reject a repeat (replay).htmandhtu— must match the actual HTTP method and target URI (scheme, host and path, no query or fragment).iat— issued-at; reject proofs outside a small clock-skew window (60 seconds, say).ath— base64url SHA-256 hash of the access token the proof accompanies (RFC 9449, section 4.2).
// Resource server - one token format per filter chain: Spring Security
// rejects configuring jwt() and opaqueToken() together.
http
.oauth2ResourceServer(rs -> rs
.jwt(jwt -> jwt.decoder(NimbusJwtDecoder.withJwkSetUri(jwkSetUri).build()))
)
.addFilterBefore(new DPoPProofValidationFilter(dpopProofValidator, jtiCache),
BearerTokenAuthenticationFilter.class);
// Check first whether your framework version validates DPoP proofs natively.
// DPoPProofValidationFilter validates:
// 1. typ = "dpop+jwt"
// 2. alg in the FAPI 2.0 allow-list (PS256, ES256, EdDSA) - never none, HS* or RS256
// 3. htm matches the request method
// 4. htu matches the request URI (scheme + host + path, no query)
// 5. iat within the clock-skew window
// 6. jti not seen before (shared cache, insert with TTL on first sight)
// 7. ath equals the hash of the presented access token
// 8. the token's cnf.jkt equals the JWK SHA-256 thumbprint of the proof key
mTLS-Bound Tokens
mTLS sender-constraining (RFC 8705) is an alternative to DPoP — stronger in some respects, more operationally demanding in others. Instead of a per-request DPoP proof, the TPP presents its TLS client certificate during the token request. The authorization server computes a thumbprint of the certificate (x5t#S256: SHA-256 of the DER-encoded certificate) and embeds it in the access token’s cnf claim. The resource server extracts the certificate from the TLS session (via the X-Client-Cert header at Kong, injected by the TLS terminator) and verifies the thumbprint matches the token’s cnf.x5t#S256.
The security model is stronger than DPoP in that the binding is established at the TLS layer before the HTTP request reaches the application — a stolen access token is useless without the private key of the client certificate. The operational cost is higher: every TPP must have a client certificate provisioned, renewed, and revoked through a certificate management process, and the certificate infrastructure must integrate with the scheme’s TPP registration and directory process.
| Feature | What it prevents | Client complexity | Server complexity | Typical scheme status |
|---|---|---|---|---|
| PAR | Request parameter tampering in browser redirect | Low — extra POST before redirect | Medium — PAR endpoint, request_uri storage | Mandatory |
| DPoP | Bearer token theft & replay across clients | Medium — key pair per client, fresh proof JWT per request | High — proof validation, distributed jti cache | Mandatory (or mTLS) |
| mTLS-bound | Bearer token theft (stronger than DPoP) | High — client cert provisioning & rotation | Medium — thumbprint validation at TLS terminator | Mandatory (or DPoP) |
| RAR | Overly broad consent grants; scope creep | Medium — structured authorization_details object | High — consent store, query endpoint, token introspection | Scheme-dependent |
| JARM | Authorization response parameter tampering | Low — parse JWT response mode | Medium — JARM signing key, response_mode=jwt | Message Signing profile |
Rich Authorization Requests (RAR)
Standard OAuth 2.0 scopes are coarse-grained: openid payments accounts grants blanket access to all of the TPP’s payment and account operations. Payment initiation under Open Banking requires granular consent that specifies the exact accounts, amounts, and operations covered by each authorization. RAR (RFC 9396) adds the authorization_details parameter to carry a structured JSON array of consent objects with rich, resource-specific semantics.
Each authorization_details object carries: type (the resource type identifier, e.g. account_information or payment_initiation, as named by your scheme), actions (what operations are permitted), locations (the resource server URLs that may receive the token), and resource-specific fields (amount, currency, account identifiers for PIS; account list for AIS). The authorization server embeds the consented authorization_details into the access token, and the resource server validates on every call that the requested operation is within the consented scope.
A typical Open Banking consent model defines four consent states: pending (created, awaiting PSU authorization), authorised (PSU approved), rejected (PSU declined or expired), and revoked (PSU or TPP explicitly cancelled). The resource server must check the consent status on every API call, not just at token issuance — a consent can be revoked mid-session.
Keycloak 24 FAPI 2.0 Configuration
Keycloak ships built-in client profiles for the FAPI 2.0 Security Profile and Message Signing profile (fapi-2-security-profile, fapi-2-message-signing, with DPoP variants in recent releases). You do not hand-write their executors: a client policy applies the built-in profiles to every client that matches its conditions — here, a client role given to TPP clients at registration. The excerpt below is a realm-export fragment; check profile names against your Keycloak version.
{
"realm": "openbanking",
"enabled": true,
"sslRequired": "all",
"accessTokenLifespan": 300,
"offlineSessionMaxLifespanEnabled": true,
"offlineSessionMaxLifespan": 7776000,
"clientPolicies": {
"policies": [
{
"name": "fapi2-tpp-policy",
"enabled": true,
"conditions": [
{ "condition": "client-roles", "configuration": { "roles": ["fapi2-client"] } }
],
"profiles": ["fapi-2-security-profile", "fapi-2-message-signing"]
}
]
},
"attributes": {
"parRequestUriLifespan": "60"
}
}
clientPoliciesreferences Keycloak’s built-in global profiles; custom profiles, if you need them, go in a separateclientProfilessection of the realm export.offlineSessionMaxLifespan(90 days here) bounds the long-lived refresh tokens behind an account-information consent; align it with the scheme’s consent and reauthentication rules.parRequestUriLifespankeeps the PARrequest_urishort-lived (seconds), well inside FAPI 2.0’s 600-second limit.
Kong & IBM API Connect Enforcement
The authorization server (Keycloak) issues FAPI 2.0-compliant tokens. The API gateway (Kong 3.7 or IBM API Connect 10.0.7) enforces token validity, DPoP binding, consent scope, and rate plans on every API call from TPPs. The gateway sits between the internet and the resource server — no API call reaches the resource server without passing through Kong’s plugin chain.
Kong’s OIDC plugin performs token introspection against Keycloak on every request. The response includes the cnf claim (DPoP or mTLS binding), the authorization_details (RAR consent), and the sub (TPP identity). A custom Lua plugin validates that the DPoP proof in the DPoP header matches the cnf.jkt thumbprint in the introspected token. IBM API Connect accomplishes the same via a GatewayScript assembly policy that reads the introspection response and validates the cnf claim.
Rate plans in IBM API Connect are tied to the consent type: an AIS (Account Information Service) plan allows high-frequency reads (for example, up to 4 calls per second per TPP per account), while a PIS (Payment Initiation Service) plan is throttled more aggressively (for example, 10 payment initiations per minute per TPP) and requires the payment amount to be within the consented limit from the authorization_details.
Mapping Controls to Open Banking API Classes
Most Open Banking schemes define three API classes with distinct security requirements. The values below are a representative baseline — each scheme (UK, EU, Brazil, Australia, Saudi Arabia and others) sets its own limits, so parameterise rather than hard-code. AIS (Account Information Service) allows TPPs to read account data — balances, transactions, statements — with consent lasting a bounded, scheme-defined period (the EU RTS reauthentication interval, for example, was extended from 90 to 180 days in 2022) and access tokens valid for around 5 minutes. PIS (Payment Initiation Service) is single-consent, single-use: the authorization covers exactly one payment, the access token is single-use and expires after it has been used to submit the payment instruction, and the consent expires as soon as the payment reaches a terminal state. CoF (Confirmation of Funds) confirms whether a specified amount is available in an account without initiating any transaction — consent is typically longer-lived for merchant use cases.
| API Class | Consent lifetime | Token lifetime | Single-use token | DPoP / mTLS |
|---|---|---|---|---|
| AIS (Account Information) | Scheme-defined (commonly 90–180 days) | 300 s per call | No — refresh token | Mandatory |
| PIS (Payment Initiation) | Single payment | 300 s, single-use | Yes | Mandatory |
| CoF (Confirmation of Funds) | Variable per merchant | 300 s per call | No — refresh token | Mandatory |
Directory-based schemes require TPPs to register with the scheme’s central directory before they can onboard to any ASPSP (Account Servicing Payment Service Provider). TPP registration produces a software ID, a software statement assertion (SSA) signed by the directory, and optionally a client certificate for mTLS binding. The ASPSP’s Dynamic Client Registration (DCR) endpoint accepts the SSA and creates the OAuth 2.0 client in Keycloak automatically — no manual client provisioning.
Production Checklist
- Audit your OAuth 2.0 foundation first. Ensure token introspection works, refresh token rotation is enabled, and all existing scopes map to a resource server. FAPI 2.0 controls layer on top — a weak OAuth foundation magnifies vulnerabilities rather than containing them.
- Enable PAR in Keycloak. Set the PAR
request_urilifespan (realm attributeparRequestUriLifespan) to 60–90 seconds. Instrument the PAR endpoint to log every request with TPP identity, IP, and request_uri jti. Alert on reuse of any request_uri. - Choose DPoP or mTLS binding (or both). DPoP is lower-friction for TPP onboarding; mTLS is stronger and easier to enforce at the TLS layer. If your TPP onboarding process can provision client certificates, prefer mTLS; otherwise DPoP with a robust jti cache satisfies the FAPI 2.0 sender-constraining requirement.
- Deploy the jti replay prevention cache. Redis Cluster with TTL equal to the DPoP proof validity window (60–300 seconds). Instrument cache hit rate — a hit on a jti that is not from a known legitimate retry is a security event.
- Implement RAR consent model. Define
authorization_detailstypes for AIS, PIS, and CoF matching your scheme’s published schema. Build a consent store (persistent, queryable by TPP + PSU + status). Expose a consent query endpoint. Embed approvedauthorization_detailsin the token introspection response. - Configure JARM in Keycloak. Generate a dedicated RSA-4096 JARM signing key. Set
response_mode=jwtas the required response mode for all FAPI 2.0 clients. Verify that TPP clients correctly parse and validate the JARM JWT before extracting the authorization code. - Configure Kong DPoP validation plugin. Validate DPoP proof on every resource server request (not just at token issuance). Forward the client certificate header (
X-Client-Cert) from the TLS terminator for mTLS binding validation.
- PAR endpoint active;
request_urisingle-use enforced; reuse logged as security event. - PKCE S256 mandatory; plain challenge method rejected at authorization endpoint.
- DPoP or mTLS binding active on all TPP-facing token and resource endpoints.
- jti replay prevention cache (Redis Cluster) deployed with TTL matching DPoP validity window.
- JARM active;
response_mode=jwtenforced; JARM signing key rotated annually. - RAR
authorization_detailsschema validated at PAR endpoint; consent store persists approved details. - Consent status checked on every API call, not just at token issuance.
- AIS access token lifetime: 300 s; PIS token single-use enforced at resource server.
- Keycloak client policies applying FAPI 2.0 profile to all TPP clients; manual client creation blocked.
- Dynamic Client Registration active; scheme directory SSA validated before client creation.
- TPP identity (client_id, SSA subject) logged in every audit event (PAR, auth, token, resource access).
- Implicit grant, ROPC, and plain PKCE blocked at realm policy level.
- Kong rate plans differentiated by consent type (AIS vs PIS); PIS rate plan aligned with the scheme’s API class limits.