321 |
321 |
parameters = {'request': request,
|
322 |
322 |
'context': context}
|
323 |
323 |
remote_addr = request.META.get('REMOTE_ADDR')
|
|
324 |
service = request.GET.get('service')
|
324 |
325 |
login_hint = set(request.session.get('login-hint', []))
|
|
326 |
show_ctx = dict(remote_addr=remote_addr, login_hint=login_hint)
|
|
327 |
if service and '.' in service:
|
|
328 |
ou_slug, service_slug = service.split('.')
|
|
329 |
if models.Service.objects.filter(slug=service_slug).exists() and \
|
|
330 |
OU.objects.filter(slug=ou_slug).exists():
|
|
331 |
show_ctx['service_slug'] = service
|
325 |
332 |
# check if the authenticator has multiple instances
|
326 |
333 |
if hasattr(authenticator, 'instances'):
|
327 |
334 |
for instance_id, instance in authenticator.instances(**parameters):
|
328 |
335 |
parameters['instance'] = instance
|
329 |
336 |
parameters['instance_id'] = instance_id
|
330 |
|
if not authenticator.shown(
|
331 |
|
instance_id=instance_id,
|
332 |
|
ctx=dict(remote_addr=remote_addr, login_hint=login_hint)):
|
|
337 |
if not authenticator.shown(instance_id=instance_id,
|
|
338 |
ctx=show_ctx):
|
333 |
339 |
continue
|
334 |
340 |
block = utils.get_authenticator_method(authenticator, 'login', parameters)
|
335 |
341 |
# update block id in order to separate instances
|
336 |
342 |
block['id'] = '%s_%s' % (block['id'], instance_id)
|
337 |
343 |
auth_blocks.append(block)
|
338 |
344 |
else:
|
339 |
|
if authenticator.shown(ctx=dict(remote_addr=remote_addr, login_hint=login_hint)):
|
|
345 |
if authenticator.shown(ctx=show_ctx):
|
340 |
346 |
auth_blocks.append(utils.get_authenticator_method(authenticator, 'login', parameters))
|
341 |
347 |
# If a login frontend method returns an HttpResponse with a status code != 200
|
342 |
348 |
# this response is returned.
|