Skip to content

Commit 2bb7ab4

Browse files
authored
Merge pull request #15 from ganiserb/fix-idp-initiated-login
Fix to handle a case that causes error 500 when doing IdP initiated login
2 parents 9917ae5 + 993ea5f commit 2bb7ab4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

djangosaml2/views.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def csrf_exempt(view_func):
4242
from saml2.client import Saml2Client
4343
from saml2.metadata import entity_descriptor
4444
from saml2.ident import code, decode
45+
from saml2.sigver import MissingKey
4546

4647
from djangosaml2.cache import IdentityCache, OutstandingQueriesCache
4748
from djangosaml2.cache import StateCache
@@ -209,9 +210,14 @@ def assertion_consumer_service(request,
209210
oq_cache = OutstandingQueriesCache(request.session)
210211
outstanding_queries = oq_cache.outstanding_queries()
211212

212-
# process the authentication response
213-
response = client.parse_authn_request_response(xmlstr, BINDING_HTTP_POST,
214-
outstanding_queries)
213+
try:
214+
response = client.parse_authn_request_response(xmlstr, BINDING_HTTP_POST,
215+
outstanding_queries)
216+
except MissingKey:
217+
logger.error('MissingKey error in ACS')
218+
return HttpResponseForbidden(
219+
"The Identity Provider is not configured correctly: "
220+
"the certificate key is missing")
215221
if response is None:
216222
logger.error('SAML response is None')
217223
return HttpResponseBadRequest(

0 commit comments

Comments
 (0)