Add an optional icon to the login services

Closes #14915
This commit is contained in:
Nicolas Évrard
2026-09-18 13:30:12 +02:00
parent 548226de8e
commit 89b50e2459
10 changed files with 64 additions and 8 deletions
+4 -1
View File
@@ -24,13 +24,16 @@ IDENTITIES = set()
METADATA = {}
CONFIG_FILENAME = {}
LOGIN = {}
ICON = {}
if config.has_section('authentication_saml'):
for identity in config.options('authentication_saml'):
IDENTITIES.add(identity)
name = config.get('authentication_saml', identity)
icon = ICON[identity] = config.get(
f'authentication_saml {identity}', 'icon', default='')
register_authentication_service(
name, f'/r/authentication/saml/{identity}/login')
name, f'/r/authentication/saml/{identity}/login', icon)
metadata = config.get(
f'authentication_saml {identity}', 'metadata', default=None)
if metadata:
+1
View File
@@ -1,3 +1,4 @@
* Support icon for login services
* Edit the selected One2Many rows sequentially
* Support filename extension for Binary field
* Use record name as fallback for filename of Binary field
+11 -3
View File
@@ -388,12 +388,20 @@
dialog.body.append(jQuery('<div/>', {
'class': 'panel panel-default',
}).append(panel_body));
for (const [name, url] of services) {
panel_body.append(jQuery('<button/>', {
for (let service of services) {
let button = jQuery('<button/>', {
'class': 'btn btn-block btn-default',
'type': 'button',
'disabled': localhost,
}).text(name).click(url, login_service));
}).text(service.name).click(service.url, login_service);
if (service.icon) {
let icon = jQuery('<img/>', {
'class': 'icon',
'src': service.icon,
});
icon.prependTo(button);
}
panel_body.append(button);
}
if (localhost) {
panel_body.append(jQuery('<p/>', {
+1
View File
@@ -1,3 +1,4 @@
* Support icon for login services
* Edit the selected One2Many rows sequentially
* Support filename extension for Binary field
* Use record name as fallback for filename of Binary field
+15 -2
View File
@@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
import configparser
import functools
import gettext
import logging
import os
@@ -622,8 +623,20 @@ class DBLogin(object):
self.service_base, self.services = rpc.authentication_services(
hostname, port)
self._services[key] = (self.services, self.service_base)
for response_id, (name, url) in enumerate(self.services, 1):
button = Gtk.Button(label=name)
def show_image(image, pixbuf):
image.set_from_pixbuf(pixbuf)
image.show()
for response_id, service in enumerate(self.services, 1):
button = Gtk.Button(label=service['name'])
if service['icon']:
image = Gtk.Image()
pixbuf = common.IconFactory.get_pixbuf_url(
service['icon'], size=16,
callback=functools.partial(show_image, image))
image.set_from_pixbuf(pixbuf)
button.set_image(image)
self.dialog.add_action_widget(button, response_id)
button.show()
+1
View File
@@ -1,3 +1,4 @@
* Add the icon parameter to register_authentication_service
* Add routes for sao custom in base router
* Replace the administration group by a flag on the user
* Make DBTestCase public
+1
View File
@@ -23,6 +23,7 @@ Reference of the ``trytond`` API:
tools/index
pool
rpc
protocols/index
i18n
sendmail
filestore
+12
View File
@@ -0,0 +1,12 @@
.. _ref-dispatcher:
.. module:: trytond.protocols.dispatcher
Dispatcher
==========
.. function:: register_authentication_service(name, url[, icon])
Register the named authentication service using, the URL path used to start
the authentication process and an optional icon URL to use when rendering
the authentication button on the clients.
+12
View File
@@ -0,0 +1,12 @@
.. _ref-protocols-index:
=========
Protocols
=========
Handling of networking protocols:
.. toctree::
:maxdepth: 1
dispatcher
+6 -2
View File
@@ -171,8 +171,12 @@ def authentication_services(request):
return _AUTHENTICATION_SERVICES
def register_authentication_service(name, url):
_AUTHENTICATION_SERVICES.append((name, url))
def register_authentication_service(name, url, icon=None):
_AUTHENTICATION_SERVICES.append({
'name': name,
'url': url,
'icon': icon,
})
_AUTHENTICATION_SERVICES = []