1.简单写了个springboot security
@Component
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
//表单登录 方式
http.formLogin()
.loginPage("/authentication/require")
//登录需要经过的url请求
.loginProcessingUrl("/authentication/form")
.and()
//请求授权
.authorizeRequests()
//任何请求
.anyRequest()
//需要身份认证
.authenticated()
.and()
//关闭跨站请求防护
.csrf().disable();
}
}
请求被拦截也是用的security默认的地址
https://www.cnblogs.com/hyl8218/p/6212603.html
少了一个注解
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled=true)