i8beef / SAML2

Other
88 stars 43 forks source link

How to handle status other than 'Success' gracefully #30

Open HDenBreejen opened 6 years ago

HDenBreejen commented 6 years ago

My IDP responds with a 'Responder' status when the user at some point cancels the authentication. SAML2 throws an exception when on any status other then Success.

I need to handle this situation gracefully in my app. Perhaps I would like to redirect to a 'Try again' page. The only way of doing this I can think of, is examining the exception. A Saml20Exception, however, does not have a error code, so I would have to resort to testing the Mesage property.

Unless there is a better way to approach this situation, I would suggest adding some properties to the Saml20Exception, so the application can handle specific situations.

Specifically for my scenario, an extra endpoint attribute for a non-success redirect-url would do fine, but that would not be as versatile.

i8beef commented 6 years ago

I would instead say that a more robust list of Exceptions would be better here for you to catch. Do you just need it to throw something like a Saml20BadStatusCodeResponse or something?

HDenBreejen commented 6 years ago

Sorry for the delayed response - I had some time off line..
Introducing a set of specific exceptions would be fine too. That would give the application the opportunity to differentiate where necessary. For my exact situation, a Saml20BadStatusCodeResponse exception, having a property with the actual statuscode received, would be great.