fanxw 1 vuosi sitten
vanhempi
commit
4cec69e942

+ 4 - 0
pom.xml

@@ -43,6 +43,10 @@
43 43
             <groupId>org.springframework.cloud</groupId>
44 44
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
45 45
         </dependency>
46
+        <dependency>  
47
+		    <groupId>org.springframework.boot</groupId>  
48
+		    <artifactId>spring-boot-starter-security</artifactId>  
49
+		</dependency>
46 50
 
47 51
         <!-- 引入spring boot自带的pagehelper插件 -->
48 52
         <dependency>

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

@@ -0,0 +1,26 @@
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
+    }
26
+}

+ 16 - 0
src/main/java/com/chinaitop/depot/system/controller/UserInfoController.java

@@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
24 24
 import org.springframework.beans.factory.annotation.Autowired;
25 25
 import org.springframework.beans.factory.annotation.Value;
26 26
 import org.springframework.http.MediaType;
27
+import org.springframework.web.bind.annotation.RequestBody;
27 28
 import org.springframework.web.bind.annotation.RequestMapping;
28 29
 import org.springframework.web.bind.annotation.RequestMethod;
29 30
 import org.springframework.web.bind.annotation.RequestParam;
@@ -1031,4 +1032,19 @@ public class UserInfoController {
1031 1032
 		}
1032 1033
 		return map;
1033 1034
 	}
1035
+
1036
+	@RequestMapping(value="/checkPwdBlack", method = RequestMethod.POST)
1037
+	@ApiOperation(value="查询密码字符串中是否包含密码黑名单里面的内容", notes = "密码可用就返回true")
1038
+	@ApiImplicitParams({
1039
+		@ApiImplicitParam(name = "newpwd", value = "密码", paramType = "form")
1040
+	})
1041
+	public boolean checkPwdBlack(String newpwd) {
1042
+		boolean flag = false;
1043
+		try {
1044
+			flag = userInfoService.checkPwdBlack(newpwd);
1045
+		} catch (Exception e) {
1046
+			e.printStackTrace();
1047
+		}
1048
+		return flag;
1049
+	}
1034 1050
 }

+ 7 - 0
src/main/java/com/chinaitop/depot/system/mapper/UserInfoMapper.java

@@ -67,4 +67,11 @@ public interface UserInfoMapper {
67 67
 	void deleteKeeperHouseObj(@Param("keepid") Integer keepid);
68 68
 
69 69
 	List<Map<Object, Object>> sptgetUserInfo(Map<Object, Object> map);
70
+
71
+	/**
72
+	 * 查询密码字符串中是否包含密码黑名单里面的内容
73
+	 * @param pwd
74
+	 * @return
75
+	 */
76
+	List<String> selectPwdBlack(String pwd);
70 77
 }

+ 4 - 0
src/main/java/com/chinaitop/depot/system/mapper/UserInfoMapper.xml

@@ -791,4 +791,8 @@
791 791
 	order by ui.real_name asc
792 792
   </select>
793 793
   
794
+  <select id="selectPwdBlack" parameterType="java.lang.String" resultType="java.util.Map">
795
+	select pwd from dict_pwd_blacklist where INSTR(#{pwd,jdbcType=VARCHAR}, pwd) > 0
796
+  </select>
797
+  
794 798
 </mapper>

+ 8 - 0
src/main/java/com/chinaitop/depot/system/service/UserInfoService.java

@@ -144,4 +144,12 @@ public interface UserInfoService {
144 144
 	String checkRepeat(Integer orgId, String sfzhm, Integer userId, String type) throws Exception;
145 145
 
146 146
 	List<Map<Object, Object>> sptgetUserInfo(Map<Object, Object> map);
147
+
148
+	/**
149
+	 * 查询密码字符串中是否包含密码黑名单里面的内容
150
+	 * @param pwd
151
+	 * @return
152
+	 * @throws Exception
153
+	 */
154
+	boolean checkPwdBlack(String pwd) throws Exception;
147 155
 }

+ 10 - 0
src/main/java/com/chinaitop/depot/system/service/impl/UserInfoServiceImpl.java

@@ -346,4 +346,14 @@ public class UserInfoServiceImpl implements UserInfoService {
346 346
 		return UserInfoMapper.sptgetUserInfo(map);
347 347
 	}
348 348
 
349
+	@Override
350
+	public boolean checkPwdBlack(String pwd) throws Exception {
351
+		boolean flag = false;
352
+		List<String> list = UserInfoMapper.selectPwdBlack(pwd);
353
+		if (null == list || list.size() == 0) {
354
+			flag = true;
355
+		}
356
+		return flag;
357
+	}
358
+
349 359
 }

