@@ -136,6 +136,13 @@ def login(request,
136136 selected_idp = request .GET .get ('idp' , None )
137137 conf = get_config (config_loader_path , request )
138138
139+ kwargs = {}
140+ # pysaml needs a string otherwise: "cannot serialize True (type bool)"
141+ if getattr (conf , '_sp_force_authn' ):
142+ kwargs ['force_authn' ] = "true"
143+ if getattr (conf , '_sp_allow_create' , "false" ):
144+ kwargs ['allow_create' ] = "true"
145+
139146 # is a embedded wayf needed?
140147 idps = available_idps (conf )
141148 if selected_idp is None and len (idps ) > 1 :
@@ -184,7 +191,7 @@ def login(request,
184191 session_id , result = client .prepare_for_authenticate (
185192 entityid = selected_idp , relay_state = came_from ,
186193 binding = binding , sign = False , sigalg = sigalg ,
187- nsprefix = nsprefix )
194+ nsprefix = nsprefix , ** kwargs )
188195 except TypeError as e :
189196 logger .error ('Unable to know which IdP to use' )
190197 return HttpResponse (text_type (e ))
@@ -200,7 +207,8 @@ def login(request,
200207 return HttpResponse (text_type (e ))
201208 session_id , request_xml = client .create_authn_request (
202209 location ,
203- binding = binding )
210+ binding = binding ,
211+ ** kwargs )
204212 try :
205213 if PY3 :
206214 saml_request = base64 .b64encode (binary_type (request_xml , 'UTF-8' ))
0 commit comments