core
core ¶
Core authentication types and orchestration logic.
This module defines the core types and main orchestration function for the authentication provider system.
AuthMethod ¶
Bases: Enum
Enum identifying authentication methods.
AuthProvider ¶
Bases: Protocol
Protocol for implementing custom auth providers.
Any class implementing this protocol can be used as an auth provider.
Must have a method attribute and implement try_auth method.
Example
class CustomAuthProvider: def init(self): self.method = AuthMethod.CUSTOM
async def try_auth(self, **kwargs) -> dmda.DomoAuth | None:
# Your custom logic
return auth or None
try_auth
async
¶
try_auth(**kwargs) -> DomoAuth | None
Attempt authentication. Return None if this method unavailable or fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Provider-specific arguments |
{}
|
Returns:
| Type | Description |
|---|---|
DomoAuth | None
|
DomoAuth instance if successful, None otherwise |
Source code in src/crew_dcs/integrations/auth/core.py
68 69 70 71 72 73 74 75 76 77 78 | |
AuthResult
dataclass
¶
AuthResult(
auth: DomoAuth,
method: AuthMethod,
details: dict[str, Any],
)
Result of authentication with metadata about how it was obtained.
Attributes:
| Name | Type | Description |
|---|---|---|
auth |
DomoAuth
|
The authenticated DomoAuth instance |
method |
AuthMethod
|
Which authentication method succeeded |
details |
dict[str, Any]
|
Additional metadata (e.g., instance, account name, provider name) |
get_auth_with_providers
async
¶
get_auth_with_providers(
providers: list[AuthProvider] | None = None,
**auth_kwargs
) -> AuthResult
Try authentication providers in order until one succeeds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
providers
|
list[AuthProvider] | None
|
Ordered list of auth providers to try. If None, uses default set. |
None
|
**auth_kwargs
|
Arguments passed to each provider's try_auth method |
{}
|
Returns:
| Type | Description |
|---|---|
AuthResult
|
AuthResult with successful auth and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If all providers fail |
Example
Use default providers¶
result = await get_auth_with_providers(target_instance="my-instance") print(f"Authenticated via {result.method.value}")
Custom provider order¶
from crew_dcs.integrations.auth import ( EnvironmentAuthProvider, OnePasswordAuthProvider )
providers = [MyCustomProvider(), EnvironmentAuthProvider()] result = await get_auth_with_providers( providers=providers, target_instance="my-instance" )
Source code in src/crew_dcs/integrations/auth/core.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |