Browse Source

feat: saml2协议单点登录支持在页面上配置saml2协议的高级配置 (#7362)

pull/7367/head
jiangweidong 3 years ago committed by GitHub
parent
commit
c5013dcbd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      apps/authentication/backends/saml2/views.py
  2. 2
      apps/jumpserver/conf.py
  3. 2
      apps/jumpserver/settings/auth.py
  4. 3
      apps/settings/serializers/auth/saml2.py

7
apps/authentication/backends/saml2/views.py

@ -92,14 +92,11 @@ class PrepareRequestMixin:
@staticmethod
def get_advanced_settings():
other_settings = {}
other_settings_path = settings.SAML2_OTHER_SETTINGS_PATH
if os.path.exists(other_settings_path):
with open(other_settings_path, 'r') as json_data:
try:
other_settings = json.loads(json_data.read())
other_settings = dict(settings.SAML2_SP_ADVANCED_SETTINGS)
except Exception as error:
logger.error('Get other settings error: %s', error)
other_settings = {}
default = {
"organization": {

2
apps/jumpserver/conf.py

@ -234,7 +234,7 @@ class Config(dict):
'SAML2_LOGOUT_COMPLETELY': True,
'AUTH_SAML2_ALWAYS_UPDATE_USER': True,
'SAML2_RENAME_ATTRIBUTES': {'uid': 'username', 'email': 'email'},
'SAML2_OTHER_SETTINGS_PATH': '',
'SAML2_SP_ADVANCED_SETTINGS': {"organization": {"en": {"name": "JumpServer", "displayname": "JumpServer", "url": "https://jumpserver.org/"}}},
'SAML2_IDP_METADATA_URL': '',
'SAML2_IDP_METADATA_XML': '',
'SAML2_SP_KEY_CONTENT': '',

2
apps/jumpserver/settings/auth.py

@ -129,7 +129,7 @@ AUTH_SAML2_AUTHENTICATION_FAILURE_REDIRECT_URI = CONFIG.AUTH_SAML2_AUTHENTICATIO
AUTH_SAML2_ALWAYS_UPDATE_USER = CONFIG.AUTH_SAML2_ALWAYS_UPDATE_USER
SAML2_LOGOUT_COMPLETELY = CONFIG.SAML2_LOGOUT_COMPLETELY
SAML2_RENAME_ATTRIBUTES = CONFIG.SAML2_RENAME_ATTRIBUTES
SAML2_OTHER_SETTINGS_PATH = CONFIG.SAML2_OTHER_SETTINGS_PATH
SAML2_SP_ADVANCED_SETTINGS = CONFIG.SAML2_SP_ADVANCED_SETTINGS
SAML2_LOGIN_URL_NAME = "authentication:saml2:saml2-login"
SAML2_LOGOUT_URL_NAME = "authentication:saml2:saml2-logout"

3
apps/settings/serializers/auth/saml2.py

@ -17,6 +17,9 @@ class SAML2SettingSerializer(serializers.Serializer):
SAML2_IDP_METADATA_XML = serializers.CharField(
allow_blank=True, required=False, label=_('IDP Metadata XML')
)
SAML2_SP_ADVANCED_SETTINGS = serializers.JSONField(
required=False, label=_('SP ADVANCED SETTINGS')
)
SAML2_SP_KEY_CONTENT = serializers.CharField(
allow_blank=True, required=False,
write_only=True, label=_('SP Private Key')

Loading…
Cancel
Save