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§
- Content
Security Policy - Content Security Policy configuration for admin panel.
- Security
Headers - Security headers for admin panel responses.
Enums§
- Frame
Options - X-Frame-Options header values
- Referrer
Policy - 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-Cookieheader value for the admin authentication JWT. - build_
admin_ auth_ cookie_ clear - Builds a
Set-Cookieheader value that clears the admin authentication cookie. - build_
csrf_ cookie - Builds a
Set-Cookieheader value for the CSRF token. - extract_
admin_ auth_ cookie Non-WebAssembly - Extracts the admin JWT token from the
Cookieheader. - extract_
csrf_ cookie server - Extracts the CSRF token from the
csrftokencookie. - extract_
csrf_ header server - Extracts the CSRF token from the
X-CSRF-Tokenrequest header. - generate_
csrf_ token - Generates a cryptographically secure CSRF token.
- require_
csrf_ header server - Validates CSRF using the
X-CSRFTokenrequest header as the provided token. - require_
csrf_ token server - Validates CSRF tokens using the double-submit cookie pattern.
- sanitize_
mutation_ values server - Sanitizes mutation data values to prevent stored XSS.
- validate_
csrf_ token - Validates a CSRF token against the expected value using constant-time comparison.