🔒 Fixing security issues. 开启nacos 认证

This commit is contained in:
lbw 2023-08-22 21:47:27 +08:00
parent f99dbbd90c
commit 95d0091c3e
9 changed files with 19 additions and 7 deletions

View File

@ -6,6 +6,8 @@ spring:
name: @artifactId@ name: @artifactId@
cloud: cloud:
nacos: nacos:
username: @nacos.username@
password: @nacos.password@
discovery: discovery:
server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
config: config:

View File

@ -6,6 +6,8 @@ spring:
name: @artifactId@ name: @artifactId@
cloud: cloud:
nacos: nacos:
username: @nacos.username@
password: @nacos.password@
discovery: discovery:
server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
watch: watch:

View File

@ -43,7 +43,7 @@ public class PigNacosApplication {
*/ */
private static boolean initEnv() { private static boolean initEnv() {
System.setProperty(ConfigConstants.STANDALONE_MODE, "true"); System.setProperty(ConfigConstants.STANDALONE_MODE, "true");
System.setProperty(ConfigConstants.AUTH_ENABLED, "false"); System.setProperty(ConfigConstants.AUTH_ENABLED, "true");
System.setProperty(ConfigConstants.LOG_BASEDIR, "logs"); System.setProperty(ConfigConstants.LOG_BASEDIR, "logs");
System.setProperty(ConfigConstants.LOG_ENABLED, "false"); System.setProperty(ConfigConstants.LOG_ENABLED, "false");
System.setProperty(ConfigConstants.NACOS_CONTEXT_PATH, "/nacos"); System.setProperty(ConfigConstants.NACOS_CONTEXT_PATH, "/nacos");

View File

@ -16,6 +16,10 @@ db:
nacos: nacos:
core: core:
auth: auth:
server:
identity:
key: serverIdentity
value: security
plugin.nacos.token.secret.key: SecretKey012345678901234567890123456789012345678901234567890123456789 plugin.nacos.token.secret.key: SecretKey012345678901234567890123456789012345678901234567890123456789
enabled: false enabled: false
system.type: nacos system.type: nacos

View File

@ -6,6 +6,8 @@ spring:
name: @artifactId@ name: @artifactId@
cloud: cloud:
nacos: nacos:
username: @nacos.username@
password: @nacos.password@
discovery: discovery:
server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
config: config:

View File

@ -6,6 +6,8 @@ spring:
name: @artifactId@ name: @artifactId@
cloud: cloud:
nacos: nacos:
username: @nacos.username@
password: @nacos.password@
discovery: discovery:
server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
config: config:

View File

@ -6,6 +6,8 @@ spring:
name: @artifactId@ name: @artifactId@
cloud: cloud:
nacos: nacos:
username: @nacos.username@
password: @nacos.password@
discovery: discovery:
server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
config: config:

View File

@ -6,6 +6,8 @@ spring:
name: @artifactId@ name: @artifactId@
cloud: cloud:
nacos: nacos:
username: @nacos.username@
password: @nacos.password@
discovery: discovery:
server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848} server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
config: config:
@ -14,9 +16,3 @@ spring:
import: import:
- optional:nacos:application-@profiles.active@.yml - optional:nacos:application-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml - optional:nacos:${spring.application.name}-@profiles.active@.yml
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://pig-mysql:3306/pig_job?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true

View File

@ -262,6 +262,8 @@
<properties> <properties>
<!-- 环境标识,需要与配置文件的名称相对应 --> <!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active> <profiles.active>dev</profiles.active>
<nacos.username>nacos</nacos.username>
<nacos.password>nacos</nacos.password>
</properties> </properties>
<activation> <activation>
<!-- 默认环境 --> <!-- 默认环境 -->