- Reject forged, replayed, and expired CSRF state with HTTP 400 Bad Request - Enforce cryptographic validation rejecting tampered ID token signatures and mismatched/missing nonces with HTTP 401 Unauthorized - Reject missing, invalid, or mismatched PKCE code_verifier with HTTP 401 Unauthorized (InvalidCodeVerifierError) - Invalidate expired ID tokens and session cookies returning HTTP 401 Unauthorized - Enforce role-based access control blocking authenticated non-admin users from admin APIs with HTTP 403 Forbidden - Eliminate legacy Remote-User trust ensuring session identity strictly governs authorization - Document and verify dual deployment modes (Standalone Mode vs Homelab Production Mode behind Traefik TLS proxy) - Add comprehensive security hardening regression suite (tests/test_security_hardening.py) and .env.example template - Ensure clean multi-stage Docker build
69 lines
1.5 KiB
Python
69 lines
1.5 KiB
Python
"""Authentication package providing domain models, hexagonal ports, and OIDC client."""
|
|
|
|
from .dependencies import (
|
|
AdminUserDep,
|
|
AuthAdapterDep,
|
|
AuthenticatedUserDep,
|
|
CurrentIdentityDep,
|
|
get_auth_adapter,
|
|
get_current_identity,
|
|
require_admin,
|
|
require_authenticated,
|
|
require_group,
|
|
set_auth_adapter,
|
|
)
|
|
from .oidc import (
|
|
InvalidCodeVerifierError,
|
|
InvalidNonceError,
|
|
InvalidStateError,
|
|
OIDCAuthAdapter,
|
|
OIDCClient,
|
|
OIDCConfig,
|
|
OIDCDiscovery,
|
|
OIDCError,
|
|
OIDCTransaction,
|
|
SessionRecord,
|
|
TokenValidationError,
|
|
claims_to_identity,
|
|
extract_identity_from_claims,
|
|
generate_code_challenge,
|
|
generate_code_verifier,
|
|
generate_nonce,
|
|
generate_state,
|
|
resolve_claim_path,
|
|
)
|
|
from .port import AuthPort, Identity
|
|
|
|
__all__ = [
|
|
"AdminUserDep",
|
|
"AuthAdapterDep",
|
|
"AuthPort",
|
|
"AuthenticatedUserDep",
|
|
"CurrentIdentityDep",
|
|
"Identity",
|
|
"InvalidCodeVerifierError",
|
|
"InvalidNonceError",
|
|
"InvalidStateError",
|
|
"OIDCAuthAdapter",
|
|
"OIDCClient",
|
|
"OIDCConfig",
|
|
"OIDCDiscovery",
|
|
"OIDCError",
|
|
"OIDCTransaction",
|
|
"SessionRecord",
|
|
"TokenValidationError",
|
|
"claims_to_identity",
|
|
"extract_identity_from_claims",
|
|
"generate_code_challenge",
|
|
"generate_code_verifier",
|
|
"generate_nonce",
|
|
"generate_state",
|
|
"get_auth_adapter",
|
|
"get_current_identity",
|
|
"require_admin",
|
|
"require_authenticated",
|
|
"require_group",
|
|
"resolve_claim_path",
|
|
"set_auth_adapter",
|
|
]
|