Skip to content

Commit

Permalink
Validate settings before running Pulp instance
Browse files Browse the repository at this point in the history
When token authentization is enabled, 4 additional variables have to be
set. The state of these variables is now checked, while properly
informing the user, instead of relying on exceptions raised later during
the instance's run.

closes pulp#1550
  • Loading branch information
MichalPysik committed Jun 21, 2024
1 parent ce05037 commit 813d401
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pulp_container/app/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.core.exceptions import ImproperlyConfigured

DRF_ACCESS_POLICY = {
"dynaconf_merge_unique": True,
"reusable_conditions": ["pulp_container.app.global_access_conditions"],
Expand All @@ -8,3 +10,14 @@

# The number of allowed threads to sign manifests in parallel
MAX_PARALLEL_SIGNING_TASKS = 10


from dynaconf import DjangoDynaconf, Validator

# Validate required settings
token_auth_enabled_validator = Validator("TOKEN_AUTH_DISABLED", eq=False)
token_server_validator = Validator("TOKEN_SERVER", ne="", when=token_auth_enabled_validator)
token_signature_algorithm_validator = Validator("TOKEN_SIGNATURE_ALGORITHM", ne="", when=token_auth_enabled_validator)
public_key_path_validator = Validator("PUBLIC_KEY_PATH", ne="", when=token_auth_enabled_validator)
private_key_path_validator = Validator("PRIVATE_KEY_PATH", ne="", when=token_auth_enabled_validator)

0 comments on commit 813d401

Please sign in to comment.