Files
bdinvite/backend/app/auth/port.py
T
kiskaadee 8ce9a73176 refactor(auth): enforce ruff and pyright standards, add router-level auth, and enhance logged-out UI
- Apply repository standards for ruff check and ruff format across backend
- Enforce strict typing annotations (PEP 604) for pyright compliance
- Add router-level dependency protection to admin.py (dependencies=[Depends(require_admin)])
- Incorporate dedicated logged-out UI screen in AdminLayout.tsx
- Update browser SSO acceptance test to verify the logged-out state and re-login
2026-10-07 06:48:57 -05:00

33 lines
1.0 KiB
Python

from typing import Protocol, runtime_checkable
from fastapi import Request, Response
from .identity import Identity
@runtime_checkable
class AuthPort(Protocol):
"""Hexagonal Port for Authentication and Identity Management.
Establishes the boundary between application domain logic and concrete authentication
mechanisms (such as OIDC, OAuth, ForwardAuth, or session providers).
"""
def current_identity(self, request: Request) -> Identity | None:
"""Resolve the validated identity associated with the incoming request.
Returns None if the request is unauthenticated or credentials/session are invalid.
"""
...
def login(self, request: Request) -> Response:
"""Initiate the login flow (e.g. redirect to identity provider or challenge response)."""
...
def logout(self, request: Request) -> Response:
"""Terminate the session or logout flow (e.g. invalidate session cookie or IdP logout redirect)."""
...
__all__ = ["AuthPort", "Identity"]