auth
AzureCredentialAuth
¶
Bases: AuthBase
This Auth can be used with requests and an Azure Credential.
Source code in src/cloe_nessy/clients/api_client/auth.py
token
property
¶
Get a valid token using the TokenCredential.
__call__(r)
¶
Appends an Authorization header to the request using the provided Azure credential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
PreparedRequest
|
The request that needs to be sent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PreparedRequest |
PreparedRequest
|
The same request object but with an added Authorization header. |
Source code in src/cloe_nessy/clients/api_client/auth.py
__init__(scope, credential=None, client_id=None, client_secret=None, tenant_id=None)
¶
Initializes the AzureCredentialAuth with an Azure credential.
The client can either be initialized with a TokenCredential object or with the client_id, client_secret, and tenant_id via an ClientSecretCredential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
str
|
The scope for the token. E.g., the client ID of the Azure AD application. |
required |
credential
|
TokenCredential | ClientSecretCredential | None
|
The Azure credential object. |
None
|
client_id
|
str | None
|
The client ID for the Azure AD application. |
None
|
client_secret
|
str | None
|
The client secret for the Azure AD application. |
None
|
tenant_id
|
str | None
|
The tenant ID for the Azure AD application. |
None
|
Source code in src/cloe_nessy/clients/api_client/auth.py
ChainedAuth
¶
Bases: AuthBase
This Auth can be used to chain multiple Auths.
Source code in src/cloe_nessy/clients/api_client/auth.py
__call__(r)
¶
The header is constructed using the template and the secret retrieved from the secret scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
PreparedRequest
|
The request that needs to be sent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PreparedRequest |
PreparedRequest
|
The same request object, but with an added header. The header is constructed using the template and the secret retrieved from the secret scope. |
Source code in src/cloe_nessy/clients/api_client/auth.py
__init__(*args)
¶
Initializes the ChainedAuth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
One or more Auth objects that are chained to construct the auth header. |
()
|
Example:
auth_1 = SecretScopeAuth({"secret": "key"}, "my_secret_scope")
auth_2 = SecretScopeAuth({"secret": "key"}, "my_other_secret_scope")
chained_auth = ChainedAuth(auth_1, auth_2)
Source code in src/cloe_nessy/clients/api_client/auth.py
EnvVariableAuth
¶
Bases: AuthBase
This Auth can be used to create an auth header from environment variables.
Source code in src/cloe_nessy/clients/api_client/auth.py
__call__(r)
¶
The header is constructed using the template and the secret retrieved from the secret scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
PreparedRequest
|
The request that needs to be sent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PreparedRequest |
PreparedRequest
|
The same request object, but with an added header. The header is constructed using the template and the secret retrieved from environment variables. |
Source code in src/cloe_nessy/clients/api_client/auth.py
__init__(header_template)
¶
Initializes the EnvVariableAuth with a header template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header_template
|
dict[str, str]
|
The template for the header that will use the environment variables. variable names are defined as placeholders. |
required |
Example:
header_template = {
"user": "USER_NAME",
"password": "USER_SECRET",
}
auth = EnvVariableAuth(header_template)
# given, that "USER_NAME" and "USER_SECRET" are environment variables
Source code in src/cloe_nessy/clients/api_client/auth.py
SecretScopeAuth
¶
Bases: AuthBase
This Auth pulls Secrets from a Secret Scope.
Source code in src/cloe_nessy/clients/api_client/auth.py
__call__(r)
¶
The header is constructed using the template and the secret retrieved from the secret scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r
|
PreparedRequest
|
The request that needs to be sent. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PreparedRequest |
PreparedRequest
|
The same request object, but with an added header. The header is constructed using the template and the secret retrieved from the secret scope. |
Source code in src/cloe_nessy/clients/api_client/auth.py
__init__(header_template, secret_scope)
¶
Initializes the SecretScopeAuth with a header template, secret scope, and secret key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header_template
|
dict[str, str]
|
The template for the header that will use the secret. secret names are defined as placeholders in curly braces. |
required |
secret_scope
|
str
|
The secret scope from where the secrets will be retrieved. |
required |
Example:
header_template = {
"jfrog-user-key": "jfrog-user",
"jfrog-password-key": "jfrog-secret",
}
auth = SecretScopeAuth(header_template, "my_secret_scope")
# given, that 'jfrog-user' and 'jfrog-secret' are secrets in 'my_secret_scope'