social_backends: If no icon is to be displayed, set display_icon to None.

This commit is contained in:
Mateusz Mandera
2019-11-05 00:08:27 +01:00
committed by Tim Abbott
parent c228f7ebcb
commit b05a0d0177
5 changed files with 7 additions and 8 deletions

View File

@@ -59,7 +59,7 @@ Fetch global settings for a Zulip server.
google/github/SAML) enabled for this organization. Each dictionary google/github/SAML) enabled for this organization. Each dictionary
specifies the name and icon that should be displayed on the login specifies the name and icon that should be displayed on the login
buttons (`display_name` and `display_icon`, where `display_icon` can buttons (`display_name` and `display_icon`, where `display_icon` can
be the empty string, if no icon is to be displayed), the URLs that be `null`, if no icon is to be displayed), the URLs that
should be accessed to initiate login/signup using the method should be accessed to initiate login/signup using the method
(`login_url` and `signup_url`) and `name`, which is a unique, (`login_url` and `signup_url`) and `name`, which is a unique,
stable, machine-readable name for the authentication method. The stable, machine-readable name for the authentication method. The

View File

@@ -2240,7 +2240,7 @@ paths:
{ {
"name": "saml:idp_name", "name": "saml:idp_name",
"display_name": "SAML", "display_name": "SAML",
"display_icon": "", "display_icon": null,
"login_url": "/accounts/login/social/saml/idp_name", "login_url": "/accounts/login/social/saml/idp_name",
"signup_url": "/accounts/register/social/saml/idp_name" "signup_url": "/accounts/register/social/saml/idp_name"
}, },

View File

@@ -1143,7 +1143,7 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth):
# SAML buttons at the top. # SAML buttons at the top.
sort_order = 9999 sort_order = 9999
# There's no common default logo for SAML authentication. # There's no common default logo for SAML authentication.
display_icon = "" display_icon = None
# The full_name provided by the IdP is very likely the standard # The full_name provided by the IdP is very likely the standard
# employee directory name for the user, and thus what they and # employee directory name for the user, and thus what they and
@@ -1280,13 +1280,12 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth):
SocialBackendDictT = TypedDict('SocialBackendDictT', { SocialBackendDictT = TypedDict('SocialBackendDictT', {
'name': str, 'name': str,
'display_name': str, 'display_name': str,
'display_icon': str, 'display_icon': Optional[str],
'login_url': str, 'login_url': str,
'signup_url': str, 'signup_url': str,
}) })
def create_standard_social_backend_dict(social_backend: SocialAuthMixin) -> SocialBackendDictT: def create_standard_social_backend_dict(social_backend: SocialAuthMixin) -> SocialBackendDictT:
assert social_backend.display_icon is not None
return dict( return dict(
name=social_backend.name, name=social_backend.name,
display_name=social_backend.auth_backend_name, display_name=social_backend.auth_backend_name,

View File

@@ -230,8 +230,8 @@ SOCIAL_AUTH_SAML_ENABLED_IDPS = {
"display_name": "SAML", "display_name": "SAML",
# Path to a square image file containing a logo to appear at # Path to a square image file containing a logo to appear at
# the left end of the login/register buttons for this IDP. # the left end of the login/register buttons for this IDP.
# The default of "" results in a text-only button. # The default of None results in a text-only button.
"display_icon": "", # "display_icon": "/path/to/icon.png",
} }
} }

View File

@@ -215,6 +215,6 @@ SOCIAL_AUTH_SAML_ENABLED_IDPS = {
"attr_username": "email", "attr_username": "email",
"attr_email": "email", "attr_email": "email",
"display_name": "Test IdP", "display_name": "Test IdP",
"display_icon": "/static/images/landing-page/logos/saml-icon.png", "display_icon": None,
} }
} }