From 98a5985467a0d4d85f42f567b27720975bde2fba Mon Sep 17 00:00:00 2001
From: Richie <280645618@qq.com>
Date: Sun, 21 Jan 2024 18:46:58 +0800
Subject: [PATCH] update
---
api/pom.xml | 8 ++++++
api/src/main/resources/application.yaml | 25 ++++++++++++++++---
tao-oms/pom.xml | 17 +++++++------
.../com/qihang/tao/TaoOmsApplication.java | 2 ++
tao-oms/src/main/resources/application.yaml | 11 ++++++++
5 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/api/pom.xml b/api/pom.xml
index 8f291c05..76f6608d 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -48,6 +48,14 @@
4.0.0
+
+
+
+
+
+
+
+
diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml
index 430595c7..f6aa5da1 100644
--- a/api/src/main/resources/application.yaml
+++ b/api/src/main/resources/application.yaml
@@ -4,7 +4,12 @@ server:
spring:
application:
name: api-service
-
+ security:
+ user:
+ name: admin
+ password: password
+ basic:
+ enabled: true
cloud:
nacos:
discovery:
@@ -19,6 +24,20 @@ spring:
- id: tao_oms_route
uri: lb://tao-oms # lb 表示从 nacos 中按照名称获取微服务,并遵循负载均衡策略,user-service 对应用户微服务应用名
predicates:
- - Path=/tao-api/** # 使用断言
+ - Path=/tao-service/** # 使用断言
filters:
- - StripPrefix=1 # 使用过滤器
\ No newline at end of file
+ - StripPrefix=1 # 使用过滤器
+# - name: Security # 添加安全过滤器
+# args:
+# springSecurityFilterChain: # 配置Spring Security过滤器链
+# order: 0
+# securityMatcher: org.springframework.security.web.util.matcher.AntPathRequestMatcher
+# securityFilter: org.springframework.security.web.server.SecurityWebFilterChainFilter
+# securityContextRepository: org.springframework.security.web.server.context.ServerSecurityContextRepository
+# serverAccessDeniedHandler: org.springframework.security.web.server.access.AccessDeniedHandlerImpl
+# serverAuthenticationEntryPoint: org.springframework.security.web.server.authentication.BasicAuthenticationEntryPoint
+
+## 授权规则
+#security:
+# rules:
+# - pattern: /api/tao-service/** # 定义需要授权的URL模式
\ No newline at end of file
diff --git a/tao-oms/pom.xml b/tao-oms/pom.xml
index 8c9da502..cdbb9e91 100644
--- a/tao-oms/pom.xml
+++ b/tao-oms/pom.xml
@@ -51,13 +51,16 @@
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
-
-
- junit
- junit
- 4.13.2
- test
-
+
+
+
+
+
+
+
+
+
+
diff --git a/tao-oms/src/main/java/com/qihang/tao/TaoOmsApplication.java b/tao-oms/src/main/java/com/qihang/tao/TaoOmsApplication.java
index 921db162..f406dedd 100644
--- a/tao-oms/src/main/java/com/qihang/tao/TaoOmsApplication.java
+++ b/tao-oms/src/main/java/com/qihang/tao/TaoOmsApplication.java
@@ -4,11 +4,13 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
/**
* Hello world!
*
*/
+//@EnableWebSecurity
@EnableDiscoveryClient
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class TaoOmsApplication
diff --git a/tao-oms/src/main/resources/application.yaml b/tao-oms/src/main/resources/application.yaml
index ad3d4578..e9841eba 100644
--- a/tao-oms/src/main/resources/application.yaml
+++ b/tao-oms/src/main/resources/application.yaml
@@ -9,6 +9,17 @@ spring:
- nacos:qihang-oms.yaml?refresh=true
application:
name: tao-oms
+ security:
+ user:
+ name: admin
+ password: password
+ basic:
+ enabled: true
+
+# 授权规则
+security:
+ rules:
+ - pattern: /api/** # 定义需要授权的URL模式
server:
port: 8081
\ No newline at end of file