From 7e7a275c0c4a07f5d27ec082538c25b838505998 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期一, 27 六月 2022 18:24:48 +0800
Subject: [PATCH] up

---
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java
index 10a7a72..3c6ef70 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java
@@ -1,6 +1,6 @@
 package com.gkhy.safePlatform.config.security;
 
-import com.gkhy.safePlatform.account.rpc.apimodel.NameService;
+import com.gkhy.safePlatform.account.rpc.apimodel.UserAccountService;
 import com.gkhy.safePlatform.config.security.customzie.CustomizeAccessDeniedHandler;
 import com.gkhy.safePlatform.config.security.customzie.CustomizeAuthenticationEntryPoint;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -14,6 +14,7 @@
 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
 
@@ -30,12 +31,8 @@
     @Resource
     private CustomizeAuthenticationEntryPoint authenticationEntryPoint;
 
-//    @Resource
-//    private TokenAuthenticationFilter tokenAuthenticationFilter;
-
-    @DubboReference(check = false)
-    private NameService nameService;
-
+    @Resource
+    private TokenAuthenticationFilter tokenAuthenticationFilter;
 
 
 
@@ -48,15 +45,15 @@
         // 关闭session
         http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
         // 登录json放行
-        http.authorizeRequests().anyRequest().permitAll();
+        http.authorizeRequests().antMatchers("/auth/login").permitAll();
         // 关闭
         http.headers().cacheControl();
         // jwt过滤器
-//        http.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
+        http.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
         // 没有登录,没有权限 => 自定义返回
         http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).accessDeniedHandler(accessDeniedHandler);
         // 请求认证访问
-//        http.authorizeRequests().anyRequest().authenticated();
+        http.authorizeRequests().anyRequest().authenticated();
         // 允许跨域访问
         http.cors();
 
@@ -80,8 +77,7 @@
     @Bean
     @Qualifier("myUserDetailService")
     protected UserDetailsService userDetailsService(){
-//        return username -> nameService.getUserDetailsByUsername(username);
-        return null;
+        return (username)-> (UserDetails) new Object();
     }
 
 

--
Gitblit v1.9.2