Skip to main content

Crate phoenix_security

Crate phoenix_security 

Source
Expand description

Security middleware with production-safe defaults for Phoenix applications.

Structs§

AccessLog
Emits query-free structured access logs and never records header values.
ClientIp
The client address after applying the trusted proxy policy.
ClientIpRateLimitKey
Cors
Applies an explicit CORS allowlist and handles preflight requests.
CorsConfig
Cross-origin policy for browser requests.
Csrf
Synchronizer-token CSRF validation backed by the server-side session.
EffectiveScheme
Request scheme after direct TLS and trusted forwarding policy are applied.
HostAllowlist
Rejects requests whose HTTP Host or URI authority is not explicitly allowed.
HttpsRedirect
Redirect cleartext requests to a configured canonical HTTPS authority.
HttpsRedirectError
MemoryRateLimitBackend
Shared in-memory backend used for local development and backend contract tests.
MemorySessionBackend
Shared in-memory reference backend used by local applications and contract tests.
NonceSecurityPolicy
Request-scoped CSP nonce generation and browser security headers.
RateLimit
Distributed-capable fixed-window limiter with an atomic backend contract.
RateLimitConfig
Fixed-window rate limit configuration.
RateLimitDecision
Atomic result returned by a distributed rate-limit backend.
RateLimitStoreError
Error returned by a rate-limit backend without exposing backend details to clients.
RequestId
Adds a fresh unpredictable request ID to every request and response.
RequestIdValue
A request identifier available to controllers and logs.
SecurityPolicy
Configurable CSP, HSTS, and browser hardening headers.
Session
A cloneable handle to one server-side session.
SessionBackendError
Sanitized backend error. The detail is available to operators, not HTTP clients.
SessionConfig
Cookie settings for server-side sessions.
SessionMiddleware
Loads and persists server-side sessions through a secure ID cookie.
SessionSnapshot
Versioned server-side session state returned by a shared backend.
SessionStore
In-process server-side session store.
TrustedProxies
Resolves forwarding headers only when the direct peer is explicitly trusted.

Enums§

CspPolicyError
RateLimitFailureMode
SameSite
SessionWrite
Result of an atomic session mutation.

Traits§

RateLimitBackend
Shared backend contract. hit must increment and decide in one atomic operation.
RateLimitKey
Produces a bounded backend key from trusted request context.
SessionBackend
Distributed session contract.

Functions§

effective_scheme
Resolve the effective request scheme without trusting raw forwarding headers.
redact_headers
Return a diagnostic header map with credential-bearing values replaced.