@@ -144,6 +144,13 @@ def login(request,
144144 selected_idp = request .GET .get ('idp' , None )
145145 conf = get_config (config_loader_path , request )
146146
147+ kwargs = {}
148+ # pysaml needs a string otherwise: "cannot serialize True (type bool)"
149+ if getattr (conf , '_sp_force_authn' ):
150+ kwargs ['force_authn' ] = "true"
151+ if getattr (conf , '_sp_allow_create' , "false" ):
152+ kwargs ['allow_create' ] = "true"
153+
147154 # is a embedded wayf needed?
148155 idps = available_idps (conf )
149156 if selected_idp is None and len (idps ) > 1 :
@@ -192,7 +199,7 @@ def login(request,
192199 session_id , result = client .prepare_for_authenticate (
193200 entityid = selected_idp , relay_state = came_from ,
194201 binding = binding , sign = False , sigalg = sigalg ,
195- nsprefix = nsprefix )
202+ nsprefix = nsprefix , ** kwargs )
196203 except TypeError as e :
197204 logger .error ('Unable to know which IdP to use' )
198205 return HttpResponse (text_type (e ))
@@ -208,7 +215,8 @@ def login(request,
208215 return HttpResponse (text_type (e ))
209216 session_id , request_xml = client .create_authn_request (
210217 location ,
211- binding = binding )
218+ binding = binding ,
219+ ** kwargs )
212220 try :
213221 if PY3 :
214222 saml_request = base64 .b64encode (binary_type (request_xml , 'UTF-8' )).decode ('utf-8' )
0 commit comments