+ 21 - 14
src/main/resources/application.properties

@@ -1,28 +1,35 @@
1 1
 #端口
2 2
 server.port=9023
3 3
 
4
+eureka.instance.hostname=172.16.0.16
5
+#eureka.instance.hostname=localhost
6
+eureka.client.serviceUrl.defaultZone=http://tj_admin:Admin_1234@${eureka.instance.hostname}:9001/eureka/
7
+#eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:9001/eureka/
8
+# 每隔10s发送一次心跳(默认30s)
9
+eureka.instance.lease-renewal-interval-in-seconds=10
10
+# 告知服务端30秒还未收到心跳的话,就将该服务移除列表(默认90s)
11
+eureka.instance.lease-expiration-duration-in-seconds=30
12
+eureka.instance.status-page-url=http://${eureka.instance.hostname}:${server.port}/swagger-ui.html
13
+#eureka.instance.status-page-url=http://${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:${server.port}/swagger-ui.html
14
+
15
+management.server.port=-1
16
+#management.endpoints.enabled-by-default=false
17
+
18
+#spring.security.basic.enabled=true
19
+# 用户名
20
+#spring.security.user.name=tj_admin
21
+# 用户密码
22
+#spring.security.user.password=Admin_1234
23
+
4 24
 #gbase8s的数据库配置
5 25
 spring.application.name=depot-system
6 26
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
7 27
 spring.datasource.url=jdbc:gbasedbt-sqli://101.36.160.140:19089/depot:INFORMIXSERVER=ol_gbasedbt1210;NEWCODESET=GB18030,GB18030-2000,5488;DB_LOCALE=zh_cn.GB18030-2000;GL_USEGLU=1;IFX_USE_STRENC=true;characterEncoding=utf8;
8 28
 spring.datasource.username=gbasedbt
9 29
 spring.datasource.password=cDbK2S0go8
10
-#spring.datasource.url=jdbc:gbasedbt-sqli://111.164.113.172:666/depot:INFORMIXSERVER=gbaseserver;NEWCODESET=GBK,8859-1,819;GL_USEGLU=1;IFX_USE_STRENC=true;characterEncoding=utf8;
11
-#spring.datasource.username=gbasedbt
12
-#spring.datasource.password=GBase123
13 30
 spring.datasource.driverClassName=com.gbasedbt.jdbc.IfxDriver
14 31
 mybatis.config-location=classpath:mybatis/mybatis-config.xml
15 32
 
16
-eureka.instance.hostname=localhost
17
-# 每隔10s发送一次心跳(默认30s)
18
-eureka.instance.lease-renewal-interval-in-seconds=10
19
-# 告知服务端30秒还未收到心跳的话,就将该服务移除列表(默认90s)
20
-eureka.instance.lease-expiration-duration-in-seconds=30
21
-eureka.client.serviceUrl.defaultZone=http://172.16.0.16:9001/eureka/
22
-eureka.instance.status-page-url=http://172.16.0.16:9023/swagger-ui.html
23
-
24
-
25
-
26 33
 # Redis数据库索引(默认为0)
27 34
 spring.redis.database=3
28 35
 # Redis服务器地址
@@ -45,7 +52,7 @@ spring.redis.timeout=3000
45 52
 spring.session.store-type=redis
46 53
 
47 54
 #图片地址
48
-web.upload-path=D:/depotImg/
55
+web.upload-path=/home/depot/depot-web/depot-file
49 56
 spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.upload-path}
50 57
 #设置全局变量判断是云端还是库端;1云端,2本地
51 58
 localOrCloud=1