Reference

Security & identity

Look up identity, access checks, browser defenses, secrets and safe input boundaries.

Scope and conventions

Web/API security patterns, not a complete authentication implementation or security certification. Sequences are labeled sketches. Use maintained framework/provider libraries for identity and cryptography; adapt policies to your trust boundaries. Primary sources accompany each entry.

Identity & credentials

Separate authentication from authorization

Web & API security

Authentication establishes a principal; authorization decides whether that principal may perform an action on a resource. A successful login does not grant access to every object.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Separate authentication from authorization
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
request → authenticate → authorize principal + action + resource
        → perform operation → return permitted data

Store a password verifier, not a recoverable password

Web & API security

Use a maintained password-hashing library with Argon2id and a unique salt. Store its encoded verifier and parameters. Encryption and fast hashes such as plain SHA-256 are unsuitable substitutes for password hashing.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Store a password verifier, not a recoverable password
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
registration → library hashes password with salt + work parameters
login        → library verifies submitted password against stored record
upgrade      → rehash after successful verification when policy changes

Select password-hashing costs deliberately

Web & API security

OWASP currently gives Argon2id m=19456 KiB, t=2, p=1 as one minimum configuration. Benchmark resource use under concurrent login load; use stronger settings when feasible and store parameters for upgrades.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Select password-hashing costs deliberately
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
Argon2id parameter example (not a password record):
m = 19456 KiB
t = 2 iterations
p = 1 lane

This is a dated policy baseline, checked 31 October 2026. Recheck the linked guidance before choosing deployment parameters.

Bound login abuse without exposing account existence

Web & API security

Use generic failure responses and throttling that considers the account as well as request origin. MFA reduces reliance on a password alone. Re-authenticate for sensitive account changes.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Bound login abuse without exposing account existence
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
invalid user / wrong password → same public failure message
repeated failures → bounded attempts + monitored policy
sensitive change → fresh authentication as required

Distinguish OAuth access from OIDC login

Web & API security

OAuth delegates access to a protected API. OpenID Connect adds an identity layer for login. An ID token is intended for its relying party; do not treat it as a generic API access token.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Distinguish OAuth access from OIDC login
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
browser login → OIDC provider → relying party validates ID token
API request   → access token → resource server validates token

Bind an authorization-code exchange with PKCE

Web & API security

Use a provider SDK for authorization code flow with PKCE. Bind the response to the initiating browser transaction, validate the redirect URI and token claims, and use the protections required by your OAuth/OIDC flow.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Bind an authorization-code exchange with PKCE
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
authorization request → code_challenge (S256)
code exchange         → matching code_verifier
callback              → validate transaction binding + tokens

PKCE is not an application authorization policy. Do not hand-roll a login flow from this sketch.