认证
Http Basic认证
示例
http.httpBasic()
.and()
.csrf().disable()
.authorizeRequests()
.antMatchers("/login.html", "/auth").permitAll()
.anyRequest().authenticated()表单认证
http.formLogin()
.loginPage("/login.html")
.loginProcessingUrl("/auth")
.usernameParameter("user")
.passwordParameter("pass")
.successHandler(bookShopAuthenticationSuccessHandler)
.failureHandler(bookShopAuthenticationFailureHandler)
.and()
.csrf().disable()
.authorizeRequests()
.antMatchers("/login.html", "/auth").permitAll()
.anyRequest().authenticated()loginPage 自定义登录页面
除了登录注册页面其他页面都需要身份认证
指定用户名密码 字段name
successHandler,failureHandler 处理成功失败的handle
successHandler
failureHandler
Last updated
Was this helpful?