details:   https://code.tryton.org/tryton/commit/e0c9a52cfdd1
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Fri Sep 18 13:30:12 2026 +0200
description:
        Add an optional icon to the login services

        Closes #14915
diffstat:

 modules/authentication_saml/routes.py    |   5 ++++-
 sao/CHANGELOG                            |   1 +
 sao/src/session.js                       |  14 +++++++++++---
 tryton/CHANGELOG                         |   1 +
 tryton/tryton/gui/window/dblogin.py      |  17 +++++++++++++++--
 trytond/CHANGELOG                        |   1 +
 trytond/doc/ref/index.rst                |   1 +
 trytond/doc/ref/protocols/dispatcher.rst |  12 ++++++++++++
 trytond/doc/ref/protocols/index.rst      |  12 ++++++++++++
 trytond/trytond/protocols/dispatcher.py  |   8 ++++++--
 10 files changed, 64 insertions(+), 8 deletions(-)

diffs (167 lines):

diff -r 2b97e6681d99 -r e0c9a52cfdd1 modules/authentication_saml/routes.py
--- a/modules/authentication_saml/routes.py     Thu Sep 17 16:18:47 2026 +0200
+++ b/modules/authentication_saml/routes.py     Fri Sep 18 13:30:12 2026 +0200
@@ -24,13 +24,16 @@
 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:
diff -r 2b97e6681d99 -r e0c9a52cfdd1 sao/CHANGELOG
--- a/sao/CHANGELOG     Thu Sep 17 16:18:47 2026 +0200
+++ b/sao/CHANGELOG     Fri Sep 18 13:30:12 2026 +0200
@@ -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
diff -r 2b97e6681d99 -r e0c9a52cfdd1 sao/src/session.js
--- a/sao/src/session.js        Thu Sep 17 16:18:47 2026 +0200
+++ b/sao/src/session.js        Fri Sep 18 13:30:12 2026 +0200
@@ -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/>', {
diff -r 2b97e6681d99 -r e0c9a52cfdd1 tryton/CHANGELOG
--- a/tryton/CHANGELOG  Thu Sep 17 16:18:47 2026 +0200
+++ b/tryton/CHANGELOG  Fri Sep 18 13:30:12 2026 +0200
@@ -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
diff -r 2b97e6681d99 -r e0c9a52cfdd1 tryton/tryton/gui/window/dblogin.py
--- a/tryton/tryton/gui/window/dblogin.py       Thu Sep 17 16:18:47 2026 +0200
+++ b/tryton/tryton/gui/window/dblogin.py       Fri Sep 18 13:30:12 2026 +0200
@@ -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 @@
             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()
 
diff -r 2b97e6681d99 -r e0c9a52cfdd1 trytond/CHANGELOG
--- a/trytond/CHANGELOG Thu Sep 17 16:18:47 2026 +0200
+++ b/trytond/CHANGELOG Fri Sep 18 13:30:12 2026 +0200
@@ -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
diff -r 2b97e6681d99 -r e0c9a52cfdd1 trytond/doc/ref/index.rst
--- a/trytond/doc/ref/index.rst Thu Sep 17 16:18:47 2026 +0200
+++ b/trytond/doc/ref/index.rst Fri Sep 18 13:30:12 2026 +0200
@@ -23,6 +23,7 @@
    tools/index
    pool
    rpc
+   protocols/index
    i18n
    sendmail
    filestore
diff -r 2b97e6681d99 -r e0c9a52cfdd1 trytond/doc/ref/protocols/dispatcher.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/trytond/doc/ref/protocols/dispatcher.rst  Fri Sep 18 13:30:12 2026 +0200
@@ -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.
+
diff -r 2b97e6681d99 -r e0c9a52cfdd1 trytond/doc/ref/protocols/index.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/trytond/doc/ref/protocols/index.rst       Fri Sep 18 13:30:12 2026 +0200
@@ -0,0 +1,12 @@
+.. _ref-protocols-index:
+
+=========
+Protocols
+=========
+
+Handling of networking protocols:
+
+.. toctree::
+   :maxdepth: 1
+
+   dispatcher
diff -r 2b97e6681d99 -r e0c9a52cfdd1 trytond/trytond/protocols/dispatcher.py
--- a/trytond/trytond/protocols/dispatcher.py   Thu Sep 17 16:18:47 2026 +0200
+++ b/trytond/trytond/protocols/dispatcher.py   Fri Sep 18 13:30:12 2026 +0200
@@ -171,8 +171,12 @@
     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 = []

Reply via email to