/12. Test backdoors, env & spec-writing skills (10-item checklist)

12. Test backdoors, env & spec-writing skills (10-item checklist)

19 cards

Review this deck
All cards in this deck

Operator mode

`isOpe=true` → `/auth/web/login` returns 400; staff call `POST /auth/operator/login` with `Authorization: Bearer <operator_token>` (a JWT from the internal IdP); the BFF verifies it via the internal JWKS, takes `operatorId` from a claim (not from the body), then asks the Operator Account Status API whether the staff member has permission on the customer's `accountNo`; the `Operator` channel session also stores `operatorId` for auditing.

`POST /auth/mock-session`

Creates a fake session for testing; guarded by STAGE ∈ {dev, stub, stg} and a password matching `MOCK_LOGIN_PASSWORD`; accepts JSON.

Guard failure returns 404

Do not return 401/403 so an attacker in prod cannot tell the test endpoint exists.

Spec for test backdoors

Must state the environment conditions, the secret used by the guard, the behavior when disabled, and a commitment never to deploy it enabled in prod.

Env vars in the spec

For each variable state the name, value per environment, source (SSM/infra stack) and description; for secret values just write "from SSM".

Env prefix convention

Inherited variables keep `LEGACY_`, new variables use `PORTAL_`; record the decision and rationale in the docs so names are not changed arbitrarily.

Endpoint description structure

Overview → Method/Endpoint → Item/Required/Value table by location (cookie/query/header/body) → Processing details as branching bullets → footnotes for reused parts.

List ALL error branches

Missing session, wrong state, each `error_description` from the IdP, missing code, token exchange failure (retry), id_token verification failure, business API failure; each branch states which session is deleted, whether cookies are set, and where to redirect.

IdP client table

Callback URL, connection, grant_type, permissions, Management API used, purpose, plus a "design rationale" section.

Checklist 1 – Safe redirects

Do successUrl/failureUrl/callback have a domain allow-list, is there any open redirect.

Checklist 2 – Bindings

Are state↔SessionID1, nonce↔id_token, code_verifier↔code, xsrfToken↔SessionID2 all in place.

Checklist 3 – Tokens never leave the server

Do access/id/refresh tokens reach the browser or the logs.

Checklist 4 – Session fixation

SessionID2 is newly created after authentication, SessionID1 is not reused.

Checklist 5 – Revocation

What logout deletes in Redis/IdP/cookies; what a 401 deletes; whether third-party cookies are kept correctly.

Checklist 6 – Authz vs authn

Are rejections at the IdP and at the BFF consistent, which branch is missed.

Checklist 7 – Timeout/retry

Do the token endpoint, JWKS, health API and backend APIs have clear retry and fallback; where is it fail-open and is that intentional.

Checklist 8 – Environments

Test endpoints are guarded by STAGE and return 404 when disabled; secrets live in SSM/infra, not in docs.

Checklist 9 – Enumeration/logging

Do error messages reveal that a user exists/is blocked; do logs carry a BFF error code for tracing without leaking data.

Checklist 10 – WebView specifics

The UA can be spoofed so it is only used for routing; access is based on token verification + account type.

12. Test backdoors, env & spec-writing skills (10-item checklist) – Flashcards – Login Flow | Học Dev