Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add *-secret-key-id charm configuration for flask, django, golang and fastapi framework charms #2160

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions charmcraft/extensions/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ class FlaskFramework(_AppBase):
"type": "string",
"description": "The secret key used for securely signing the session cookie and for any other security related needs by your Flask application. This configuration will set the FLASK_SECRET_KEY environment variable. Run `app.config.from_prefixed_env()` in your Flask application in order to receive this configuration.",
},
"flask-secret-key-id": {
"type": "secret",
"description": "This configuration is similar to `flask-secret-key`, but instead accepts a Juju user secret ID. "
'The secret should contain a single key, "value", which maps to the actual Flask secret key. '
"To create the secret, run the following command: `juju add-secret my-flask-secret-key value=<secret-string> && juju grant-secret my-flask-secret-key flask-k8s`, "
"and use the output secret ID to configure this option.",
},
"flask-session-cookie-secure": {
"type": "boolean",
"description": "Set the secure attribute in the Flask application cookies. This configuration will set the FLASK_SESSION_COOKIE_SECURE environment variable. Run `app.config.from_prefixed_env()` in your Flask application in order to receive this configuration.",
Expand Down Expand Up @@ -277,6 +284,13 @@ class DjangoFramework(_AppBase):
"type": "string",
"description": "The secret key used for securely signing the session cookie and for any other security related needs by your Django application. This configuration will set the DJANGO_SECRET_KEY environment variable.",
},
"django-secret-key-id": {
"type": "secret",
"description": "This configuration is similar to `django-secret-key`, but instead accepts a Juju user secret ID. "
'The secret should contain a single key, "value", which maps to the actual Django secret key. '
"To create the secret, run the following command: `juju add-secret my-django-secret-key value=<secret-string> && juju grant-secret my-django-secret-key django-k8s`, "
"and use the output secret ID to configure this option.",
},
"django-allowed-hosts": {
"type": "string",
"description": "A comma-separated list of host/domain names that this Django site can serve. This configuration will set the DJANGO_ALLOWED_HOSTS environment variable with its content being a JSON encoded list.",
Expand Down Expand Up @@ -314,6 +328,13 @@ class GoFramework(_AppBase):
"type": "string",
"description": "Long secret you can use for sessions, csrf or any other thing where you need a random secret shared by all units",
},
"app-secret-key-id": {
"type": "secret",
"description": "This configuration is similar to `app-secret-key`, but instead accepts a Juju user secret ID. "
'The secret should contain a single key, "value", which maps to the actual application secret key. '
"To create the secret, run the following command: `juju add-secret my-app-secret-key value=<secret-string> && juju grant-secret my-app-secret-key go-app`, "
"and use the output secret ID to configure this option.",
},
}

@staticmethod
Expand Down Expand Up @@ -367,6 +388,13 @@ class FastAPIFramework(_AppBase):
"type": "string",
"description": "Long secret you can use for sessions, csrf or any other thing where you need a random secret shared by all units",
},
"app-secret-key-id": {
"type": "secret",
"description": "This configuration is similar to `app-secret-key`, but instead accepts a Juju user secret ID. "
'The secret should contain a single key, "value", which maps to the actual application secret key. '
"To create the secret, run the following command: `juju add-secret my-app-secret-key value=<secret-string> && juju grant-secret my-app-secret-key fastapi-app`, "
"and use the output secret ID to configure this option.",
},
}

@staticmethod
Expand Down
Loading