fanxw před 1 rokem
rodič
revize
914030e78c

+ 4 - 0
pom.xml

@@ -48,6 +48,10 @@
48 48
 			<artifactId>spring-boot-starter-test</artifactId>
49 49
 			<scope>test</scope>
50 50
 		</dependency>
51
+		<dependency>  
52
+		    <groupId>org.springframework.boot</groupId>  
53
+		    <artifactId>spring-boot-starter-security</artifactId>  
54
+		</dependency>
51 55
 
52 56
 		<!-- swagger2 -->
53 57
 		<dependency>

+ 25 - 0
src/main/java/com/chinaitop/depot/WebSecurityConfig.java

@@ -0,0 +1,25 @@
1
+package com.chinaitop.depot;
2
+
3
+import org.springframework.context.annotation.Configuration;
4
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
5
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
6
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
7
+
8
+@Configuration
9
+@EnableWebSecurity
10
+public class WebSecurityConfig 
11
+extends WebSecurityConfigurerAdapter 
12
+{
13
+
14
+	@Override
15
+    protected void configure(HttpSecurity http) throws Exception {
16
+
17
+		http.authorizeRequests()
18
+		.antMatchers("/**")
19
+		.permitAll() //允许所有用户访问所有资源
20
+        .and()
21
+        .csrf().disable(); // 禁用CSRF(防止伪造的跨域攻击)
22
+
23
+        super.configure(http);
24
+    }
25
+}

+ 6 - 2
src/main/resources/bootstrap.yml

@@ -7,7 +7,7 @@ server:
7 7
 eureka:
8 8
   client:
9 9
     service-url:
10
-      defaultZone: http://localhost:9001/eureka/
10
+      defaultZone: http://tj_admin:Admin_1234@${eureka.instance.hostname}:9001/eureka/
11 11
   instance:
12 12
     hostname: 172.16.0.16
13 13
     prefer-ip-address: true
@@ -20,6 +20,10 @@ eureka:
20 20
 mybatis:
21 21
   config-location: classpath:mybatis/mybatis-config.xml
22 22
 
23
+management:
24
+  server:
25
+    port: -1
26
+
23 27
 spring:
24 28
   application:
25 29
     name: depot-agent
@@ -50,7 +54,7 @@ spring:
50 54
     static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.upload-path}
51 55
 
52 56
 web:
53
-  upload-path: /home/depot/depot-web/apache-tomcat-8.0.53/webapps/ROOT/WEB-INF/classes/static
57
+  upload-path: /home/depot/depot-web/depot-file
54 58
 
55 59
 cxf:
56 60
   path: /archive