ccproxy.auth.storage¶
ccproxy.auth.storage
¶
Token storage implementations for authentication.
BaseJsonStorage
¶
Bases: TokenStorage[CredentialsT], Generic[CredentialsT]
Base class for JSON file storage implementations.
This class provides common JSON read/write operations with error handling, atomic writes, and proper permission management.
This is a generic class that can work with any credential type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path
|
Path to JSON file for storage |
required |
enable_backups
|
bool
|
Whether to create backups before overwriting |
True
|
Source code in ccproxy/auth/storage/base.py
exists
async
¶
Check if credentials file exists.
Returns:
| Type | Description |
|---|---|
bool
|
True if file exists, False otherwise |
Source code in ccproxy/auth/storage/base.py
delete
async
¶
Delete credentials file.
Returns:
| Type | Description |
|---|---|
bool
|
True if deleted successfully, False if file didn't exist |
Raises:
| Type | Description |
|---|---|
CredentialsStorageError
|
If file cannot be deleted |
Source code in ccproxy/auth/storage/base.py
get_location
¶
TokenStorage
¶
Bases: ABC, Generic[CredentialsT]
Abstract interface for token storage operations.
This is a generic interface that can work with any credential type that extends BaseModel (e.g., ClaudeCredentials, OpenAICredentials).
load
abstractmethod
async
¶
Load credentials from storage.
Returns:
| Type | Description |
|---|---|
CredentialsT | None
|
Parsed credentials if found and valid, None otherwise |
save
abstractmethod
async
¶
Save credentials to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credentials
|
CredentialsT
|
Credentials to save |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if saved successfully, False otherwise |
exists
abstractmethod
async
¶
Check if credentials exist in storage.
Returns:
| Type | Description |
|---|---|
bool
|
True if credentials exist, False otherwise |
delete
abstractmethod
async
¶
Delete credentials from storage.
Returns:
| Type | Description |
|---|---|
bool
|
True if deleted successfully, False otherwise |