From b93aa6f8445c309db6ae0f06a1637b8385af94fc Mon Sep 17 00:00:00 2001 From: lu <2066448475@qq.com> Date: Tue, 14 Jan 2025 12:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=99=BB=E5=BD=95=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E9=AA=8C=E8=AF=81=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?JSON=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ .idea/misc.xml | 2 +- .../java/com/example/config/SecurityConfiguration.java | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29b636a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +*.iml \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9952cf4..b7503f2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/study-project-backend/src/main/java/com/example/config/SecurityConfiguration.java b/study-project-backend/src/main/java/com/example/config/SecurityConfiguration.java index 0c76c4e..5564622 100644 --- a/study-project-backend/src/main/java/com/example/config/SecurityConfiguration.java +++ b/study-project-backend/src/main/java/com/example/config/SecurityConfiguration.java @@ -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()