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 25, 2024
1 parent ce05037 commit 723a3b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/1550.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pulp Container specific settings are now properly validated at startup of a Pulp instance.
16 changes: 16 additions & 0 deletions pulp_container/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from pulpcore.plugin import PulpPluginAppConfig
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured


class PulpContainerPluginAppConfig(PulpPluginAppConfig):
Expand All @@ -11,3 +13,17 @@ class PulpContainerPluginAppConfig(PulpPluginAppConfig):

def ready(self):
super().ready()

# Checks only needed if token auth is enabled
if str(getattr(settings, 'TOKEN_AUTH_DISABLED', False)).lower() == 'true':
return

missing_settings = []
if getattr(settings, 'TOKEN_SERVER', None) is None:
raise ImproperlyConfigured("TODO TOKEN SERVER")
if getattr(settings, 'TOKEN_SIGNATURE_ALGORITHM', None) is None:
raise ImproperlyConfigured("TODO SIGNATURE ALGORITHM")
if getattr(settings, 'PUBLIC_KEY_PATH', None) is None:
raise ImproperlyConfigured("TODO PUBLIC KEY PATH")
if getattr(settings, 'PRIVATE_KEY_PATH', None) is None:
raise ImproperlyConfigured("TODO PRIVATE KEY PATH")

0 comments on commit 723a3b4

Please sign in to comment.