在项目中引入 spring-security 依赖后 登录接口变成弹框登录
使用formlogin配置项,而不是httpBasic配置项,httpBasic开启了就是弹窗登录
检查一下配置文件中是否指定自定义登录页,可以参考:
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
super.configure(auth);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/hello","/login.html").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
//指定登录页的路径
.loginPage("/hello")
//指定自定义form表单请求的路径
.loginProcessingUrl("/authentication/form")
.failureUrl("/login?error")
.defaultSuccessUrl("/success")
//必须允许所有用户访问我们的登录页(例如未验证的用户,否则验证流程就会进入死循环)
//这个formLogin().permitAll()方法允许所有用户基于表单登录访问/login这个page。
.permitAll();
//默认都会产生一个hiden标签 里面有安全相关的验证 防止请求伪造 这边我们暂时不需要 可禁用掉
http .csrf().disable();
}
@Override
public void configure(WebSecurity web) throws Exception {
super.configure(web);
}
}
如有帮助,欢迎采纳!
这是引用spring-security后给你的默认界面,@SpringBootApplication里禁用就行
@SpringBootApplication(exclude={SecurityAutoConfiguration.class,SecurityFilterAutoConfiguration.class})