10. Multi-channel, WebView SSO & 3-layer authorization

13 cards

Review this deck
All cards in this deck

Channel in the session

`Web`, `App`, `Operator` stored in SessionID2; same session/xsrf structure, different issuance.

APP_SSO_TOKEN flow on the UI side

API returns 401 → if the UA matches ACME Trade App then POST `/auth/app/login`; on 200 retry the original request, on 403 show "Login failed"; if the UA does not match, go to web login.

APP_SSO_TOKEN flow on the BFF side

Check the UA again → call the SSO Token Verify API (server-to-server, API key) → receive sub/accountNo/accountType/passkeyFlag → only issue SessionID2 for an online trading account.

Opaque token vs id_token

An opaque token cannot be self-verified and requires calling the issuer's API; an id_token is self-verified with JWKS without extra calls.

API key for the SSO Token Verify API

A dedicated server-to-server secret, stored in a secret store, never in docs or the client.

Spoofed UA

A web attacker can fake the app UA but has no valid APP_SSO_TOKEN → the BFF still returns 403; access is based on token verification + account type.

Why 403 rather than 401 for a rejected SSO

401 means "not logged in, please log in"; 403 means the token is valid but not eligible, and the UI must not retry in a loop.

Layer 1 – IdP

Post-login Action (`event.client.client_id` × account type, `api.access.deny()`) → returns `error=access_denied`; a custom DB script has no client context so it cannot do this.

Layer 3 – BFF

After getting the accountNo, call the Account Attribute API; not an online trading account → cancel the session, "Login failed".

Defense in depth

Do not trust a single layer; the UI can be bypassed, the IdP can be misconfigured, the BFF is the last checkpoint.

Login Status API

A blocking API: failure or `isLoginAllowed=false` → delete SessionID1, do not persist SessionID2, do not set cookies, "Login failed".

Login History API

A best-effort API: called with `usedPasskey` when `needsTradingInfoEntry=false`; errors are deliberately ignored and do not affect login.

Blocking vs best-effort APIs

The spec must state which kind each API is and its behavior on error (fail-closed vs fire-and-forget).

10. Multi-channel, WebView SSO & 3-layer authorization – Flashcards – Login Flow | Học Dev