fix: address reviewer comments

This commit is contained in:
Bruno Rocha 2025-07-28 18:54:16 +01:00 committed by thedoubl3j
parent 052166df39
commit 58e237a09a
No known key found for this signature in database
GPG Key ID: E84C42ACF75B0768
4 changed files with 14 additions and 17 deletions

View File

@ -513,7 +513,7 @@ class BaseAuthenticatorMigrator:
self._write_output(f' ✗ Unexpected error creating {mapper_type} mapper "{mapper_name}": {str(e)}', 'error')
return False
def get_social_org_map(self, authenticator_setting_name):
def get_social_org_map(self, authenticator_setting_name=None):
"""
Get social auth organization map with fallback to global setting.
@ -525,15 +525,15 @@ class BaseAuthenticatorMigrator:
dict: Organization mapping configuration, with fallback to global setting
"""
# Try authenticator-specific setting first
authenticator_map = getattr(settings, authenticator_setting_name, None)
if authenticator_map:
return authenticator_map
if authenticator_setting_name:
if authenticator_map := getattr(settings, authenticator_setting_name, None):
return authenticator_map
# Fall back to global setting
global_map = getattr(settings, 'SOCIAL_AUTH_ORGANIZATION_MAP', {})
return global_map
def get_social_team_map(self, authenticator_setting_name):
def get_social_team_map(self, authenticator_setting_name=None):
"""
Get social auth team map with fallback to global setting.
@ -545,9 +545,9 @@ class BaseAuthenticatorMigrator:
dict: Team mapping configuration, with fallback to global setting
"""
# Try authenticator-specific setting first
authenticator_map = getattr(settings, authenticator_setting_name, None)
if authenticator_map:
return authenticator_map
if authenticator_setting_name:
if authenticator_map := getattr(settings, authenticator_setting_name, None):
return authenticator_map
# Fall back to global setting
global_map = getattr(settings, 'SOCIAL_AUTH_TEAM_MAP', {})

View File

@ -41,8 +41,8 @@ class OIDCMigrator(BaseAuthenticatorMigrator):
verify_ssl = getattr(settings, "SOCIAL_AUTH_OIDC_VERIFY_SSL", True)
# Get organization and team mappings
org_map_value = self.get_social_org_map("SOCIAL_AUTH_OIDC_ORGANIZATION_MAP")
team_map_value = self.get_social_team_map("SOCIAL_AUTH_OIDC_TEAM_MAP")
org_map_value = self.get_social_org_map()
team_map_value = self.get_social_team_map()
# Convert org and team mappings from AWX to the Gateway format
# Start with order 1 and maintain sequence across both org and team mappers
@ -76,10 +76,9 @@ class OIDCMigrator(BaseAuthenticatorMigrator):
"""Create a generic OIDC authenticator in Gateway."""
category = config["category"]
config_settings = config["settings"]
name = config_settings["name"]
# Generate authenticator name and slug
authenticator_name = f"AWX-{category.replace(' ', '_').title()}-{name}"
authenticator_name = "oidc"
authenticator_slug = self._generate_authenticator_slug("oidc", category)
self._write_output(f"\n--- Processing {category} authenticator ---")

View File

@ -60,10 +60,9 @@ class RADIUSMigrator(BaseAuthenticatorMigrator):
"""Create a RADIUS authenticator in Gateway."""
category = config["category"]
config_settings = config["settings"]
name = config_settings["name"]
# Generate authenticator name and slug
authenticator_name = f"AWX-{category.replace('-', '_').title()}-{name}"
authenticator_name = "radius"
authenticator_slug = self._generate_authenticator_slug("radius", category)
self._write_output(f"\n--- Processing {category} authenticator ---")

View File

@ -66,11 +66,10 @@ class TACACSMigrator(BaseAuthenticatorMigrator):
"""Create a TACACS+ authenticator in Gateway."""
category = config["category"]
config_settings = config["settings"]
name = config_settings["name"]
# Generate authenticator name and slug
authenticator_name = f"AWX-{category.replace('+', 'plus').replace('-', '_').title()}-{name}"
authenticator_slug = self._generate_authenticator_slug("tacacsplus", category)
authenticator_name = "tacacs"
authenticator_slug = self._generate_authenticator_slug("tacacs", category)
self._write_output(f"\n--- Processing {category} authenticator ---")
self._write_output(f"Name: {authenticator_name}")