ccproxy.auth.storage¶
ccproxy.auth.storage
¶
Token storage implementations for authentication.
TokenStorage
¶
Bases: ABC
Abstract interface for token storage operations.
load
abstractmethod
async
¶
Load credentials from storage.
Returns:
Type | Description |
---|---|
ClaudeCredentials | None
|
Parsed credentials if found and valid, None otherwise |
save
abstractmethod
async
¶
Save credentials to storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
ClaudeCredentials
|
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 |
JsonFileTokenStorage
¶
Bases: TokenStorage
JSON file storage implementation for Claude credentials with keyring fallback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
Path
|
Path to the JSON credentials file |
required |
Source code in ccproxy/auth/storage/json_file.py
load
async
¶
Load credentials from JSON file .
Returns:
Type | Description |
---|---|
ClaudeCredentials | None
|
Parsed credentials if found and valid, None otherwise |
Raises:
Type | Description |
---|---|
CredentialsInvalidError
|
If the JSON file is invalid |
CredentialsStorageError
|
If there's an error reading the file |
Source code in ccproxy/auth/storage/json_file.py
save
async
¶
Save credentials to both keyring and JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
ClaudeCredentials
|
Credentials to save |
required |
Returns:
Type | Description |
---|---|
bool
|
True if saved successfully, False otherwise |
Raises:
Type | Description |
---|---|
CredentialsStorageError
|
If there's an error writing the file |
Source code in ccproxy/auth/storage/json_file.py
exists
async
¶
Check if credentials file exists.
Returns:
Type | Description |
---|---|
bool
|
True if file exists, False otherwise |
delete
async
¶
Delete credentials from both keyring and file.
Returns:
Type | Description |
---|---|
bool
|
True if deleted successfully, False otherwise |
Raises:
Type | Description |
---|---|
CredentialsStorageError
|
If there's an error deleting the file |
Source code in ccproxy/auth/storage/json_file.py
KeyringTokenStorage
¶
Bases: TokenStorage
OS keyring storage implementation for Claude credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name
|
str
|
Name of the service in the keyring |
'claude-code-proxy'
|
username
|
str
|
Username to associate with the stored credentials |
'default'
|
Source code in ccproxy/auth/storage/keyring.py
load
async
¶
Load credentials from the OS keyring.
Returns:
Type | Description |
---|---|
ClaudeCredentials | None
|
Parsed credentials if found and valid, None otherwise |
Raises:
Type | Description |
---|---|
CredentialsStorageError
|
If the stored data is invalid |
CredentialsStorageError
|
If there's an error reading from keyring |
Source code in ccproxy/auth/storage/keyring.py
save
async
¶
Save credentials to the OS keyring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
ClaudeCredentials
|
Credentials to save |
required |
Returns:
Type | Description |
---|---|
bool
|
True if saved successfully, False otherwise |
Raises:
Type | Description |
---|---|
CredentialsStorageError
|
If there's an error writing to keyring |
Source code in ccproxy/auth/storage/keyring.py
exists
async
¶
Check if credentials exist in the keyring.
Returns:
Type | Description |
---|---|
bool
|
True if credentials exist, False otherwise |
Source code in ccproxy/auth/storage/keyring.py
delete
async
¶
Delete credentials from the keyring.
Returns:
Type | Description |
---|---|
bool
|
True if deleted successfully, False otherwise |
Raises:
Type | Description |
---|---|
CredentialsStorageError
|
If there's an error deleting from keyring |