diff --git a/awx/sso/utils/base_migrator.py b/awx/sso/utils/base_migrator.py index 476e943c66..50468547c4 100644 --- a/awx/sso/utils/base_migrator.py +++ b/awx/sso/utils/base_migrator.py @@ -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', {}) diff --git a/awx/sso/utils/oidc_migrator.py b/awx/sso/utils/oidc_migrator.py index 92372906d4..1d4494e928 100644 --- a/awx/sso/utils/oidc_migrator.py +++ b/awx/sso/utils/oidc_migrator.py @@ -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 ---") diff --git a/awx/sso/utils/radius_migrator.py b/awx/sso/utils/radius_migrator.py index 1e8a6f7a96..e61702a109 100644 --- a/awx/sso/utils/radius_migrator.py +++ b/awx/sso/utils/radius_migrator.py @@ -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 ---") diff --git a/awx/sso/utils/tacacs_migrator.py b/awx/sso/utils/tacacs_migrator.py index 5ea6a5174a..5279c74fba 100644 --- a/awx/sso/utils/tacacs_migrator.py +++ b/awx/sso/utils/tacacs_migrator.py @@ -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}")