@@ -33,6 +33,7 @@ def index(request):
3333 req = prepare_django_request (request )
3434 auth = init_saml_auth (req )
3535 errors = []
36+ error_reason = None
3637 not_auth_warn = False
3738 success_slo = False
3839 attributes = False
@@ -56,12 +57,16 @@ def index(request):
5657 auth .process_response ()
5758 errors = auth .get_errors ()
5859 not_auth_warn = not auth .is_authenticated ()
60+
5961 if not errors :
6062 request .session ['samlUserdata' ] = auth .get_attributes ()
6163 request .session ['samlNameId' ] = auth .get_nameid ()
6264 request .session ['samlSessionIndex' ] = auth .get_session_index ()
6365 if 'RelayState' in req ['post_data' ] and OneLogin_Saml2_Utils .get_self_url (req ) != req ['post_data' ]['RelayState' ]:
6466 return HttpResponseRedirect (auth .redirect_to (req ['post_data' ]['RelayState' ]))
67+ else :
68+ if auth .get_settings ().is_debug_active ():
69+ error_reason = auth .get_last_error_reason ()
6570 elif 'sls' in req ['get_data' ]:
6671 dscb = lambda : request .session .flush ()
6772 url = auth .process_slo (delete_session_cb = dscb )
@@ -77,7 +82,7 @@ def index(request):
7782 if len (request .session ['samlUserdata' ]) > 0 :
7883 attributes = request .session ['samlUserdata' ].items ()
7984
80- return render (request , 'index.html' , {'errors' : errors , 'not_auth_warn' : not_auth_warn , 'success_slo' : success_slo ,
85+ return render (request , 'index.html' , {'errors' : errors , 'error_reason' : error_reason , ' not_auth_warn' : not_auth_warn , 'success_slo' : success_slo ,
8186 'attributes' : attributes , 'paint_logout' : paint_logout })
8287
8388
0 commit comments