From 12354ae5c6ff4d184a97a939a294d20ec8a8721e Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 24 Aug 2022 11:19:40 -0700 Subject: [PATCH] #10135 add idp to saml login --- netbox/netbox/authentication.py | 4 ++++ netbox/templates/login.html | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/netbox/netbox/authentication.py b/netbox/netbox/authentication.py index 62512943e..b1f4858c7 100644 --- a/netbox/netbox/authentication.py +++ b/netbox/netbox/authentication.py @@ -55,6 +55,10 @@ def get_auth_backend_display(name): return AUTH_BACKEND_ATTRS.get(name, (name, None)) +def get_saml_idps(): + return getattr(settings, "SOCIAL_AUTH_SAML_ENABLED_IDPS", {}).keys() + + class ObjectPermissionMixin: def get_all_permissions(self, user_obj, obj=None): diff --git a/netbox/templates/login.html b/netbox/templates/login.html index f4dd9c696..b4b0df8d9 100644 --- a/netbox/templates/login.html +++ b/netbox/templates/login.html @@ -41,11 +41,20 @@ {% if auth_backends %}
Or use a single sign-on (SSO) provider:
- {% for name, display in auth_backends.items %} -
- {% if display.1 %}{% endif %} - {{ display.0 }} -
+ {% for name, backend in auth_backends.items %} + {% if name == 'saml' %} + {% for idp in backend.idps %} +
+ {% if backend.icon_name %}{% endif %} + {{ backend.display_name }} ({{idp}}) +
+ {% endfor %} + {% else %} +
+ {% if backend.icon_name %}{% endif %} + {{ backend.display_name }} +
+ {% endif %} {% endfor %} {% endif %}