From 803fd7c9a5bc2af2711a4c195e42bdc4a5cca66b Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 17 Aug 2022 17:30:58 +0200 Subject: [PATCH] auth_saml: remove login hints field (#68223) --- ...0004_remove_samlauthenticator_login_hints.py | 17 +++++++++++++++++ src/authentic2_auth_saml/models.py | 6 +----- tests/test_auth_saml.py | 5 +---- 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 src/authentic2_auth_saml/migrations/0004_remove_samlauthenticator_login_hints.py diff --git a/src/authentic2_auth_saml/migrations/0004_remove_samlauthenticator_login_hints.py b/src/authentic2_auth_saml/migrations/0004_remove_samlauthenticator_login_hints.py new file mode 100644 index 00000000..319838be --- /dev/null +++ b/src/authentic2_auth_saml/migrations/0004_remove_samlauthenticator_login_hints.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.26 on 2022-08-17 15:31 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentic2_auth_saml', '0003_auto_20220726_1713'), + ] + + operations = [ + migrations.RemoveField( + model_name='samlauthenticator', + name='login_hints', + ), + ] diff --git a/src/authentic2_auth_saml/models.py b/src/authentic2_auth_saml/models.py index 9b95643f..c2409c76 100644 --- a/src/authentic2_auth_saml/models.py +++ b/src/authentic2_auth_saml/models.py @@ -121,9 +121,6 @@ class SAMLAuthenticator(BaseAuthenticator): ), blank=True, ) - login_hints = models.CharField( - _('Login hints'), max_length=512, help_text=_('Comma separated list.'), blank=True - ) lookup_by_attributes = JSONField( _('Lookup by attributes'), default=list, @@ -183,8 +180,7 @@ class SAMLAuthenticator(BaseAuthenticator): def settings(self): settings = {k.upper(): v for k, v in self.__dict__.items()} - for setting in ('AUTHN_CLASSREF', 'LOGIN_HINTS'): - settings[setting] = [x.strip() for x in settings[setting].split(',') if x.strip()] + settings['AUTHN_CLASSREF'] = [x.strip() for x in settings['AUTHN_CLASSREF'].split(',') if x.strip()] for setting in ('METADATA', 'METADATA_PATH', 'METADATA_URL'): if not settings[setting]: diff --git a/tests/test_auth_saml.py b/tests/test_auth_saml.py index c4e65c20..7ee325aa 100644 --- a/tests/test_auth_saml.py +++ b/tests/test_auth_saml.py @@ -340,14 +340,13 @@ def test_manager_user_sidebar(app, superuser, simple_user): def test_saml_authenticator_settings(db): authenticator = SAMLAuthenticator.objects.create( - enabled=True, metadata='meta1.xml', slug='idp1', authn_classref='a, b', login_hints='b , c' + enabled=True, metadata='meta1.xml', slug='idp1', authn_classref='a, b' ) assert 'METADATA' in authenticator.settings assert 'METADATA_PATH' not in authenticator.settings assert 'METADATA_URL' not in authenticator.settings assert authenticator.settings['AUTHN_CLASSREF'] == ['a', 'b'] - assert authenticator.settings['LOGIN_HINTS'] == ['b', 'c'] authenticator.metadata = '' authenticator.metadata_path = '/some/path/metadata.xml' @@ -358,11 +357,9 @@ def test_saml_authenticator_settings(db): assert 'METADATA_URL' not in authenticator.settings authenticator.authn_classref = '' - authenticator.login_hints = ', ' authenticator.save() assert authenticator.settings['AUTHN_CLASSREF'] == [] - assert authenticator.settings['LOGIN_HINTS'] == [] def test_saml_authenticator_data_migration(migration, settings): -- 2.30.2