ulisesbocchio / spring-boot-security-saml

spring-security-saml integration with Spring Boot
MIT License
157 stars 72 forks source link

How to handle AuthenticationFailure Exception? #71

Closed valeriopaone closed 5 years ago

valeriopaone commented 6 years ago

In the SAMLUserDetailsServiceImpl, in the event that my user is not registered with the system or if the user is disabled or in other cases i generate a UsernameNotFoundException with a different message for each case. This exception automatically calls my endpoint "/error" which in my case is not an html. What are the attributes that I can pass to the method of this endpoint from which I can read the exception message?

I tried with the classic attributes of a SimpleUrlAuthenticationFailureHandler (HttpServletRequest request, HttpServletResponse response, Exception exception) but the exception is not what I expect I looked for this information everywhere but I did not

Thanks in advance

ulisesbocchio commented 5 years ago

check out the Spring MVC documentation for error handling. This is a good article too that goes into details: https://www.journaldev.com/2651/spring-mvc-exception-handling-controlleradvice-exceptionhandler-handlerexceptionresolver