0

How can I intercept authentication failures when using @EnableZuulProxy + @EnableOAuth2Sso annotations?

I have an authorization server that authenticates the users against a Microsoft Active Directory server. As I could tell, in Spring Cloud the processes goes like this:

  1. The user tries to access an Angular client through a Zuul proxy server
  2. The Zuul server checks for the authorization against an authorization server
  3. The authorization server, in turn, validates the user credentials against a Microsoft Active Directory server and, if necessary, a login page is shown to the user
  4. The user types in the username and password
  5. Eventualy, the user's password is expired, and the Microsoft AD answers to the autorization server denying the authentication with a "data 733" code in the error message
  6. The authorization server sends the authentication error to Zuul server which, in turn, asks for the login page again with a query parameter (/login?error)

What I want to do is change the query parameter in step 6, to something like /login?error_expired, so I can show a message to the user, telling him that he must update his password before going on.

Thanks in advance for any help.

julianobrasil
  • 8,954
  • 2
  • 33
  • 55
  • The answer is to write a custom filter. – spencergibb May 22 '17 at 15:01
  • @spencergibb, so I must do something like httpSecurity.addFilterAfter(new CustomFilter(), BasicAuthenticationFilter.class)? If so, which is the exact phase I should use to put the filter. I tried after the BasicAuthenticationFilter, but with no success. – julianobrasil May 23 '17 at 13:54
  • 1
    A custom zuul filter. https://stackoverflow.com/questions/31055736/creating-custom-zuul-filters https://github.com/spring-cloud-samples/sample-zuul-filters/ – spencergibb May 24 '17 at 20:54

1 Answers1

0

At last I found out that I was wrong about some assumptions. I had just to intercept a failed authentication attempt in the authorization server itself, using regular Spring Security techniques.

julianobrasil
  • 8,954
  • 2
  • 33
  • 55