我正在使用彈簧引導。我想發佈一個用戶名和密碼參數登錄,如果登錄成功,然後返回一個令牌。之後,我將使用令牌來判斷登錄狀態。這是我的安全配置代碼。但我不知道在哪裏寫登錄認證邏輯代碼。如何使用spring boot安全性實現身份驗證?
SecurityConfig.java
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest()
.fullyAuthenticated()
.and()
.formLogin()
.loginPage("/user/unlogin")
.permitAll();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/user/login")
.antMatchers("/user/logout")
.antMatchers("/user/register");
}
}
==========================
謝謝!