misc: pass the authentication request to the adapter object (#50833)
This commit is contained in:
parent
7cd78e96ab
commit
d106f3da90
|
@ -58,6 +58,9 @@ def display_truncated_list(l, max_length=10):
|
|||
|
||||
|
||||
class DefaultAdapter(object):
|
||||
def __init__(self, request=None):
|
||||
self.request = request
|
||||
|
||||
def get_idp(self, entity_id):
|
||||
'''Find the first IdP definition matching entity_id'''
|
||||
for idp in self.get_idps():
|
||||
|
|
|
@ -34,7 +34,7 @@ class SAMLBackend(ModelBackend):
|
|||
if not idp:
|
||||
logger.debug('unknown idp %s', saml_attributes['issuer'])
|
||||
return None
|
||||
adapters = utils.get_adapters(idp)
|
||||
adapters = utils.get_adapters(idp, request=request)
|
||||
for adapter in adapters:
|
||||
if not hasattr(adapter, 'authorize'):
|
||||
continue
|
||||
|
|
|
@ -180,11 +180,12 @@ def import_object(path):
|
|||
|
||||
|
||||
@to_list
|
||||
def get_adapters(idp={}):
|
||||
def get_adapters(idp={}, **kwargs):
|
||||
idp = idp or {}
|
||||
adapters = tuple(idp.get('ADAPTER', ())) + tuple(app_settings.ADAPTER)
|
||||
for adapter in adapters:
|
||||
yield import_object(adapter)()
|
||||
klass = import_object(adapter)
|
||||
yield klass(**kwargs)
|
||||
|
||||
|
||||
def get_values(saml_attributes, name):
|
||||
|
|
Loading…
Reference in New Issue