-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathauth.py
More file actions
49 lines (38 loc) · 1.58 KB
/
auth.py
File metadata and controls
49 lines (38 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
"""Authentication-related constants and utilities for the Airbyte Cloud."""
from airbyte import constants
from airbyte.secrets import SecretString
from airbyte.secrets.util import get_secret, try_get_secret
def resolve_cloud_client_secret(
input_value: str | SecretString | None = None,
/,
) -> SecretString:
"""Get the Airbyte Cloud client secret from the environment."""
return get_secret(constants.CLOUD_CLIENT_SECRET_ENV_VAR, default=input_value)
def resolve_cloud_client_id(
input_value: str | SecretString | None = None,
/,
) -> SecretString:
"""Get the Airbyte Cloud client ID from the environment."""
return get_secret(constants.CLOUD_CLIENT_ID_ENV_VAR, default=input_value)
def resolve_cloud_bearer_token(
input_value: str | SecretString | None = None,
/,
) -> SecretString | None:
"""Get the Airbyte Cloud bearer token from the environment."""
return try_get_secret(constants.CLOUD_BEARER_TOKEN_ENV_VAR, default=input_value)
def resolve_cloud_api_url(
input_value: str | None = None,
/,
) -> str:
"""Get the Airbyte Cloud API URL from the environment, or return the default."""
return str(
try_get_secret(constants.CLOUD_API_ROOT_ENV_VAR, default=input_value)
or constants.CLOUD_API_ROOT
)
def resolve_cloud_workspace_id(
input_value: str | None = None,
/,
) -> str:
"""Get the Airbyte Cloud workspace ID from the environment, or return None if not set."""
return str(get_secret(constants.CLOUD_WORKSPACE_ID_ENV_VAR, default=input_value))