Closed alishir closed 9 months ago
I'm seeing the same. In Chrome, I get redirected to /login
after entering the correct TOTP code. In Firefox, I make it to the /third-factor
page. (Aside: I get redirected to /error?continue
after entering smith
.)
I don't know if it's related, but I notice in both browsers that /favicon.ico
is redirected to /login
. This was previously called out in #63. This is despite the fact that this line is present in the code:
.requestMatchers("/favicon.ico").permitAll()
I also notice that sending a POST
to /login
results in a response with a different JSESSIONID
value in the cookie than what previously obtained from the initial request. Is that how Spring Security is supposed to work?
In case it helps anyone in the future, I was able to solve the error after the /third-factor
page. I came across this issue: https://github.com/spring-projects/spring-security/issues/12635#issuecomment-1468046651, which led me to add
.dispatcherTypeMatchers(DispatcherType.ERROR).permitAll()
inside authorizeHttpRequests
.
This also appears to have fixed the issue with favicon.ico
. I'm getting a 404 instead of a 302.
And it fixed the issue in Chrome!
I have created a branch in my fork of the repo. TBH I don't know Spring Security well enough to know if this is an acceptable solution. Is this worthy of a PR?
Thanks everyone, this has been fixed via https://github.com/spring-projects/spring-security-samples/commit/345bd64cf7e019d3b9ea3c799c6af70b38924c58 and merged into 6.1.x
, 6.2.x
and main
.
@marcusdacoregio Thanks. It looks like your fix helped with the second factor, but now the third factor is redirecting to the error page.
@sugarjig, sorry for the trouble. I'll try to take a look at it next week.
@sugarjig how did you reproduce it? I couldn't have the same result on my side, when I provided incorrect information it redirects my to /login
as expected.
@marcusdacoregio I just tried it again in Chrome. The first time failed, but then a second and third try succeeded. Each try was in a fresh incognito window. Not quite sure what's going on, but it's likely on my end!
I just launched the multi-factor example, login with
user@example.com
andpassword
, generate the TOTP code withoathtool --totp "80ed266dd80bcd32564f0f4aaa8d9b149a2b1eaa"
command and enter the code, but I redirected to /login.The problem exists on Chrome browser, with Firefox it works fine.