|
42 | 42 | from saml2.s_utils import UnsupportedBinding |
43 | 43 | from saml2.response import ( |
44 | 44 | StatusError, StatusAuthnFailed, SignatureError, StatusRequestDenied, |
45 | | - UnsolicitedResponse, |
| 45 | + UnsolicitedResponse, StatusNoAuthnContext, |
46 | 46 | ) |
| 47 | +from saml2.mdstore import SourceNotFound |
47 | 48 | from saml2.validate import ResponseLifetimeExceed, ToEarly |
48 | 49 | from saml2.xmldsig import SIG_RSA_SHA1, SIG_RSA_SHA256 # support for SHA1 is required by spec |
49 | 50 |
|
@@ -134,7 +135,15 @@ def login(request, |
134 | 135 | }) |
135 | 136 |
|
136 | 137 | selected_idp = request.GET.get('idp', None) |
137 | | - conf = get_config(config_loader_path, request) |
| 138 | + try: |
| 139 | + conf = get_config(config_loader_path, request) |
| 140 | + except SourceNotFound as excp: |
| 141 | + msg = ('Error, IdP EntityID was not found ' |
| 142 | + 'in metadata: {}') |
| 143 | + logger.exception(msg.format(excp)) |
| 144 | + return HttpResponse(msg.format(('Please contact ' |
| 145 | + 'technical support.')), |
| 146 | + status=500) |
138 | 147 |
|
139 | 148 | # is a embedded wayf needed? |
140 | 149 | idps = available_idps(conf) |
@@ -284,6 +293,9 @@ def assertion_consumer_service(request, |
284 | 293 | except StatusRequestDenied: |
285 | 294 | logger.warning("Authentication interrupted at IdP.", exc_info=True) |
286 | 295 | return fail_acs_response(request) |
| 296 | + except StatusNoAuthnContext: |
| 297 | + logger.warning("Missing Authentication Context from IdP.", exc_info=True) |
| 298 | + return fail_acs_response(request) |
287 | 299 | except MissingKey: |
288 | 300 | logger.exception("SAML Identity Provider is not configured correctly: certificate key is missing!") |
289 | 301 | return fail_acs_response(request) |
|
0 commit comments