Skip to main content

Module security

Module security 

Source
Expand description

Security utilities for admin panel

This module provides security-related functionality including:

  • CSP and security response headers
  • CSRF token generation and validation
  • XSS prevention helpers for mutation data

Structs§

ContentSecurityPolicy
Content Security Policy configuration for admin panel.
SecurityHeaders
Security headers for admin panel responses.

Enums§

FrameOptions
X-Frame-Options header values
ReferrerPolicy
Referrer-Policy header values

Constants§

ADMIN_AUTH_COOKIE_NAME
The cookie name used for admin JWT authentication.
CSRF_COOKIE_NAME
The cookie name used for CSRF token storage (double-submit cookie pattern).
CSRF_HEADER_NAME
The header name used for CSRF token submission.
PAGES_CSRF_HEADER_NAME
Header spelling used by reinhardt_pages::csrf::csrf_headers.

Functions§

build_admin_auth_cookie
Builds a Set-Cookie header value for the admin authentication JWT.
build_admin_auth_cookie_clear
Builds a Set-Cookie header value that clears the admin authentication cookie.
build_csrf_cookie
Builds a Set-Cookie header value for the CSRF token.
extract_admin_auth_cookieNon-WebAssembly
Extracts the admin JWT token from the Cookie header.
extract_csrf_cookieserver
Extracts the CSRF token from the csrftoken cookie.
extract_csrf_headerserver
Extracts the CSRF token from the X-CSRF-Token request header.
generate_csrf_token
Generates a cryptographically secure CSRF token.
require_csrf_headerserver
Validates CSRF using the X-CSRFToken request header as the provided token.
require_csrf_tokenserver
Validates CSRF tokens using the double-submit cookie pattern.
sanitize_mutation_valuesserver
Sanitizes mutation data values to prevent stored XSS.
validate_csrf_token
Validates a CSRF token against the expected value using constant-time comparison.