From 654c76293e768dbda5b6aa6b69e00732fd3124c4 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 3 Feb 2021 21:25:39 +0100 Subject: [PATCH] auth_saml: report mapping errors to users (#50834) --- debian/control | 3 ++- setup.py | 2 +- src/authentic2_auth_saml/adapters.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 9cf6c50e..0c2b47fd 100644 --- a/debian/control +++ b/debian/control @@ -39,7 +39,8 @@ Depends: ${misc:Depends}, ${python3:Depends}, python3-chardet, python3-attr (>=17), python3-pycryptodome, - python3-atomicwrites + python3-atomicwrites, + python3-django-mellon>=1.22 Conflicts: python-authentic2 Replaces: python-authentic2 Description: Versatile identity server diff --git a/setup.py b/setup.py index a7191f2c..d87a45b1 100755 --- a/setup.py +++ b/setup.py @@ -131,7 +131,7 @@ setup(name="authentic2", 'python-ldap', 'django-filter>1,<2.3', 'pycryptodomex', - 'django-mellon', + 'django-mellon>=1.22', 'ldaptools', 'jwcrypto>=0.3.1,<1', 'cryptography', diff --git a/src/authentic2_auth_saml/adapters.py b/src/authentic2_auth_saml/adapters.py index 87c57beb..49502725 100644 --- a/src/authentic2_auth_saml/adapters.py +++ b/src/authentic2_auth_saml/adapters.py @@ -19,8 +19,10 @@ from __future__ import unicode_literals import logging from django.utils import six +from django.contrib import messages from django.core.exceptions import MultipleObjectsReturned from django.db.transaction import atomic +from django.utils.translation import ugettext as _ from mellon.adapters import DefaultAdapter, UserCreationError from mellon.utils import get_setting @@ -74,6 +76,8 @@ class AuthenticAdapter(DefaultAdapter): try: self.provision_a2_attributes(user, idp, saml_attributes) except MappingError as e: + if self.request: + messages.error(self.request, _('user creation failed on a mandatory mapping action: %s') % e) raise UserCreationError('user creation failed on a mandatory mapping action: %s' % e) if not user.ou: user.ou = get_default_ou() -- 2.30.0