0
votes

I have a Spring Boot application that has spring security configured using WebSecurityConfigurerAdapter. The problem I'm having is at .failureUrl. If I define it like this

failureUrl("/login?error")

and in my page if the error is present a message is shown. The login form is at the bottom of the page and I want the user to remain there when he is redirected via the failureUrl. So, I changed the url to

"/login?error#id"

where id is the id of the error message div. If I do this, the user is redirected to

/login#id

the ?error part is omitted completely. What am I doing wrong? Are there special characters that need to be escaped in the WebSecurityConfigurerAdapter?

Later edit:

I found the problem: I needed to add "/login" in the permitAll antmatchers.

1
If you have solved it yourself, remove your question or post solution as answer if you think it can be useful for others. - holmis83

1 Answers

0
votes

The ?error part was omitted completely because I didn't have /login in the permitAll antmatchers, therefore

/login?error#id

was redirected to

/login#id

because

/login

was set as the loginPage in my configuration.