mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 19:50:05 -03:30
fix: address reviewer comments
This commit is contained in:
@@ -513,7 +513,7 @@ class BaseAuthenticatorMigrator:
|
|||||||
self._write_output(f' ✗ Unexpected error creating {mapper_type} mapper "{mapper_name}": {str(e)}', 'error')
|
self._write_output(f' ✗ Unexpected error creating {mapper_type} mapper "{mapper_name}": {str(e)}', 'error')
|
||||||
return False
|
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.
|
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
|
dict: Organization mapping configuration, with fallback to global setting
|
||||||
"""
|
"""
|
||||||
# Try authenticator-specific setting first
|
# Try authenticator-specific setting first
|
||||||
authenticator_map = getattr(settings, authenticator_setting_name, None)
|
if authenticator_setting_name:
|
||||||
if authenticator_map:
|
if authenticator_map := getattr(settings, authenticator_setting_name, None):
|
||||||
return authenticator_map
|
return authenticator_map
|
||||||
|
|
||||||
# Fall back to global setting
|
# Fall back to global setting
|
||||||
global_map = getattr(settings, 'SOCIAL_AUTH_ORGANIZATION_MAP', {})
|
global_map = getattr(settings, 'SOCIAL_AUTH_ORGANIZATION_MAP', {})
|
||||||
return global_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.
|
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
|
dict: Team mapping configuration, with fallback to global setting
|
||||||
"""
|
"""
|
||||||
# Try authenticator-specific setting first
|
# Try authenticator-specific setting first
|
||||||
authenticator_map = getattr(settings, authenticator_setting_name, None)
|
if authenticator_setting_name:
|
||||||
if authenticator_map:
|
if authenticator_map := getattr(settings, authenticator_setting_name, None):
|
||||||
return authenticator_map
|
return authenticator_map
|
||||||
|
|
||||||
# Fall back to global setting
|
# Fall back to global setting
|
||||||
global_map = getattr(settings, 'SOCIAL_AUTH_TEAM_MAP', {})
|
global_map = getattr(settings, 'SOCIAL_AUTH_TEAM_MAP', {})
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class OIDCMigrator(BaseAuthenticatorMigrator):
|
|||||||
verify_ssl = getattr(settings, "SOCIAL_AUTH_OIDC_VERIFY_SSL", True)
|
verify_ssl = getattr(settings, "SOCIAL_AUTH_OIDC_VERIFY_SSL", True)
|
||||||
|
|
||||||
# Get organization and team mappings
|
# Get organization and team mappings
|
||||||
org_map_value = self.get_social_org_map("SOCIAL_AUTH_OIDC_ORGANIZATION_MAP")
|
org_map_value = self.get_social_org_map()
|
||||||
team_map_value = self.get_social_team_map("SOCIAL_AUTH_OIDC_TEAM_MAP")
|
team_map_value = self.get_social_team_map()
|
||||||
|
|
||||||
# Convert org and team mappings from AWX to the Gateway format
|
# Convert org and team mappings from AWX to the Gateway format
|
||||||
# Start with order 1 and maintain sequence across both org and team mappers
|
# 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."""
|
"""Create a generic OIDC authenticator in Gateway."""
|
||||||
category = config["category"]
|
category = config["category"]
|
||||||
config_settings = config["settings"]
|
config_settings = config["settings"]
|
||||||
name = config_settings["name"]
|
|
||||||
|
|
||||||
# Generate authenticator name and slug
|
# Generate authenticator name and slug
|
||||||
authenticator_name = f"AWX-{category.replace(' ', '_').title()}-{name}"
|
authenticator_name = "oidc"
|
||||||
authenticator_slug = self._generate_authenticator_slug("oidc", category)
|
authenticator_slug = self._generate_authenticator_slug("oidc", category)
|
||||||
|
|
||||||
self._write_output(f"\n--- Processing {category} authenticator ---")
|
self._write_output(f"\n--- Processing {category} authenticator ---")
|
||||||
|
|||||||
@@ -60,10 +60,9 @@ class RADIUSMigrator(BaseAuthenticatorMigrator):
|
|||||||
"""Create a RADIUS authenticator in Gateway."""
|
"""Create a RADIUS authenticator in Gateway."""
|
||||||
category = config["category"]
|
category = config["category"]
|
||||||
config_settings = config["settings"]
|
config_settings = config["settings"]
|
||||||
name = config_settings["name"]
|
|
||||||
|
|
||||||
# Generate authenticator name and slug
|
# Generate authenticator name and slug
|
||||||
authenticator_name = f"AWX-{category.replace('-', '_').title()}-{name}"
|
authenticator_name = "radius"
|
||||||
authenticator_slug = self._generate_authenticator_slug("radius", category)
|
authenticator_slug = self._generate_authenticator_slug("radius", category)
|
||||||
|
|
||||||
self._write_output(f"\n--- Processing {category} authenticator ---")
|
self._write_output(f"\n--- Processing {category} authenticator ---")
|
||||||
|
|||||||
@@ -66,11 +66,10 @@ class TACACSMigrator(BaseAuthenticatorMigrator):
|
|||||||
"""Create a TACACS+ authenticator in Gateway."""
|
"""Create a TACACS+ authenticator in Gateway."""
|
||||||
category = config["category"]
|
category = config["category"]
|
||||||
config_settings = config["settings"]
|
config_settings = config["settings"]
|
||||||
name = config_settings["name"]
|
|
||||||
|
|
||||||
# Generate authenticator name and slug
|
# Generate authenticator name and slug
|
||||||
authenticator_name = f"AWX-{category.replace('+', 'plus').replace('-', '_').title()}-{name}"
|
authenticator_name = "tacacs"
|
||||||
authenticator_slug = self._generate_authenticator_slug("tacacsplus", category)
|
authenticator_slug = self._generate_authenticator_slug("tacacs", category)
|
||||||
|
|
||||||
self._write_output(f"\n--- Processing {category} authenticator ---")
|
self._write_output(f"\n--- Processing {category} authenticator ---")
|
||||||
self._write_output(f"Name: {authenticator_name}")
|
self._write_output(f"Name: {authenticator_name}")
|
||||||
|
|||||||
Reference in New Issue
Block a user