Skip to content

Configuration

The TendukeConfig class can be used to set configuration values. It can additionally read configuration items from a file or environment variables.

Configuration properties for interacting with licensing and oauth / open ID connect.

Attributes:

Name Type Description
token_path str

Location on disk to save license tokens.

public_key_path str

Location on disk to save public keys.

licensing_api_url str

Protocol and host name for API tenant.

token_refresh_leeway_seconds float

The number of seconds before expiry time that an ID Token or JWT will be automatically refreshed.

http_timeout_seconds float

Timeout for HTTP requests.

licensing_api_authorization_model str | None

Method of authorization used for API calls.

idp_oidc_discovery_url str | None

Used to retrieve the details of the Open ID Connect endpoints for the identity provider.

idp_oauth_authorization_url str | None

Endpoint for Authorization Request in Authorization Code or Implicit Grant flows.

idp_oauth_device_code_url str | None

Endpoint for Device Authorization Request in Device Authorization Grant flow.

idp_oauth_token_url str | None

Endpoint for Access Token Request or Device Access Token Request.

idp_oauth_client_id str | None

Application credentials for OAuth/Open ID Connect.

idp_userinfo_url str | None

Endpoint handling the UserInfo Request.

idp_oauth_client_secret str | None

Application credentials for OAuth/Open ID Connect. Required for some OAuth flows or for some Identity Providers.

idp_oauth_scope str | None

Scopes to include in the Access and ID tokens requested via Open ID Connect.

idp_jwks_uri str | None

URL path to read public key used to verify JWTs received from Authorization Server authenticating Open ID Connect session.

auth_redirect_uri str | None

Fully specified URL for OAuth redirect_uri to listen for redirect during PKCE Flow.

auth_redirect_path str

Redirect path fragment to listen for redirect during PKCE Flow. For desktop clients, this path will be appended to http://localhost (either on the specified port or a random ephemeral port). This fragment is ignored if auth_redirect_uri is specified.

auth_redirect_port int

Local redirect port to listen on for PKCE Flow Client.

auth_success_message str | None

File containing response for successful login (see PKCE Flow Client).

https_proxy str | None

Proxy to use for HTTPS requests.

Source code in tenduke_core/config/tenduke_config.py
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
@dataclass
class TendukeConfig:
    """Configuration properties for interacting with licensing and oauth / open ID connect.

    Attributes:
        token_path: Location on disk to save license tokens.
        public_key_path: Location on disk to save public keys.
        licensing_api_url: Protocol and host name for API tenant.
        token_refresh_leeway_seconds:
            The number of seconds before expiry time that an ID Token or JWT will be
            automatically refreshed.
        http_timeout_seconds: Timeout for HTTP requests.
        licensing_api_authorization_model: Method of authorization used for API calls.
        idp_oidc_discovery_url:
            Used to retrieve the details of the Open ID Connect endpoints for the identity
            provider.
        idp_oauth_authorization_url:
            Endpoint for Authorization Request in Authorization Code or Implicit Grant flows.
        idp_oauth_device_code_url:
            Endpoint for Device Authorization Request in Device Authorization Grant flow.
        idp_oauth_token_url: Endpoint for Access Token Request or Device Access Token Request.
        idp_oauth_client_id: Application credentials for OAuth/Open ID Connect.
        idp_userinfo_url: Endpoint handling the UserInfo Request.
        idp_oauth_client_secret:
            Application credentials for OAuth/Open ID Connect. Required for some OAuth flows or for
            some Identity Providers.
        idp_oauth_scope:
            Scopes to include in the Access and ID tokens requested via Open ID Connect.
        idp_jwks_uri:
            URL path to read public key used to verify JWTs received from Authorization Server
            authenticating Open ID Connect session.
        auth_redirect_uri:
            Fully specified URL for OAuth redirect_uri to listen for redirect during PKCE Flow.
        auth_redirect_path:
            Redirect path fragment to listen for redirect during PKCE Flow. For desktop clients,
            this path will be appended to http://localhost (either on the specified port or a random
            ephemeral port). This fragment is ignored if auth_redirect_uri is specified.
        auth_redirect_port: Local redirect port to listen on for PKCE Flow Client.
        auth_success_message: File containing response for successful login (see PKCE Flow Client).
        https_proxy: Proxy to use for HTTPS requests.
    """

    token_path: str
    public_key_path: str
    licensing_api_url: str
    token_refresh_leeway_seconds: float = 30.0
    http_timeout_seconds: float = 30.0
    auth_redirect_path: str = "/login/callback"
    auth_redirect_port: int = 0
    auth_redirect_uri: str | None = None
    licensing_api_authorization_model: str | None = None
    idp_oidc_discovery_url: str | None = None
    idp_oauth_authorization_url: str | None = None
    idp_oauth_device_code_url: str | None = None
    idp_oauth_token_url: str | None = None
    idp_oauth_client_id: str | None = None
    idp_userinfo_url: str | None = None
    idp_oauth_client_secret: str | None = None
    idp_oauth_scope: str | None = None
    idp_jwks_uri: str | None = None
    auth_success_message: str | None = None
    https_proxy: str | None = None

    @classmethod
    def load(
        cls: type["TendukeConfig"],
        prefix: str | None = None,
        file_name: str | None = None,
        **kwargs,
    ) -> "TendukeConfig":
        """Load the configuration.

        Priority order for configuration values:
        - environment variables
        - configuration file
        - kwargs

        Args:
            prefix: Optionally override default prefix for environment variables.
            file_name: Configuration file to load.
        """
        config_builder = dataconf.multi.dict(kwargs)

        if file_name:
            config_builder = config_builder.file(file_name)

        if prefix:
            config_builder = config_builder.env(prefix)

        config = config_builder.on(TendukeConfig)
        return config  # pyright: ignore[reportReturnType]

load(prefix=None, file_name=None, **kwargs) classmethod

Load the configuration.

Priority order for configuration values: - environment variables - configuration file - kwargs

Parameters:

Name Type Description Default
prefix str | None

Optionally override default prefix for environment variables.

None
file_name str | None

Configuration file to load.

None
Source code in tenduke_core/config/tenduke_config.py
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
@classmethod
def load(
    cls: type["TendukeConfig"],
    prefix: str | None = None,
    file_name: str | None = None,
    **kwargs,
) -> "TendukeConfig":
    """Load the configuration.

    Priority order for configuration values:
    - environment variables
    - configuration file
    - kwargs

    Args:
        prefix: Optionally override default prefix for environment variables.
        file_name: Configuration file to load.
    """
    config_builder = dataconf.multi.dict(kwargs)

    if file_name:
        config_builder = config_builder.file(file_name)

    if prefix:
        config_builder = config_builder.env(prefix)

    config = config_builder.on(TendukeConfig)
    return config  # pyright: ignore[reportReturnType]