Skip to content

Commit

Permalink
Merge pull request ckan#8468 from ckan/8467-beaker-session-warnings
Browse files Browse the repository at this point in the history
[ckan#8467] Use legacy_key in SECRET_KEY fallback
  • Loading branch information
wardi authored Oct 3, 2024
2 parents 7e5f6a8 + 0ae06ff commit a151eff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/8468.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unnecessary beaker.session.secret warning
2 changes: 1 addition & 1 deletion ckan/config/config_declaration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ groups:
placeholder: egg:ckan

- key: SECRET_KEY
legacy_key: beaker.session.secret
validators: not_empty
required: true
placeholder_callable: secrets:token_urlsafe
callable_args:
nbytes: 20
validators: configured_default("beaker.session.secret",None)
description: |
This is the secret token that is used by security related tasks by CKAN and its extensions.
``ckan generate config`` generates a unique
Expand Down
10 changes: 10 additions & 0 deletions ckan/tests/config/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,13 @@ def test_all_secrets_default_to_SECRET_KEY(ckan_config):
assert ckan_config[key] == "super_secret"

# Note: api_token.jwt.*.secret are tested in ckan/tests/lib/test_api_token.py


@pytest.mark.ckan_config("beaker.session.secret", "super_secret")
def test_SECRET_KEY_falls_back_to_beaker_session_secret(ckan_config, monkeypatch):

monkeypatch.delitem(ckan_config, "SECRET_KEY")

environment.update_config()

assert ckan_config["SECRET_KEY"] == "super_secret"

0 comments on commit a151eff

Please sign in to comment.