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

Add RADIUS auth config dump #15126

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions awx/main/management/commands/dump_auth_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class Command(BaseCommand):
"USER_SEARCH": False,
}

DAB_RADIUS_AUTHENTICATOR_KEYS = {
"SERVER": True,
"PORT": False,
"SECRET": False,
}

def is_enabled(self, settings, keys):
missing_fields = []
for key, required in keys.items():
Expand Down Expand Up @@ -92,6 +98,13 @@ def get_awx_saml_settings(self) -> dict[str, Any]:

return awx_saml_settings

def get_awx_radius_settings(self) -> dict[str, Any]:
awx_radius_settings = {}
for awx_radius_setting in settings_registry.get_registered_settings(category_slug='radius'):
awx_radius_settings[awx_radius_setting.removeprefix("RADIUS_")] = getattr(settings, awx_radius_setting, None)

return awx_radius_settings

def format_config_data(self, enabled, awx_settings, type, keys, name):
config = {
"type": f"ansible_base.authentication.authenticator_plugins.{type}",
Expand Down Expand Up @@ -174,6 +187,22 @@ def handle(self, *args, **options):
else:
data.append({f"LDAP_{awx_ldap_name}_missing_fields": ldap_missing_fields})

# dump RADIUS settings
awx_radius_settings = self.get_awx_radius_settings()
awx_radius_enabled, radius_missing_fields = self.is_enabled(awx_radius_settings, self.DAB_RADIUS_AUTHENTICATOR_KEYS)
if awx_radius_enabled:
data.append(
self.format_config_data(
awx_radius_enabled,
awx_radius_settings,
"RADIUS",
self.DAB_RADIUS_AUTHENTICATOR_KEYS,
"RADIUS",
)
)
else:
data.append({"RADIUS_missing_fields": radius_missing_fields})

# write to file if requested
if options["output_file"]:
# Define the path for the output JSON file
Expand Down