mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
SSO: allow specifying custom icon URL
This commit is contained in:
parent
99b09e66a8
commit
23beda54d9
@ -49,9 +49,9 @@ to an empty dictionary. This dictionary maps a `social_core` module's name (ie.
|
|||||||
`REMOTE_AUTH_BACKEND.name`) to a couple of parameters, `(display_name, icon)`.
|
`REMOTE_AUTH_BACKEND.name`) to a couple of parameters, `(display_name, icon)`.
|
||||||
|
|
||||||
The `display_name` is the name displayed to the user on the login page. The
|
The `display_name` is the name displayed to the user on the login page. The
|
||||||
icon refers to a [Material Design
|
icon may either be the URL of an icon; refer to a [Material Design
|
||||||
Icons](https://github.com/google/material-design-icons) icon's name, or `None`
|
Icons](https://github.com/google/material-design-icons) icon's name; or be
|
||||||
for no icon.
|
`None` for no icon.
|
||||||
|
|
||||||
For instance, the OIDC backend may be customized with
|
For instance, the OIDC backend may be customized with
|
||||||
```python
|
```python
|
||||||
|
@ -44,10 +44,20 @@ class LoginView(View):
|
|||||||
return super().dispatch(*args, **kwargs)
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
def gen_auth_data(self, name, url, params):
|
def gen_auth_data(self, name, url, params):
|
||||||
display_name, icon_name = get_auth_backend_display(name)
|
display_name, icon_source = get_auth_backend_display(name)
|
||||||
|
|
||||||
|
icon_name = None
|
||||||
|
icon_img = None
|
||||||
|
if icon_source:
|
||||||
|
if '://' in icon_source:
|
||||||
|
icon_img = icon_source
|
||||||
|
else:
|
||||||
|
icon_name = icon_source
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'display_name': display_name,
|
'display_name': display_name,
|
||||||
'icon_name': icon_name,
|
'icon_name': icon_name,
|
||||||
|
'icon_img': icon_img,
|
||||||
'url': f'{url}?{urlencode(params)}',
|
'url': f'{url}?{urlencode(params)}',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@
|
|||||||
{% for backend in auth_backends %}
|
{% for backend in auth_backends %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<a href="{{ backend.url }}" class="btn w-100">
|
<a href="{{ backend.url }}" class="btn w-100">
|
||||||
{% if backend.icon_name %}<i class="mdi mdi-{{ backend.icon_name }}"></i>{% endif %}
|
{% if backend.icon_name %}<i class="mdi mdi-{{ backend.icon_name }}"></i>
|
||||||
|
{% elif backend.icon_img %}<img src="{{ backend.icon_img }}" height="24" class="me-2" />{% endif %}
|
||||||
{{ backend.display_name }}
|
{{ backend.display_name }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user