“/authentication/form” 并不存在,怎么处理登陆逻辑?

来源:4-4 个性化用户认证流程(一)

大番薯93

2017-11-07

老师您好,

我们的登录表单提交到了"/authentication/form", 在BroswerSecurityConfig中也设置了loginProcessingUrl 到同一个地址,可是这个地址并没有映射到任何method或者代码,Spring自己是怎么处理这个登陆逻辑的?

我猜测是不是只需要表单post的地址和loginProcessingUrl一致,Spring会自己调用原生的mehtod去验证?

谢谢!

写回答

2回答

JoJo

2017-11-09

BroswerSecurityConfig的loginProcessingUrl方法实际上是在设置UsernamePasswordAuthenticationFilter这个过滤器的处理路径。设好以后,当你发相应的请求时,过滤器就会拦下来做处理。


0
1
懂我不言
加了loginProcessingUrl,但是404,删了它之后,表单提交url改成/login时还是404
2017-11-09
共1条回复

张奸狗二

2017-12-27

当我们设置 `loginPage` 的时候 `FormLoginConfigurer` 里调用 `super.loginPage`到 `AbstractAuthenticationFilterConfigurer#setLoginPage`

往下走你会发现 `this.authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint(loginPage);` 这一行代码.

个人理解这里就是定义了登录认证处理路由的地方, 所以之前的 `/login` 处理逻辑都被替换成了 `loginPage` 参数, 比如我们设定 `loginPage` 为 `/login.html`

/login.html GET - the login form
/login.html POST - process the credentials and if valid authenticate the user
/login.html?error GET - redirect here for failed authentication attempts
/login.html?logout GET - redirect here after successfully logging out


0
1
张奸狗二
spring-boot 版本 1.5.9-RELEASE
2017-12-27
共1条回复

Spring Security技术栈开发企业级认证与授权

Spring Security技术栈,REST风格开发常见接口,独立开发认证授权模块保证REST服务安全

2662 学习 · 1561 问题

查看课程