summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-06-06 20:52:22 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2019-06-11 14:46:02 (GMT)
commit81ab8f4c9ee816f4fe066b4d74989915a76bc401 (patch)
tree7c8629fcdb67085d0a7385430bae82c1ac617ef7
parent31015e6580b4f7ca300c66f880ae8b281a18a883 (diff)
downloaddjango-mellon-81ab8f4c9ee816f4fe066b4d74989915a76bc401.zip
django-mellon-81ab8f4c9ee816f4fe066b4d74989915a76bc401.tar.gz
django-mellon-81ab8f4c9ee816f4fe066b4d74989915a76bc401.tar.bz2
adapters: abstract user queryset (#33739)v1.2.43
-rw-r--r--mellon/adapters.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mellon/adapters.py b/mellon/adapters.py
index 8f94f15..8c869a3 100644
--- a/mellon/adapters.py
+++ b/mellon/adapters.py
@@ -43,6 +43,9 @@ class DefaultAdapter(object):
def get_identity_providers_setting(self):
return app_settings.IDENTITY_PROVIDERS
+ def get_users_queryset(self, idp, saml_attributes):
+ return User.objects.all()
+
def get_idps(self):
for i, idp in enumerate(self.get_identity_providers_setting()):
if 'METADATA_URL' in idp and 'METADATA' not in idp:
@@ -137,8 +140,9 @@ class DefaultAdapter(object):
name_id = saml_attributes['name_id_content']
issuer = saml_attributes['issuer']
try:
- user = User.objects.get(saml_identifiers__name_id=name_id,
- saml_identifiers__issuer=issuer)
+ user = self.get_users_queryset(idp, saml_attributes).get(
+ saml_identifiers__name_id=name_id,
+ saml_identifiers__issuer=issuer)
self.logger.info('looked up user %s with name_id %s from issuer %s',
user, name_id, issuer)
return user
@@ -210,7 +214,8 @@ class DefaultAdapter(object):
key = user_field
if ignore_case:
key += '__iexact'
- users_found = User.objects.filter(saml_identifiers__isnull=True, **{key: value})
+ users_found = self.get_users_queryset(idp, saml_attributes).filter(
+ saml_identifiers__isnull=True, **{key: value})
if not users_found:
self.logger.debug('looking for users by attribute %r and user field %r with value %r: not found',
saml_attribute, user_field, value)