We are using WSO2 Identity Server 5.8.0.
We have made an extension to the org.wso2.carbon.identity.application.authenticator.samlsso.manager.DefaultSAML2SSOManager located in the project identity-outbound-auth-samlsso
Basically we need to add some checks to the SAML Response when we use external IdPs based on SAML authentication.
We made all the checks and all works good. We are facing one little issue. In some cases, when some access errors happem, we need to customize the error message to the user.
I saw here I saw it's possible to customize error message and it's possible to configure WSO2 IS in order to pass error code in request param.
So, what I wanted to do is to generate custom error code when one error happens. I tried the previous configuration and then in the org.wso2.carbon.identity.application.authenticator.samlsso.SAMLSSOAuthenticator class I did the following
@Override
protected void processAuthenticationResponse(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws AuthenticationFailedException {
try{
//Original code
} catch (SPIDCheckException spe) {
// whenever the code reaches here the subject identifier will be null. Therefore we can't pass AuthenticatedUser object with the exception.
AuthenticationFailedException afe = new AuthenticationFailedException(spe.getMessage(), spe);
afe.setErrorCode("MY_CUSTOM_ERROR_CODE");
throw afe;
}
}
I was expecting that with the previous configuration my custom cose would apper in request parameter but it's not so. So I had to find a workaround; my solution was to add a cookie to the response but I don't like it.
Is there any chance to propagate a custom error code from SAMLSSOAuthenticator to the login error JSP page in a query string param?
Am I missing anything?
Thank you
Angelo