配置文件数据库和redis账号密码加密
This commit is contained in:
parent
40c3cc5498
commit
94552bc1b1
|
|
@ -88,6 +88,13 @@
|
||||||
<version>${swagger.fox.version}</version>
|
<version>${swagger.fox.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--加密依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,46 @@
|
||||||
package com.bonus.sgzb.gateway;
|
package com.bonus.sgzb.gateway;
|
||||||
|
|
||||||
|
import org.jasypt.encryption.StringEncryptor;
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网关启动程序
|
* 网关启动程序
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
||||||
public class SgzbGatewayApplication
|
public class SgzbGatewayApplication implements CommandLineRunner {
|
||||||
{
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
SpringApplication.run(SgzbGatewayApplication.class, args);
|
SpringApplication.run(SgzbGatewayApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 网关启动成功 ლ(´ڡ`ლ)゙ \n");
|
System.out.println("(♥◠‿◠)ノ゙ 网关启动成功 ლ(´ڡ`ლ)゙ \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StringEncryptor encryptor;
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
String nacos = encrypt("Jjsp@nacos2023" );
|
||||||
|
String mysqlNm = encrypt("root" );
|
||||||
|
String mysqlPs = encrypt("Bonus@admin123!" );
|
||||||
|
String redis = encrypt("Dszbns@Redis123!" );
|
||||||
|
System.err.println( "nacos原始明文密码加密后的结果为:" + nacos );
|
||||||
|
System.err.println( "mysqlNm原始明文密码加密后的结果为:" + mysqlNm );
|
||||||
|
System.err.println( "mysqlPs原始明文密码加密后的结果为:" + mysqlPs );
|
||||||
|
System.err.println( "redis原始明文密码加密后的结果为:" + redis );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String encrypt( String originPassord ) {
|
||||||
|
return encryptor.encrypt( originPassord );
|
||||||
|
}
|
||||||
|
|
||||||
|
private String decrypt( String encryptedPassword ) {
|
||||||
|
return encryptor.decrypt( encryptedPassword );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ spring:
|
||||||
nacos:
|
nacos:
|
||||||
enabled: true
|
enabled: true
|
||||||
nacos:
|
nacos:
|
||||||
|
username: nacos
|
||||||
|
password: ENC(gQ6+/ZE1DwP8W8IFKQDEllLgAJIOIZ5CBy334W5W/uCdyCrNosOWVuCzIPsm/ZF9)
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 192.168.0.14:8848
|
server-addr: 192.168.0.14:8848
|
||||||
|
|
@ -53,3 +55,8 @@ spring:
|
||||||
groupId: DEFAULT_GROUP
|
groupId: DEFAULT_GROUP
|
||||||
data-type: json
|
data-type: json
|
||||||
rule-type: gw-flow
|
rule-type: gw-flow
|
||||||
|
|
||||||
|
#加密组件
|
||||||
|
jasypt:
|
||||||
|
encryptor:
|
||||||
|
password: Encrypt
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,13 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--加密依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package com.bonus.sgzb;
|
||||||
import com.bonus.sgzb.common.security.annotation.EnableCustomConfig;
|
import com.bonus.sgzb.common.security.annotation.EnableCustomConfig;
|
||||||
import com.bonus.sgzb.common.security.annotation.EnableRyFeignClients;
|
import com.bonus.sgzb.common.security.annotation.EnableRyFeignClients;
|
||||||
import com.bonus.sgzb.common.swagger.annotation.EnableCustomSwagger2;
|
import com.bonus.sgzb.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
@ -17,6 +18,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
|
@EnableEncryptableProperties
|
||||||
public class SgzbBaseApplication
|
public class SgzbBaseApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,13 @@
|
||||||
<version>5.8.16</version>
|
<version>5.8.16</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--加密依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package com.bonus.sgzb.material;
|
||||||
import com.bonus.sgzb.common.security.annotation.EnableCustomConfig;
|
import com.bonus.sgzb.common.security.annotation.EnableCustomConfig;
|
||||||
import com.bonus.sgzb.common.security.annotation.EnableRyFeignClients;
|
import com.bonus.sgzb.common.security.annotation.EnableRyFeignClients;
|
||||||
import com.bonus.sgzb.common.swagger.annotation.EnableCustomSwagger2;
|
import com.bonus.sgzb.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
@ -17,6 +18,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
|
@EnableEncryptableProperties
|
||||||
public class SgzbMaterialApplication
|
public class SgzbMaterialApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,13 @@
|
||||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
<version>3.1.423</version>
|
<version>3.1.423</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--加密依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.sgzb.system;
|
package com.bonus.sgzb.system;
|
||||||
|
|
||||||
|
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import com.bonus.sgzb.common.security.annotation.EnableCustomConfig;
|
import com.bonus.sgzb.common.security.annotation.EnableCustomConfig;
|
||||||
|
|
@ -15,6 +16,7 @@ import com.bonus.sgzb.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableEncryptableProperties
|
||||||
public class SgzbSystemApplication
|
public class SgzbSystemApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue