A broker of the brokerage brk-north signs in to the broker portal at nine in the morning and opens quote Q-5531. The portal's backend, the service svc-portal-bff, now remembers that this browser belongs to the broker u-broker-n1. Every later click is quicker because the broker does not prove anything again. Ten minutes later the broker opens a second tab: a page that promises a free roof-age lookup. That page is hostile. It contains a hidden form that posts to the portal's "submit quote" endpoint, and a script that tries to read whatever the portal left in the browser.
The hostile page does not need the broker's password: the browser is signed in, and browsers attach some credentials on their own. The question this page answers is narrow and practical: after login, what exactly does the browser hold, who can make it send that thing, and who can steal it? The answer decides whether the hostile tab is harmless or whether it submits a quote in the broker's name.
What a session is, in plain words#
HTTP forgets: each request arrives alone. So after the broker proves who they are, the server keeps a record ("this browser is u-broker-n1, signed in at 09:00 with password plus one-time code") and gives the browser a short random handle to it, which the browser sends back on every request.
That record is a session: server-side state that remembers an authenticated person between requests. A tiny example: the portal stores {principal: u-broker-n1, tenant: brk-north, acr: password} under the id 7f3c... and the browser sends 7f3c... on every request. The usual carrier for the handle is a cookie, so the handle in its cookie is called a session cookie.
Before AI. A Java engineer has run this for twenty years: the servlet container'sHttpSession, aJSESSIONIDcookie, a filter that loads the session before the controller runs, andsession.invalidate()on logout. Nothing on this page replaces that design. What changed is where tokens live once an identity provider issues them, and how much a single injected script can do.
A session answers one question only: "which authenticated person is this browser?". It does not say which quotes that person may read. The quote service still decides that on the record. A valid token is not a permission, and neither is a valid session.
The smallest session: one cookie line#
The smallest primitive is one response header. The broker portal in the example sets this after login (it is step 8 of the login trace on OAuth, OIDC and federation):
HTTP/1.1 302 Found
Location: /quotes
Set-Cookie: __Host-portal_session=<id>; Path=/; HttpOnly; Secure; SameSite=Lax
Each attribute closes one door.
HttpOnly keeps scripts away from the cookie. Standard (MDN Set-Cookie, read 2026-11-18): it "Forbids JavaScript from accessing the cookie, for example, through the Document.cookie property", yet the cookie "will still be sent with JavaScript-initiated requests". So an injected script cannot copy the handle, but it can still make the browser use it. Remember that second half; the hostile tab depends on it.
Secure keeps the cookie off plain HTTP. MDN: sent "only when a request is made with the https: scheme (except on localhost)".
SameSite decides whether the cookie travels on requests that another site started. Strict sends it "only for requests originating from the same site that set the cookie". Lax also sends it on cross-site top-level navigations with a safe method, which "excludes POST, PUT, and DELETE". None sends it everywhere and requires Secure. MDN says only that "Some browsers use Lax as the default value if SameSite is not specified", so the portal sets it explicitly.
The __Host- prefix pins the cookie to this exact host. MDN: such cookies "must be set with the Secure attribute by a secure page (HTTPS)", "must not have a Domain attribute specified, and the Path attribute must be set to /". A sibling subdomain cannot plant or overwrite it.
Common confusion. MDN says Path "is not intended as a security measure". Scope a cookie with the host and the prefix, not the path.
The cookie specification itself is unfinished. Standard (RFC 6265bis, read 2026-11-18): the revision is still an Internet-Draft, draft-ietf-httpbis-rfc6265bis-22, in the RFC Editor queue; since 19 October 2026 its RFC Editor state is Blocked (RPC status "blocked: Final Approval Pending"). The published RFC 6265 is older than SameSite. In practice, browser behaviour plus MDN is what a team tests against.
The broker portal in the example#
The example in examples/uw-auth/ follows one request from the broker's browser to the record. The broker never holds a token. The portal backend, svc-portal-bff, ran the login with the identity provider, received an ID token and an access token, validated the ID token, and kept both tokens on the server. The browser holds only __Host-portal_session. When the broker opens quote Q-5531, the BFF looks up the session, attaches the access token server-side and calls the API. The quote service validates that token and asks the policy decision point about the record.
That design has a name. A backend for frontend (BFF) is a server component that belongs to one front end: it is the OAuth client, holds the tokens, and proxies the browser's calls, so the browser never sees a token. A tiny example: the browser calls /api/quotes/Q-5531 on the portal's own origin; the BFF turns that into GET https://api.uw.insurer.example/quotes/Q-5531 with Authorization: Bearer <access_token>.
In our insurance example. The broker sees a quote,Q-5531; the insurer works the same record as submissionSUB-1004. The portal backend created thequote_idwhen the broker submitted, and intake maps it one to one to thesubmission_id. Authorization is decided on the record both ids point to, never on which id the caller sent. This site's own caseUW-A02shows it: the broker ofbrk-south, with a perfectly valid session and token, asks forQ-5531and then forSUB-1004; both answers are 404 under ruleR-AZ-03.
Here is the design with the two places a credential could live, and the one place it does live:
Diagram: Where the credential lives · the broker portal's backend for frontend
Read left to right. The broker's browser holds only an opaque session cookie that scripts cannot read. The portal BFF holds the session record and both tokens, and attaches the access token server-side. The quote service validates the token and asks the policy decision point about the record. A hostile tab can try to make the browser send the cookie (CSRF) or run script inside the page (XSS); neither reaches a token, and neither changes the decision on Q-5531.
- Broker's browser
- __Host-portal_session cookie: The only credential in the browser: an opaque handle. Scripts cannot read it; the browser attaches it to requests to the portal's own host.
- GET /api/quotes/Q-5531 on the portal origin: The page calls its own backend, never the API directly. Every state-changing request also carries a CSRF token the hostile tab cannot know.
- Portal BFF (svc-portal-bff)
- session record: Server-side state keyed by the cookie's id. Logout and idle timeout delete it; a copied cookie then points at nothing.
- ID token + access token kept server-side: The BFF is the OAuth client. It validated the ID token at login and keeps the access token to call the API.
- Quote service
- validate token, ask the PDP on the record: The service checks the token, then decides on the record's tenant. The session and the cookie never decide which quote.
The left lane is all a script on the page can touch, and HttpOnly hides even the handle from scripts. The tokens sit on a server the hostile tab cannot reach. The permission is decided in the right lane, on the record's tenant; the session never decides it.
Two designs, the same five events#
Put two designs through the same events. One is the portal's: a cookie session at the BFF. The other is the common single-page-app shortcut: the access token in browser storage, sent by script in the Authorization header.
The same outcomes, as computed by examples/uw-auth/sessions.py session_outcome(design, event) (synthetic; no browser is driven):
| Event | Cookie session at the BFF | Bearer token in the browser |
|---|---|---|
| Login | new session cookie, id regenerated at login | token stored in browser storage, readable by any script in the origin |
| Injected script (XSS) | can send requests while the page stays open; cannot copy the cookie | reads the token and replays it from anywhere until it expires (3,600 s in this example) |
| Forged cross-site POST | refused: no cookie (SameSite=Lax) and no CSRF token | refused: the browser does not attach the header (this example's inference) |
| Logout | server deletes the session; an old cookie is worthless | a copied token keeps working until exp, unless the API introspects or checks a deny list |
| Idle 900 s | server ends the session | still signed in; a bearer token has only its expiry |
| Decision without recent strong login | 401 insufficient_user_authentication | same 401: step-up does not depend on where the token lives |
The code below shows that each outcome follows from four properties of a design (script-readable, auto-sent, CSRF token, server-revocable). It proves nothing about a real browser.
from sessions import session_outcome
for event in ["xss_script", "cross_site_post", "logout", "idle_timeout"]:
for design in ["bff_cookie", "spa_bearer"]:
o = session_outcome(design, event)
print(f"{event:<16} {design:<11} exposed={o['credential_exposed']!s:<5} attacker: {o['attacker_can']}")
Run in a scratch copy of examples/uw-auth/ on 2026-11-18 (the example's agent is a scripted stand-in, so results show the access controls, not any model):
xss_script bff_cookie exposed=False attacker: send requests from the open page while it stays open (the cookie rides along); cannot copy the cookie
xss_script spa_bearer exposed=True attacker: read the access token and replay it from anywhere until it expires (3600 s)
cross_site_post bff_cookie exposed=False attacker: nothing: the forged POST arrives without the cookie (SameSite=Lax) and without the CSRF token
cross_site_post spa_bearer exposed=False attacker: nothing: the browser does not attach the Authorization header to a forged cross-site request
logout bff_cookie exposed=False attacker: nothing with an old cookie: the server deleted the session
logout spa_bearer exposed=True attacker: keep using a copied token until exp, unless the API introspects or checks a revocation list
idle_timeout bff_cookie exposed=False attacker: nothing
idle_timeout spa_bearer exposed=False attacker: use an unattended browser until the token expires
The designs tie on the forged form, for different reasons, and split on XSS and logout: with browser tokens one injected script becomes a stolen credential that logout cannot recall; with the BFF the script is dangerous only while the page is open.
The hostile tab, part one: a forged request#
Back to the broker's second tab. Its hidden form posts to https://portal.insurer.example/api/quotes with fields that submit a quote. If the browser attaches the session cookie, the BFF sees a valid session and does what the request asks. The broker never clicked anything. This attack is cross-site request forgery (CSRF): another site makes the victim's browser send a request that carries the victim's ambient credentials. A tiny example: <form action="https://portal.insurer.example/api/quotes" method="post"> on the free roof-age page, submitted by script on load.
The first layer is a value the attacker cannot know. Guideline (OWASP CSRF Prevention Cheat Sheet, read 2026-11-18): "First, check if your framework has built-in CSRF protection and use it". The synchronizer token, a random value bound to the session and required on every state change, is "one of the most popular and recommended methods"; stateless designs use the signed double-submit cookie.
The second layer is the browser telling the server where the request came from. The same cheat sheet now leads with Fetch Metadata and calls the Sec-Fetch-Site request header "the primary signal for CSRF protection". It immediately adds the condition: for software that "targets only modern browsers ... you may rely on Fetch Metadata headers together with the fallback options", and "a fallback to standard origin verification headers is a mandatory requirement". So a server that rejects state-changing requests whose Sec-Fetch-Site is cross-site must still check Origin when the header is absent. This emphasis is newer than most tutorials; this site's fact log marks it SURPRISING.
SameSite is the third, supporting layer. OWASP: SameSite "does not replace a proper CSRF defense in most deployments". The portal's Lax cookie does not travel on the hostile form's cross-site POST, but Lax still sends it on a top-level GET navigation, which is one more reason never to change state with GET ("Do not use GET requests for state changing operations").
Production pitfall. Login itself can be forged. An attacker signs the victim into the attacker's own account, and the victim then types data into it. OWASP calls this login CSRF: protect the login form with a pre-session token and regenerate the session after login.
The hostile tab, part two: a script inside the page#
The second threat is worse. Suppose a broker-supplied file name is rendered without escaping, and a script runs inside the portal's own origin. That is cross-site scripting (XSS): an attacker's script executes in a trusted page, with the page's privileges. A tiny example: a quote attachment named <img src=x onerror=...> that the portal shows as HTML.
An injected script can read the page, call the API with fetch and read any CSRF token. OWASP: "Remember that Cross-Site Scripting (XSS) can defeat all CSRF mitigation techniques!" What the session design still controls is the blast radius. With the BFF, the script cannot read __Host-portal_session (HttpOnly) and cannot reach the tokens (they are on the server), so the attack ends when the tab closes or the session ends. With tokens in browser storage, the script reads the access token and, in many SPAs, the refresh token too. Guideline (OWASP Session Management Cheat Sheet, read 2026-11-18): "Do not store authentication tokens, session IDs, JWTs, refresh tokens, or any credential in" web storage; prefer HttpOnly; Secure; SameSite=Strict cookies or a Backend-for-Frontend pattern.
What this is not. This page explains what XSS can reach, not how to prevent it. Output encoding, templating and content security policy are a different discipline; the enforceable checks around the model, including injected text, live on Guardrails.
Fixation, logout and the session that must end#
Two lifecycle mistakes turn a correct cookie into a weak one.
The first is keeping the same session id across login. If an attacker can plant a known id in the victim's browser before login (an old subdomain, a link), and the server keeps that id after the broker authenticates, the attacker now holds a signed-in session. This is session fixation. The defence is one line of policy. OWASP: "The session ID must be renewed or regenerated by the web application after any privilege level change" (login, password change, role change), and the old id destroyed. The example's BFF regenerates the id at login and again after step-up.
The second is a logout that only clears the browser. OWASP: on logout or expiry "invalidate the session on both sides, client and server"; a deleted cookie with a live server record leaves a copied id working. Timeouts are server-enforced too, idle and absolute; the cheat sheet gives ranges by risk (idle "2-5 minutes for high-value applications", "15-30 minutes for low risk applications"). The example uses 900 seconds idle (illustrative).
Step-up: a sensitive action asks for more#
Some actions need a recent, stronger login even inside a valid session. In the example, decision.record on submission SUB-1004 is only for the assigned underwriter u-uw-w1, acting through the cockpit backend svc-cockpit-bff, with a phishing-resistant authentication no older than 300 seconds (illustrative). Asking for that mid-session is step-up: the server refuses a sensitive action until the person authenticates again at a higher level, then lets the same session continue.
This site's own case UW-A12 runs it. The underwriter's cockpit session is ten minutes old and at password level. The cockpit asks the quote service to record a decision. The answer is 401, with a challenge that tells the client what to obtain, and nothing is written:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="insufficient_user_authentication",
acr_values="urn:insurer.example:acr:phishing-resistant", max_age="300"
Standard (RFC 9470, read 2026-11-18): the error means the authentication event behind the token "does not meet the authentication requirements"; acr_values lists acceptable levels and max_age the allowed seconds since the last active authentication. The example's pdp.py builds that challenge (wrapped here for reading). After the underwriter completes the stronger login, the cockpit BFF records the new acr and auth_time server-side and regenerates the session id, because a privilege level changed. How the stronger authenticator works (passkeys, phishing resistance, assurance levels) is the next page.
Security note. Step-up proves a stronger login, not a right. After step-up the policy decision point still checks role, entitlementuw.decide, business unit and assignment. InUW-A09the peer underwriteru-uw-w2, fully stepped up, is refusedSUB-1004with 403 because the submission is not assigned to them.
CORS is not authorization#
One more browser mechanism is often mistaken for a lock. Cross-origin resource sharing (CORS) lets a server tell the browser which other origins may read its responses from script. A tiny example: the API answers Access-Control-Allow-Origin: https://portal.insurer.example, so a script on the portal can read the response and a script on the hostile page cannot.
Standard (MDN CORS guide, read 2026-11-18): CORS is "an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources." An app "can only request resources from the same origin the application was loaded from unless the response from other origins includes the right CORS headers." For credentialed requests the server "must not specify the * wildcard" and must name the origin. And a "simple request" (GET, HEAD or POST with only safelisted headers and a form-like content type) is sent without a preflight.
This site's inference (MDN does not say it in these words): the browser enforces CORS on whether a script may read a response, so it does not stop a request from reaching the server, and a non-browser client such as curl ignores it completely. The hostile tab's simple form POST reaches the BFF whatever the CORS headers say; only the CSRF defence stops it. So the quote service never treats "passed CORS" as evidence of who called or what they may do.
Common confusion. RFC 10017 says a BFF "can rely on CORS as a CSRF defense mechanism" with a required custom header, which forces a preflight. That stops forged browser requests; it still says nothing about which records the caller may read.
Choosing where the tokens live#
The decision of this page is where tokens live for a browser application. Standard (RFC 10017, OAuth 2.0 for Browser-Based Applications, BCP 212, August 2026, read 2026-11-18): it describes three architectures and says they "are presented in decreasing order of security". This document was a long-running draft and is now an RFC; this site marks that SURPRISING.
- Backend for Frontend: "strongly recommended for business applications, sensitive applications, and applications that handle personal data". The BFF "MUST enable the Secure flag", "MUST enable the HttpOnly flag", "SHOULD enable the SameSite=Strict flag" and "MUST implement a proper CSRF defense".
- Token-mediating backend: the refresh token stays server-side, the access token goes to the browser; the RFC says "it is strongly recommended to evaluate if adopting a full BFF".
- Browser-based OAuth client: a public client in JavaScript with PKCE; script in the page "will be able to obtain access tokens and refresh tokens from the authorization server."
Diagram: Three browser designs from RFC 10017 · what the browser holds and what an injected script takes
Rows are the three architectures, in the RFC's decreasing order of security. Read across a row for one design; read down a column to compare. The more the browser holds, the more one XSS takes, and the less logout can recall.
- Backend for frontend
- opaque cookie: Only the session handle. All tokens stay with the confidential client on the server.
- actions while the page is open: The script can send requests through the cookie but cannot copy a credential to use elsewhere.
- yes: server deletes the session: Logout deletes server state and revokes the refresh token held by the BFF.
- Token-mediating backend
- access token: The backend runs the flow and hands the access token to the browser, which calls resource servers directly.
- the access token until it expires: Readable by script, usable from the attacker's own machine until exp.
- partly: The backend can revoke the refresh token; an access token already copied lives to exp unless the API introspects.
- Browser-only client
- access and refresh tokens: A public client entirely in JavaScript, using authorization code with PKCE.
- both tokens: RFC 10017: the attacker can obtain access and refresh tokens from the authorization server.
- depends on the authorization server: Only revocation at the authorization server, honoured by resource servers that check it, ends a stolen token early.
| Design | Browser holds | XSS can take | Logout and revocation | Fits |
|---|---|---|---|---|
| BFF (cookie session) | an opaque HttpOnly cookie | actions while the page is open; no token | server deletes the session | portals with personal or business data, like the broker portal |
| Token-mediating backend | the access token | the access token until it expires | refresh token server-side; access token lives to exp | front ends that must call many APIs directly, after a written reason |
| Browser-only client | access and refresh tokens | both tokens | depends on the authorization server | low-sensitivity apps with no backend at all |
This site's recommendation: the simplest credible design for the broker portal is the BFF with a server session, because it holds business data for many tenants and a backend already exists. The trigger to grow is not "we added a SPA". It is a need the BFF cannot meet, such as many independent APIs that must be called from the browser at high volume; then a token-mediating backend with short access-token lifetimes is the next step, chosen in writing. The browser-only client fits an app with no server and nothing worth stealing.
In our insurance example. The example's portal cookie usesSameSite=Laxwith a synchronizer CSRF token, which OWASP allows ("SameSite=Strict(preferred) orSameSite=Lax"). RFC 10017 says SHOULDStrict. A team following the RFC starts withStrict;Laxis a documented deviation, typically so that a broker who follows an emailed link to a quote arrives signed in. WithLaxthe CSRF token carries the whole defence for POSTs, which is why it is mandatory here.
The same pattern in Next.js (documented shape; not run here)#
Product (Next.js, as documented on 2026-11-18): the Next.js authentication guide splits the work into authentication, session management and authorization, and recommends an auth library over custom code. It shows cookies set on the server with httpOnly: true, secure: true, sameSite: 'lax', path: '/', a Data Access Layer with a verifySession() function wrapped in React cache, and says to "Treat Server Actions with the same security considerations as public-facing API endpoints". In Next.js 16 the request interceptor file changed name: SURPRISING: "The middleware file convention is deprecated and has been renamed to proxy" (version history: v16.0.0), with a codemod npx @next/codemod@canary middleware-to-proxy ..
The BFF shape for the portal, assembled from those documented pieces, is folded below.
Next.js BFF route handlerDocumented shape; not run, not type-checked
getSession, getAccessToken and isSameOriginRequest stand for your session store, your token store and your CSRF check. Use a maintained auth or session library for them.
// sketch: documented shape, not run. app/api/quotes/[id]/route.ts in the portal BFF
import 'server-only'
import { cookies } from 'next/headers'
export async function GET(req: Request) {
const sid = (await cookies()).get('__Host-portal_session')?.value
const session = await getSession(sid) // server-side lookup: your session store
if (!session) return new Response(null, { status: 401 })
const id = new URL(req.url).pathname.split('/').pop() ?? ''
const token = await getAccessToken(session) // the access token never leaves the server
const r = await fetch(`https://api.uw.insurer.example/quotes/${encodeURIComponent(id)}`,
{ headers: { Authorization: `Bearer ${token}` } })
return new Response(r.body, { status: r.status }) // 404 from the quote service passes through
}
export async function POST(req: Request) {
if (!isSameOriginRequest(req)) return new Response(null, { status: 403 }) // CSRF: token or Sec-Fetch-Site + Origin
// ... same session lookup, then forward to the quote API
}
The BFF never decides which quote the broker may read; the quote service does, as the 404 passing through shows.
One caution comes straight from the documentation: a proxy.ts check is optimistic only. The guide says proxy "should not be your only line of defense in protecting your data", and the proxy page says "Always verify authentication and authorization inside each Server Function rather than relying on Proxy alone."
In a coding agent. A coding agent editing the portal works through a repository-scoped GitHub App installation and proposes a pull request that a person with merge rights reviews. A diff that setsSameSite=None, dropsHttpOnlyor moves tokens intolocalStorageis what that review is for; a test should assert theSet-Cookieline. The agent's sandbox holds no real session or production credential. Workflow: diff-to-deploy; permissions: Coding agents.
Security notes#
HttpOnlylimits theft, not misuse;SameSiteis defence in depth behind a real CSRF defence.- Never put a session id, token or key in a URL. OWASP's REST sheet says passwords, security tokens and API keys "should not appear in the URL, as this can be captured in web server logs"; a session id deserves the same care.
- A session says who; it never says which record. Keep the object-level check in the service that owns the record.
- Logout, password change and "sign out everywhere" must delete server state.
Monday checklist#
- Every session cookie:
__Host-prefix,Path=/,HttpOnly,Secure, explicitSameSite(Strictunless a written reason saysLax). - Session id at least 64 bits of entropy from a CSPRNG (OWASP), regenerated at login and at step-up, destroyed on logout.
- No token, refresh token or session id in
localStorageorsessionStorage. - A test that a cross-site POST without the CSRF token is refused.
- CORS: an explicit origin list, never
*with credentials, and no code that reads "CORS passed" as authorization. - A negative test per sensitive action: no step-up gives 401 with
acr_values; a stepped-up peer still gets 403.
Exercises#
Exercise 1. The portal team wants to drop the CSRF token "because the cookie is SameSite=Lax". Which request still carries the cookie cross-site, and why does that matter?
AnswerTop-level GET navigations
Lax still sends the cookie on cross-site top-level navigations with a safe method. If any GET changes state, it is forgeable; and a sibling application on the same site defeats SameSite entirely (RFC 10017 notes SameSite "falls short when the BFF is hosted alongside other applications within the same site"). Keep the token.
Exercise 2. A script injected into the BFF-based portal sends POST /api/quotes with the page's CSRF token. Does the CSRF defence stop it? What does the design still protect?
AnswerNo; it protects the credential and the duration
No. XSS runs on the portal's origin and can read the token. The BFF design still keeps the tokens and the session id out of the script's reach, so the attacker cannot reuse them elsewhere, and the attack ends when the page closes or the server ends the session. The quote service still refuses records of another tenant.
Exercise 3. An API team says "we enabled CORS only for the portal origin, so other tenants cannot call us." Write the one-sentence reply.
AnswerCORS limits browsers reading responses
CORS only tells browsers which origins' scripts may read responses; any non-browser client, and any simple request from a browser, still reaches the API, so tenant isolation must be decided on the record by the quote service (in this example rule R-AZ-03, answered 404).
Advanced perspective#
Signed or encrypted cookie sessionsStateless is simpler until you need to revoke
A cookie can carry the session itself, signed or encrypted, instead of a handle. Product (Next.js, as documented on 2026-11-18): the guide calls this stateless and says it is "simpler, but can be less secure if not implemented correctly"; database sessions send the browser only "the encrypted session ID" and are "more secure, but can be complex". The trade is the one tokens have: no lookup per request, but no way to end one session early except a server-side deny list, which brings the state back. Use a stateless cookie for low-value preferences or as a cache in front of a session table; use a server session where "sign out this device now" must work. Whatever the format, the key that signs the cookie is a secret held by the server, rotated like any other, and never a password.
Device sessions and "sign out everywhere"One principal, many sessions, one revocation path
A broker uses a laptop and a phone. Model each as its own session row with principal_id, device label, created, last seen, acr, auth_time. Three operations follow: list ("where am I signed in"), end one, end all. Ending all must also reach anything the sessions handed out. With a BFF that is the refresh token held server-side: revoke it at the authorization server (RFC 7009 says revoking a refresh token "SHOULD also invalidate all access tokens based on the same authorization grant", where supported). Access tokens already issued live until exp unless resource servers introspect; keep them short. OpenID Connect Back-Channel Logout lets the identity provider POST a logout_token to the BFF so a sign-out at the identity provider ends the portal session too. Write the access-removal time you can actually achieve; it is the sum of these delays, not the moment the button was pressed.
Fetch Metadata in practiceA server rule, with a fallback that is not optional
A Fetch Metadata check is a few lines in the BFF: for state-changing methods, reject when Sec-Fetch-Site is cross-site; allow same-origin; decide same-site deliberately (a sibling subdomain is same-site). When the header is absent, OWASP makes the fallback mandatory: compare Origin (or, if absent, Referer) with the expected origin. Log rejections with the route and the header values, never the cookie. Keep the synchronizer token for any client you cannot classify, and remember that Fetch Metadata, like every CSRF control, is useless against XSS on your own origin.
Running a BFFIt becomes a token vault with uptime
The BFF now holds every signed-in broker's tokens, so it is a high-value service: encrypt the token store at rest, keep it off logs, give it its own workload identity, and scale the session store (a shared cache or database) so a restart does not sign everyone out. It also becomes a proxy that must not widen anything: it forwards to a fixed list of upstream routes, never to a URL taken from the request, and it never adds scopes the user did not get. If the BFF fails, brokers cannot work; if the session store fails, fail closed and ask them to sign in again, rather than accepting cookies you cannot look up.
In one breath#
After login the browser holds something that stands for the person, and any open page may try to make it act. Put only an opaque, HttpOnly, Secure, SameSite, __Host- cookie there, keep tokens on a backend for frontend, defend every state change against CSRF, regenerate the id at login and step-up, and delete server state at logout. CORS and the session itself decide nothing about records. Prove who, then decide what, on the record itself.
The broker portal now remembers a signed-in broker safely, and the cockpit can ask an underwriter for a stronger login before a decision. What it cannot yet say is how strong "stronger" is, or why a password plus a one-time code still falls to a phishing page. Authenticators and MFA picks up there: passkeys, phishing resistance and assurance levels.