diff --git a/modules/authentication_saml/routes.py b/modules/authentication_saml/routes.py
index 4dc9644bbe..2bafd4fe25 100644
--- a/modules/authentication_saml/routes.py
+++ b/modules/authentication_saml/routes.py
@@ -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:
diff --git a/sao/CHANGELOG b/sao/CHANGELOG
index af7cc0057c..576425e658 100644
--- a/sao/CHANGELOG
+++ b/sao/CHANGELOG
@@ -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 --git a/sao/src/session.js b/sao/src/session.js
index 68ca27d2d9..140c5b8e12 100644
--- a/sao/src/session.js
+++ b/sao/src/session.js
@@ -388,12 +388,20 @@
dialog.body.append(jQuery('
', {
'class': 'panel panel-default',
}).append(panel_body));
- for (const [name, url] of services) {
- panel_body.append(jQuery('', {
+ for (let service of services) {
+ let button = jQuery('', {
'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('
', {
+ 'class': 'icon',
+ 'src': service.icon,
+ });
+ icon.prependTo(button);
+ }
+ panel_body.append(button);
}
if (localhost) {
panel_body.append(jQuery('', {
diff --git a/tryton/CHANGELOG b/tryton/CHANGELOG
index 3ad387c871..469adbb194 100644
--- a/tryton/CHANGELOG
+++ b/tryton/CHANGELOG
@@ -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 --git a/tryton/tryton/gui/window/dblogin.py b/tryton/tryton/gui/window/dblogin.py
index 4eef1e92ca..cf9f6e9fd7 100644
--- a/tryton/tryton/gui/window/dblogin.py
+++ b/tryton/tryton/gui/window/dblogin.py
@@ -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()
diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG
index c1da60b16a..7c7d237ba1 100644
--- a/trytond/CHANGELOG
+++ b/trytond/CHANGELOG
@@ -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 --git a/trytond/doc/ref/index.rst b/trytond/doc/ref/index.rst
index f9f9f506e6..4c61b19a1e 100644
--- a/trytond/doc/ref/index.rst
+++ b/trytond/doc/ref/index.rst
@@ -23,6 +23,7 @@ Reference of the ``trytond`` API:
tools/index
pool
rpc
+ protocols/index
i18n
sendmail
filestore
diff --git a/trytond/doc/ref/protocols/dispatcher.rst b/trytond/doc/ref/protocols/dispatcher.rst
new file mode 100644
index 0000000000..a2c1856211
--- /dev/null
+++ b/trytond/doc/ref/protocols/dispatcher.rst
@@ -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 --git a/trytond/doc/ref/protocols/index.rst b/trytond/doc/ref/protocols/index.rst
new file mode 100644
index 0000000000..7e9724e7b8
--- /dev/null
+++ b/trytond/doc/ref/protocols/index.rst
@@ -0,0 +1,12 @@
+.. _ref-protocols-index:
+
+=========
+Protocols
+=========
+
+Handling of networking protocols:
+
+.. toctree::
+ :maxdepth: 1
+
+ dispatcher
diff --git a/trytond/trytond/protocols/dispatcher.py b/trytond/trytond/protocols/dispatcher.py
index 827690fee3..399b80d8dd 100644
--- a/trytond/trytond/protocols/dispatcher.py
+++ b/trytond/trytond/protocols/dispatcher.py
@@ -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 = []