summaryrefslogtreecommitdiffstats
path: root/python/doc/tutorial/sp-login-send-authn-request.py
blob: 3d5ccefd8d20e10cb2459bad7b9399603d0ff527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import lasso

lasso.init()

## Send an authentication request to identity provider.
##
## Called when the user press login button on service provider.

server_dump = [...] # Load server_dump from file or database or...
server = lasso.Server.new_from_dump(server_dump)
login = lasso.Login.new(server)
if login.init_authn_request('http://identification.entrouvert.org'):
    raise Exception('Login error')

# Identity provider will ask user to authenticate himself.
login.request.set_isPassive(False)

# Identity provider will not ask user to authenticate himself if he has already done it recently.
# login.request.set_forceAuthn(False)

# Identity provider will create a federation with this service provider and this user, if this was
# not already done.
login.request.set_nameIDPolicy(lasso.libNameIDPolicyTypeFederated)

if login.build_authn_request_msg():
    raise Exception('Login error')
[...] # Reply a HTTP redirect to login.msg_url.

lasso.shutdown()