On this page
Protect browser and machine requests
Enforce antiforgery, trusted forwarding, key scopes and session revocation.
Goal: enforce browser-write protection and distinguish human sessions from machine credentials. A package reference alone does not secure an endpoint.
Browser writes
Configure authentication and authorization in the product. Install an enforcing antiforgery gate after authorization. Calling UseAntiforgery alone does not enforce token validation on every JSON write. Anonymous cookie-based writes must opt in with RequireAntiforgery; reviewed machine/webhook routes may opt out with DisableAntiforgery while retaining their own authentication.
Expected failure: missing or invalid antiforgery proof rejects the write before the handler changes data. A valid login cookie alone is insufficient.
Trusted client address
Use GetClientIp or GetClientIpPartition for audit and rate-limit partitioning. Never interpret raw Cloudflare or forwarded headers as authority. Authenticated BFF forwarding is explicitly enabled and requires proof over an overwritten IP header. Foundation strips forwarding proof before downstream middleware.
API keys
IApiKeyManager returns random key material once. Persistence stores hashes. The host registers its EF context, both API-consumer/key configurations, the named authentication scheme and scope authorization. Issuance and revocation are administrative operations. A scope does not establish tenant membership.
The lifecycle hydrates the key snapshot before startup completes. Later failures may use the last good snapshot only within MaximumStaleAge, then resolution fails closed. Cross-replica revocation convergence follows RefreshInterval; immediate global invalidation requires product infrastructure.
Human sessions
In the released legacy stack, refresh rows and the session counter share one database. Revocation updates them transactionally. IUserSessionStore is the counter's sole owner. Products implement IAccessTokenIssuer and enforce the counter on protected requests. Refresh-token replay evidence must remain until expiry.
Version 0.7.0 adds a separate complete opaque-token session adapter with cookie/CSRF and native bearer/binding profiles, atomic rotation and authoritative request validation. Its counter has one writer in the authentication/session store. It does not automatically adopt legacy sessions. Its X-Session-CSRF proof is distinct from the older antiforgery convention; preserve anonymous-write protection and explicitly configure product policies when adopting it. See strong authentication and sessions.
Verify the boundary
Exercise missing tokens, stale snapshots, forged forwarded headers, revoked keys, insufficient scopes and cross-tenant access through the actual host pipeline. These checks belong beside the product's authorization integration tests.
Next: strong authentication and Kernel HTTP API.