diff --git a/generate_env.py b/generate_env.py index eba6d7d87b..c370503969 100644 --- a/generate_env.py +++ b/generate_env.py @@ -1,43 +1,43 @@ import os + import hvac # Configuration for Vault -VAULT_ADDR = 'http://localhost:8200' -VAULT_OIDC_CLIENT_ID = 'your_oidc_client_id' -VAULT_OIDC_ISSUER_URL = 'https://your-oidc-issuer-url' +VAULT_ADDR = "http://localhost:8200" +VAULT_OIDC_CLIENT_ID = "your_oidc_client_id" +VAULT_OIDC_ISSUER_URL = "https://your-oidc-issuer-url" # Static variables -STATIC_VARIABLES = { - 'API_KEY': 'static_api_key', - 'DATABASE_URL': 'static_database_url' -} +STATIC_VARIABLES = {"API_KEY": "static_api_key", "DATABASE_URL": "static_database_url"} + def get_secret_from_vault(path): client = hvac.Client(url=VAULT_ADDR) - token = client.auth.oidc.login( - role='your_oidc_role', - jwt=os.environ['JWT'] - )['auth']['client_token'] - + token = client.auth.oidc.login(role="your_oidc_role", jwt=os.environ["JWT"])[ + "auth" + ]["client_token"] + client.token = token - secret = client.secrets.kv.v2.read_secret_version(path=path)['data']['data'] + secret = client.secrets.kv.v2.read_secret_version(path=path)["data"]["data"] return secret + def generate_env_file(env_path): - with open(env_path, 'w') as env_file: + with open(env_path, "w") as env_file: for key, value in STATIC_VARIABLES.items(): env_file.write(f"{key}={value}\n") - + # Add secrets from Vault vault_secrets = { - 'SECRET_KEY': get_secret_from_vault('secret/key'), - 'PASSWORD': get_secret_from_vault('secret/password') + "SECRET_KEY": get_secret_from_vault("secret/key"), + "PASSWORD": get_secret_from_vault("secret/password"), } - + for key, value in vault_secrets.items(): env_file.write(f"{key}={value}\n") -if __name__ == '__main__': - env_path = '.env' + +if __name__ == "__main__": + env_path = ".env" generate_env_file(env_path) print(f"Environment file generated at {env_path}") diff --git a/poetry.lock b/poetry.lock index 1f1b8fd646..dfc39888f7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1470,20 +1470,19 @@ files = [ [[package]] name = "django-oauth-toolkit" -version = "2.4.0" +version = "3.0.1" description = "OAuth2 Provider for Django" optional = false python-versions = ">=3.8" files = [ - {file = "django_oauth_toolkit-2.4.0-py3-none-any.whl", hash = "sha256:4931d6bf64b6aee32a42f989f218769d1876f3daa53c6bf883d8ab793fb302ee"}, - {file = "django_oauth_toolkit-2.4.0.tar.gz", hash = "sha256:8975eaf697413a8d54208ee068bc5ad6d1ed76f1df84e4882fbb25e7e6966e1b"}, + {file = "django_oauth_toolkit-3.0.1-py3-none-any.whl", hash = "sha256:3ef00b062a284f2031b0732b32dc899e3bbf0eac221bbb1cffcb50b8932e55ed"}, + {file = "django_oauth_toolkit-3.0.1.tar.gz", hash = "sha256:7200e4a9fb229b145a6d808cbf0423b6d69a87f68557437733eec3c0cf71db02"}, ] [package.dependencies] -django = ">=3.2,<4.0.0 || >4.0.0" -jwcrypto = ">=0.8.0" -oauthlib = ">=3.1.0" -pytz = ">=2024.1" +django = ">=4.2" +jwcrypto = ">=1.5.0" +oauthlib = ">=3.2.2" requests = ">=2.13.0" [[package]] @@ -7251,4 +7250,4 @@ testing = ["coverage[toml]", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = "3.12.6" -content-hash = "8800aef8544c66b32596bbe7c95a998ca8b26965b007247bd6bb139387b4fd70" +content-hash = "51fb373daee579f3b54160873f56dba6986dff67b8bc01d825bc82c5f3f4d63b" diff --git a/pyproject.toml b/pyproject.toml index 7290ab5ca8..c553c10667 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ pluggy = "^1.3.0" named-enum = "^1.4.0" drf-nested-routers = "^0.94.0" django-scim2 = "^0.19.1" -django-oauth-toolkit = "^2.3.0" +django-oauth-toolkit = "^3.0.0" youtube-transcript-api = "^0.6.2" posthog = "^3.5.0" ruff = "0.8.3"