ccproxy.auth.dependencies¶
ccproxy.auth.dependencies
¶
FastAPI dependency injection for authentication.
get_credentials_auth_manager
async
¶
Get credentials-based authentication manager.
Returns:
Type | Description |
---|---|
AuthManager
|
CredentialsAuthManager instance |
get_bearer_auth_manager
async
¶
Get bearer token authentication manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
Annotated[HTTPAuthorizationCredentials | None, Depends(bearer_scheme)]
|
HTTP authorization credentials |
required |
Returns:
Type | Description |
---|---|
AuthManager
|
BearerTokenAuthManager instance |
Raises:
Type | Description |
---|---|
HTTPException
|
If no valid bearer token provided |
Source code in ccproxy/auth/dependencies.py
get_auth_manager
async
¶
Get authentication manager with fallback strategy.
Try bearer token first, then fall back to credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
Annotated[HTTPAuthorizationCredentials | None, Depends(bearer_scheme)]
|
HTTP authorization credentials |
None
|
Returns:
Type | Description |
---|---|
AuthManager
|
AuthManager instance |
Raises:
Type | Description |
---|---|
HTTPException
|
If no valid authentication available |
Source code in ccproxy/auth/dependencies.py
get_auth_manager_with_injected_settings
async
¶
Get authentication manager with dependency-injected settings.
This version uses FastAPI's dependency injection for settings, which allows test overrides to work properly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
Annotated[HTTPAuthorizationCredentials | None, Depends(bearer_scheme)]
|
HTTP authorization credentials |
None
|
settings
|
Application settings (injected by FastAPI) |
required |
Returns:
Type | Description |
---|---|
AuthManager
|
AuthManager instance |
Raises:
Type | Description |
---|---|
HTTPException
|
If no valid authentication available |
Source code in ccproxy/auth/dependencies.py
require_auth
async
¶
Require authentication for endpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auth_manager
|
Annotated[AuthManager, Depends(get_auth_manager)]
|
Authentication manager |
required |
Returns:
Type | Description |
---|---|
AuthManager
|
AuthManager instance |
Raises:
Type | Description |
---|---|
HTTPException
|
If authentication fails |
Source code in ccproxy/auth/dependencies.py
get_access_token
async
¶
Get access token from authenticated manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auth_manager
|
Annotated[AuthManager, Depends(require_auth)]
|
Authentication manager |
required |
Returns:
Type | Description |
---|---|
str
|
Access token string |
Raises:
Type | Description |
---|---|
HTTPException
|
If token retrieval fails |
Source code in ccproxy/auth/dependencies.py
get_auth_manager_dependency
async
¶
Dependency wrapper for getting auth manager with settings injection.