Overview
The previous article covered what FAPI 2.0 asks for. This one covers what it takes to prove a platform delivers it. The scope is the ASPSP (account provider) side of an Open Banking standard: an authorisation server (AS), account information APIs and payment initiation APIs. The bar is a conformance suite — the OpenID Foundation FAPI 2.0 plans, a regulator’s functional suite, or both — that plays the third-party provider (TPP) and probes every rule in the profile.
The examples use a market profile that layers specific rules on top of FAPI 2.0 — parameterised consent scopes, signed request and response bodies, refresh tokens bound to the consent lifetime — as several national Open Banking standards do. The patterns apply to any FAPI 2.0 market profile.
Most conformance tests are negative. They send a request object with an expired exp, a token presented without its bound certificate, a PKCE verifier that does not match, a scope that points at another client’s consent. A server that implements only the happy path typically passes a minority of a suite. The rest is about saying no, in exactly the way the standard says to.
Choosing the Topology
Before writing code, decide where the authorisation server ends and the resource server begins. Two shapes cover almost every implementation.
A. Single deployable. The AS, the resource APIs and the consent store ship as one application. In FAPI, the consent ties everything together: the PAR request references it, the scope carries its ID, the token is bound to it, and the resource API checks it on every call. In one process, a revoked consent is revoked for the token endpoint and the resource API in the same transaction, and there is no service-to-service trust to configure. Keep the packages strict inside — authz, common (signing, schema validation, error model), consent, one package per API family — so a later split follows existing seams.
B. Split AS and RS. The AS is a separate service, often a product or an identity platform the organisation already runs, and the resource APIs call a consent service or introspect tokens. This scales each side independently and lets a central identity team own the AS. The cost is every new hop: service credentials, introspection latency, and cache coherence on consent status. A resource server that caches consent status for 60 seconds will happily serve a revoked consent for 60 seconds, and some conformance tests check exactly that.
| Concern | Single deployable | Split AS / RS |
|---|---|---|
| Consent revocation | Immediate, in-process | Depends on cache TTL or introspection on every call |
| Internal trust | None beyond gateway–app | mTLS or signed tokens between every pair |
| Scaling | As one unit | Independently |
| Reuse of an existing AS | Harder | Natural fit |
| Time to first green run | Shorter | Longer: more moving parts to configure per run |
Neither is wrong. Choose by trust boundary, not by org chart: if you cannot name who secures each internal hop, start with one deployable and split later.
mTLS: Split Between Gateway and App
Certificate handling has two jobs. Give them to two layers. The gateway does cryptography: it terminates TLS with FAPI-permitted cipher suites, verifies the TPP certificate chain against the trusted CA, and forwards the verified certificate. The application does policy: it decides which endpoints require a certificate, binds tokens to its thumbprint, and authenticates tls_client_auth clients by subject DN.
Why not demand the certificate at the TLS layer for everything? Because the customer’s browser reaches the same host for login and consent, and a browser has no client certificate. Either put the PSU-facing pages on a separate host, or ask for a certificate at TLS without requiring it and enforce per endpoint in the app.
server {
listen 443 ssl;
server_name as.aspsp.example;
ssl_protocols TLSv1.2 TLSv1.3;
# FAPI-permitted TLS 1.2 suites only
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_client_certificate /etc/gateway/tpp-ca.pem;
ssl_verify_client optional; # browsers share this host
ssl_verify_depth 3;
location / {
# proxy_set_header replaces any inbound value: a client cannot
# smuggle its own certificate header past the gateway.
proxy_set_header X-Client-Cert-Verify $ssl_client_verify;
proxy_set_header X-Client-Cert $ssl_client_escaped_cert;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://app:8080;
}
}
On the application side, decode the forwarded certificate once, in one filter, and expose a parsed X509Certificate to everything downstream. Token binding, client authentication and resource checks should never parse headers themselves.
If the app trusts X-Client-Cert and anything other than the gateway can reach the app, anyone can claim any certificate. Overwrite the header at the gateway on every request, require X-Client-Cert-Verify to equal SUCCESS before using it, and restrict the app port to the gateway with network policy. On a Kubernetes or Red Hat OpenShift platform, a NetworkPolicy that admits only the gateway pods is the minimum.
Rule → Enforcement Matrix
Keep one table as the source of truth: each rule in the profile, the single place in code that enforces it, and how a violation is answered. If a rule has no row, it has no owner. If it has two enforcement points, one will drift. Add a fourth column in your own copy listing the conformance test IDs that cover each row.
| FAPI 2.0 / market-profile rule | Typical enforcement point | How a violation is answered |
|---|---|---|
| PAR mandatory (RFC 9126) | Filter on /authorize rejects any request without a request_uri issued by /par | invalid_request; loose query parameters ignored |
Signed request object (JAR, RFC 9101, typ oauth-authz-req+jwt) | PAR converter verifies the signature against the client’s registered JWKS, then uses only its claims | invalid_request_object |
Request object windows: aud = issuer, nbf not too old, exp − nbf bounded | Same converter; maximum age held in configuration | invalid_request_object |
Client authentication: private_key_jwt or tls_client_auth | Assertion decoder (PS256 or ES256, aud, exp, jti replay cache) or certificate subject match | invalid_client, 401 |
| Sender-constrained tokens (RFC 8705), short-lived | Token carries cnf.x5t#S256; resource filter compares it with the presented certificate | 401 on mismatch or missing certificate |
PKCE S256, response_type=code only | Client settings require a proof key; plain rejected at PAR | invalid_request / invalid_grant |
| Issuer in authorisation response (RFC 9207) | Response handler appends iss to every redirect, success and error | — |
Consent-parameterised scopes (e.g. accounts:<ConsentId>) | Scope validator: consent exists, is awaiting authorisation, belongs to this client | invalid_scope |
| Refresh token bound to consent lifetime | Refresh expiry = consent expiry; rotation per profile; revoked with the consent | invalid_grant after consent ends |
Signed request and response bodies (JWS, application/jwt) | One payload codec on every resource endpoint | 400 with profile error code |
| Payload rules | Schema validator loads the standard’s published OpenAPI files at start-up | 400 with field path |
x-fapi-interaction-id | First filter in the chain echoes the inbound value or mints a UUID | Present on every response, including errors |
| Error model | One exception type and one handler that chooses body or header-only by status | As the profile specifies per status |
Enforcement in Code
Spring Authorization Server, like most mature OAuth frameworks, gives you the OAuth core. FAPI and market-profile rules sit on top as converters, validators and filters. Four of them carry most of the weight.
Request object: trust only what is signed
At /par, the form may carry a request parameter plus loose parameters. The profile says only the signed request object counts. Verify it, check the time windows, and rebuild the authorisation request from its claims alone.
public final class RequestObjectValidator {
private final String issuer;
private final Duration maxAge; // from configuration, per profile version
private final Clock clock;
JWTClaimsSet validate(SignedJWT jwt, RegisteredClient client) throws ParseException {
if (!"oauth-authz-req+jwt".equals(typ(jwt))) fail("typ");
if (!allowedAlg(jwt.getHeader().getAlgorithm())) fail("alg");
if (!verify(jwt, client.jwks())) fail("signature");
JWTClaimsSet c = jwt.getJWTClaimsSet();
Instant now = clock.instant();
Instant nbf = required(c.getNotBeforeTime(), "nbf").toInstant();
Instant exp = required(c.getExpirationTime(), "exp").toInstant();
if (!c.getAudience().contains(issuer)) fail("aud");
if (!client.id().equals(c.getIssuer())) fail("iss");
if (nbf.isBefore(now.minus(maxAge))) fail("nbf too old");
if (Duration.between(nbf, exp).compareTo(maxAge) > 0) fail("exp - nbf");
if (!exp.isAfter(now)) fail("expired");
return c; // caller builds the request from these claims only
}
private static void fail(String what) {
throw new OAuth2AuthenticationException(
new OAuth2Error("invalid_request_object", what, null));
}
}
Certificate-bound tokens and consent-bound refresh
Access tokens should be short-lived and carry the certificate thumbprint. Refresh tokens follow the consent: their expiry is the consent’s expiry, and revoking the consent revokes them. Whether refresh tokens rotate is a profile decision; some Open Banking profiles forbid rotation so that a TPP holds one refresh token for the life of a long consent. Check yours and make it a setting.
TokenSettings fapiTokenSettings(FapiProperties p) {
return TokenSettings.builder()
.accessTokenFormat(OAuth2TokenFormat.SELF_CONTAINED)
.accessTokenTimeToLive(p.accessTokenTtl()) // e.g. 5 minutes
.x509CertificateBoundAccessTokens(true) // cnf.x5t#S256
.reuseRefreshTokens(!p.rotateRefreshTokens()) // profile-specific
.build();
}
// Refresh token expiry follows the consent, not a fixed TTL.
final class ConsentBoundRefreshTokenGenerator
implements OAuth2TokenGenerator<OAuth2RefreshToken> {
private final ConsentStore consents;
public OAuth2RefreshToken generate(OAuth2TokenContext ctx) {
if (!OAuth2TokenType.REFRESH_TOKEN.equals(ctx.getTokenType())) return null;
Consent consent = consents.fromScopes(ctx.getAuthorizedScopes());
return new OAuth2RefreshToken(randomToken(), Instant.now(), consent.expiresAt());
}
}
Consent-parameterised scopes
In several national Open Banking profiles, the scope is not just accounts. It is accounts:<ConsentId>. That turns the scope into a pointer, and a pointer must be checked: it exists, it is in the right state, and it is owned by the calling client. Skip the ownership check and one TPP can authorise against another TPP’s consent.
private static final Pattern SCOPE =
Pattern.compile("^(accounts|payments):([A-Za-z0-9\\-]{1,128})$");
Consent resolve(Set<String> scopes, String clientId) {
List<Matcher> hits = scopes.stream().map(SCOPE::matcher)
.filter(Matcher::matches).toList();
if (hits.size() != 1) throw invalidScope("exactly one consent scope");
Matcher m = hits.get(0);
Consent c = consents.find(m.group(2))
.orElseThrow(() -> invalidScope("unknown consent"));
if (!c.family().equals(m.group(1))) throw invalidScope("wrong family");
if (!c.clientId().equals(clientId)) throw invalidScope("not your consent");
if (c.status() != Status.AWAITING_AUTHORISATION) throw invalidScope("bad state");
return c;
}
Schemas straight from the standard
Do not hand-write payload rules. Most Open Banking standards publish OpenAPI files; load them at start-up and validate every request and response body against the matching operation. When the standard ships an errata, drop in the new files and let the tests show what changed. Hand-coded validation drifts within weeks.
Conformance suites check what you send back as strictly as what you accept. Response validation in test environments catches date formats, missing mandatory links and enum casing before the suite does. Keep it on in every non-production environment; decide separately whether the latency cost is worth it in production.
Conformance Runs in CI
Conformance tools are usually built for a person at a browser: create a plan, paste discovery metadata and client configuration, approve each customer consent by hand, start the run, read the verdicts. One manual pass can take hours. If it only happens before a submission, regressions accumulate silently in between.
The fix is to script the steps the tool’s own guide describes, in the same order, without modifying the tool. The OpenID Foundation suite is open source, runs in containers and exposes a REST API, so it can be driven directly. A regulator’s functional suite may need a headless browser to press the same buttons a person would.
-
Start from a clean runner
Restart the suite (or create a fresh plan) for each test set, then wait on a health check rather than a fixed sleep. Carried-over state is the main cause of flaky runs.
-
Generate configuration, never edit it
A small tool renders discovery and client configuration from templates: issuer URLs for the target environment, client IDs, certificates and signing keys pulled from a secret store at run time. Keys never enter version control.
-
Stage consents
Creating the plan or fetching its test cases makes the suite create consents and PAR requests. Collect the authorisation URLs it produces.
-
Complete each customer consent headlessly
A headless browser opens each URL, logs in as a test customer, selects accounts and approves. Negative cases that expect rejection are left to fail as designed.
-
Run and collect verdicts
Start the run, wait for completion, and parse results into one JSON file per plan. Compare with the last green baseline: any test that flips from pass to fail breaks the build.
export async function runPlan(plan: Plan): Promise<Verdicts> {
await runner.reset();
await waitUntil(() => runner.healthy(), { timeoutMs: 120_000 });
await runner.loadDiscovery(await render(`templates/discovery-${plan}.json`, env));
await runner.loadConfig(await render("templates/config.json", env, secrets));
const cases = await runner.fetchTestCases(); // stages consents + PAR
for (const c of cases.filter(c => c.authorizeUrl)) {
await psu.completeConsent(c.authorizeUrl, testCustomerFor(c)); // Playwright
}
await runner.start();
await waitUntil(() => runner.finished(), { timeoutMs: 30 * 60_000 });
const verdicts = parseVerdicts(await runner.results());
await writeJson(`out/results-${plan}.json`, verdicts);
assertNoRegression(verdicts, await baseline(plan)); // fails the pipeline
return verdicts;
}
Wire this into the pipeline in two tiers. A fast subset — the request-object, client-authentication and token-binding tests — runs on every merge to the main branch. The full set of plans runs nightly against a dedicated test environment and publishes its verdict files as build artefacts. Once a full run is unattended, teams stop batching fixes for a “conformance week” and start treating a red conformance test like a failing unit test.
Official evidence packages usually come from the suite’s own interface and carry a signed declaration from the implementer. The headless runner gets you to green quickly and keeps you there. A named person still runs the final pass and signs.
Strict vs Compatibility Modes
Test tools are software. Profile versions disagree on details, and a functional suite may read a clause differently from the OpenID Foundation plans. When that happens you have two bad options: fail a test you should pass, or weaken a check you should keep. The better option is a third: give each difference a named switch, a relaxed value for the suite that needs it, and a strict value everywhere else.
# Base configuration: strict by default.
fapi:
profile:
# Some profiles require aud = issuer; FAPI 2.0 also allows the
# token endpoint URL. Strict accepts the issuer only.
strict-assertion-audience: true
# Request-object window differs between profile versions.
request-object-max-age: 10m
compat:
relax-test-identity-match: false
---
# Named compatibility profile, used only by the functional suite.
spring.config.activate.on-profile: conformance-compat
fapi:
profile:
strict-assertion-audience: false
request-object-max-age: 60m
compat:
relax-test-identity-match: true # logged on every use
Three rules keep this honest. Every switch is logged at start-up with its value. Every relaxed check logs a warning each time it is exercised. And the OpenID Foundation plans run in strict mode only, against every client authentication method you support. A clean strict run is the evidence that the switches are compatibility shims, not hidden weaknesses.
@Component
final class CompatGuard implements ApplicationRunner {
public void run(ApplicationArguments a) {
log.info("FAPI switches: {}", props.describe());
if (env.acceptsProfiles(Profiles.of("conformance-compat"))
&& env.acceptsProfiles(Profiles.of("production"))) {
throw new IllegalStateException("compatibility profile in production");
}
}
}
Make strict the default in the base configuration, relax only in a named profile, and fail start-up if that profile is active together with a production marker. A switch that “someone will flip back later” is an audit finding waiting to happen.
Common Failure Points
Most conformance failures are not in cryptography. They are in edges: time windows, encodings, ordering, and places where two readings of the text are both reasonable.
| Symptom | Likely cause | Fix |
|---|---|---|
| Token-binding tests fail only behind the gateway | Forwarded certificate is URL-encoded PEM; the app parses it raw | One certificate filter decodes once; downstream code reads a parsed certificate |
| Refresh tests fail after the first refresh | Framework default rotates refresh tokens where the profile forbids it (or vice versa) | Make rotation a profile setting; tie expiry to the consent |
| Error-path tests fail despite the right status | Body returned where the profile wants header-only, or the reverse | Single exception handler that chooses body or header by status |
| Request-object tests pass in one suite, fail in another | Profile versions disagree on the time window | Window in configuration; strict profile uses the tighter value |
| Client-assertion tests reject valid clients | aud checked against one value; the tool sends another permitted value | Accept what FAPI 2.0 permits in compatibility mode; issuer-only in strict |
| Interaction-ID tests fail on error responses | Filter runs after the exception handler | Order the filter first so every response carries x-fapi-interaction-id |
| Signed-response tests fail | JWS body returned as application/json | Codec sets application/jwt and wraps the payload as the profile specifies |
| Revocation tests fail intermittently | Resource server caches consent status | Read consent status on every call, or bound the cache well below the test’s timing |
| Flaky runs | Runner state carried over between test sets | Reset per set; wait on health, not sleep |
The pattern behind almost every row is the same: a rule enforced in two places, or in none. The matrix prevents more failures than any individual fix.
Checklist
-
Choose the deployable boundary by trust
Keep AS and resource APIs together while consent is shared state, or name who secures every internal hop in a split design.
-
Split mTLS: cryptography at the gateway, policy in the app
Verify chains at the edge, overwrite the certificate header on every request, restrict the app port, and require certificates per endpoint in the app.
-
Write the rule → enforcement matrix before the code
One row per profile rule, one enforcement point per row, and the test IDs that cover it. Review it with every errata.
-
Validate against the standard’s OpenAPI
Requests and responses, from the published files. No hand-coded payload rules.
-
Make windows, lifetimes and audiences configuration
Request-object age,
exp − nbf, token lifetime, refresh rotation and assertion audience all vary between profile versions and suites. -
Automate the conformance runner early
Script the manual guide step by step, store verdicts per run, run a subset on every merge and the full set nightly, and fail on any regression.
-
Name every compatibility switch and prove strict mode
Strict by default, relaxed only in a named profile, logged on use, blocked in production. Run the OpenID Foundation plans in strict mode.
-
Describe results precisely
Sandbox conformance is not certification. Report it as what it is, and keep the certification evidence path separate, manual and signed.