ソースを参照

高危漏洞修复

lvzhikai 4 年 前
コミット
b562f6b28f
共有3 個のファイルを変更した27 個の追加30 個の削除を含む
  1. 5 0
      pom.xml
  2. 14 0
      src/main/java/com/unis/module/eureka/SpringSecurityConfig.java
  3. 8 30
      src/main/resources/application.yml

+ 5 - 0
pom.xml

@@ -36,6 +36,11 @@
36 36
 			<artifactId>spring-boot-starter-test</artifactId>
37 37
 			<scope>test</scope>
38 38
 		</dependency>
39
+
40
+		<dependency>
41
+			<groupId>org.springframework.boot</groupId>
42
+			<artifactId>spring-boot-starter-security</artifactId>
43
+		</dependency>
39 44
 	</dependencies>
40 45
 
41 46
 	<dependencyManagement>

+ 14 - 0
src/main/java/com/unis/module/eureka/SpringSecurityConfig.java

@@ -0,0 +1,14 @@
1
+package com.unis.module.eureka;
2
+
3
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
4
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
5
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
6
+
7
+@EnableWebSecurity
8
+public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
9
+    @Override
10
+    protected void configure(HttpSecurity http) throws Exception {
11
+        http.csrf().disable();
12
+        http.authorizeRequests().anyRequest().authenticated().and().httpBasic(); //开启认证
13
+    }
14
+}

+ 8 - 30
src/main/resources/application.yml

@@ -1,12 +1,13 @@
1
-spring:
2
-  profiles:
3
-    active: local_dev
4 1
 server:
5
-  port: 9711
6
----
2
+  port: 9001
7 3
 # 本地开发环境
8 4
 spring:
9
-  profiles: local_dev
5
+  security:
6
+    user:
7
+      #你的用户名
8
+      name: A1D2M3in90
9
+      #你的密码
10
+      password: a8d7m6IN23
10 11
 #eurekaServer
11 12
 eureka:
12 13
   instance:
@@ -17,7 +18,7 @@ eureka:
17 18
     register-with-eureka: false
18 19
     fetch-registry: false
19 20
     service-url:
20
-      defaultZone: http://172.16.0.46:9711/eureka/
21
+      defaultZone: http://A1D2M3in90:a8d7m6IN23@localhost:9001/eureka/
21 22
   server:
22 23
     # 关闭自我保护机制(不关闭会在所有服务连接异常85%后不在注销服务)
23 24
     enable-self-preservation: false
@@ -27,27 +28,4 @@ management:
27 28
   endpoints:
28 29
     web:
29 30
       exposure:
30
-        include: '*'
31
-#  endpoint:
32
-#    health:
33
-#      show-details: always
34
----
35
-# 部署环境
36
-spring:
37
-  profiles: prod
38
-eureka:
39
-  instance:
40
-    prefer-ip-address: true
41
-  client:
42
-    register-with-eureka: false
43
-    fetch-registry: false
44
-    service-url:
45
-      defaultZone: http://${spring.cloud.client.ip-address}:${server.port}/eureka/
46
-  server:
47
-    enable-self-preservation: false
48
-    eviction-interval-timer-in-ms: 30000
49
-management:
50
-  endpoints:
51
-    web:
52
-      exposure:
53 31
         include: '*'