0004-adapters-abstract-user-queryset-33739.patch
mellon/adapters.py | ||
---|---|---|
43 | 43 |
def get_identity_providers_setting(self): |
44 | 44 |
return app_settings.IDENTITY_PROVIDERS |
45 | 45 | |
46 |
def get_users_queryset(self, idp, saml_attributes): |
|
47 |
return User.objects.all() |
|
48 | ||
46 | 49 |
def get_idps(self): |
47 | 50 |
for i, idp in enumerate(self.get_identity_providers_setting()): |
48 | 51 |
if 'METADATA_URL' in idp and 'METADATA' not in idp: |
... | ... | |
137 | 140 |
name_id = saml_attributes['name_id_content'] |
138 | 141 |
issuer = saml_attributes['issuer'] |
139 | 142 |
try: |
140 |
user = User.objects.get(saml_identifiers__name_id=name_id, |
|
141 |
saml_identifiers__issuer=issuer) |
|
143 |
user = self.get_users_queryset(idp, saml_attributes).get( |
|
144 |
saml_identifiers__name_id=name_id, |
|
145 |
saml_identifiers__issuer=issuer) |
|
142 | 146 |
self.logger.info('looked up user %s with name_id %s from issuer %s', |
143 | 147 |
user, name_id, issuer) |
144 | 148 |
return user |
... | ... | |
210 | 214 |
key = user_field |
211 | 215 |
if ignore_case: |
212 | 216 |
key += '__iexact' |
213 |
users_found = User.objects.filter(saml_identifiers__isnull=True, **{key: value}) |
|
217 |
users_found = self.get_users_queryset(idp, saml_attributes).filter( |
|
218 |
saml_identifiers__isnull=True, **{key: value}) |
|
214 | 219 |
if not users_found: |
215 | 220 |
self.logger.debug('looking for users by attribute %r and user field %r with value %r: not found', |
216 | 221 |
saml_attribute, user_field, value) |
217 |
- |