配置登录安全验证接口返回JSON数据

This commit is contained in:
lu 2025-01-14 12:42:10 +08:00
parent fd756fe7b3
commit b93aa6f844
3 changed files with 7 additions and 4 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea
*.iml

View File

@ -8,7 +8,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -26,15 +26,16 @@ public class SecurityConfiguration {
.anyRequest().authenticated()
.and()
.formLogin()
.loginProcessingUrl("/api/auth/login")
.successHandler(this::onAuthenticationSuccess)
.failureHandler(this::onAuthenticationFailure)
.loginProcessingUrl("/api/auth/login")//登录页面
.successHandler(this::onAuthenticationSuccess)//登录成功返回
.failureHandler(this::onAuthenticationFailure)//登录失败返回
.and()
.logout()
.logoutUrl("api/auth/logout")
.and()
.csrf()
.disable()
//无权限返回
.exceptionHandling()
.authenticationEntryPoint(this::onAuthenticationFailure)
.and()