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 OIDC auth config dump #15131

Open
wants to merge 4 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 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,13 @@ class Command(BaseCommand):
"USER_SEARCH": False,
}

DAB_OIDC_AUTHENTICATOR_KEYS = {
"KEY": True,
"SECRET": False,
"OIDC_ENDPOINT": True,
"VERIFY_SSL": False,
}

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

return awx_saml_settings

def get_awx_oidc_settings(self) -> dict[str, Any]:
awx_oidc_settings = {}
for awx_oidc_setting in settings_registry.get_registered_settings(category_slug='oidc'):
awx_oidc_settings[awx_oidc_setting.removeprefix("SOCIAL_AUTH_OIDC_")] = getattr(settings, awx_oidc_setting, None)

return awx_oidc_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 +188,22 @@ def handle(self, *args, **options):
else:
data.append({f"LDAP_{awx_ldap_name}_missing_fields": ldap_missing_fields})

# dump OIDC settings
awx_oidc_settings = self.get_awx_oidc_settings()
awx_oidc_enabled, oidc_missing_fields = self.is_enabled(awx_oidc_settings, self.DAB_OIDC_AUTHENTICATOR_KEYS)
if awx_oidc_enabled:
data.append(
self.format_config_data(
awx_oidc_enabled,
awx_oidc_settings,
"open_id_connect",
self.DAB_OIDC_AUTHENTICATOR_KEYS,
"OIDC",
)
)
else:
data.append({"OIDC_missing_fields": oidc_missing_fields})

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