close #I6AIC7 pigx-register支持开启认证模式

This commit is contained in:
aeizzz 2023-01-14 19:01:58 +08:00
parent c48bc207ea
commit 56751368d4
10 changed files with 31 additions and 4 deletions

View File

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

View File

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

View File

@ -43,7 +43,7 @@ public class PigNacosApplication {
*/
private static boolean initEnv() {
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_ENABLED, "false");
return true;

View File

@ -16,6 +16,7 @@
package com.alibaba.nacos.config;
import com.alibaba.nacos.console.filter.XssFilter;
import com.alibaba.nacos.core.code.ControllerMethodsCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
@ -39,7 +40,7 @@ import java.time.ZoneId;
*/
@Component
@EnableScheduling
@PropertySource("/application.properties")
@PropertySource("/application.yml")
public class ConsoleConfig {
@Autowired
@ -64,11 +65,18 @@ public class ConsoleConfig {
config.addAllowedHeader("*");
config.setMaxAge(18000L);
config.addAllowedMethod("*");
config.addAllowedOriginPattern("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
@Bean
public XssFilter xssFilter() {
return new XssFilter();
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString());

View File

@ -2,6 +2,8 @@ server:
port: 8848 #如何修改 pig-register 启动端口 >: https://t.cn/A6XGvTdb
tomcat:
basedir: logs
error:
include-message: always
db:
num: 1
@ -14,12 +16,15 @@ db:
nacos:
core:
auth:
server:
identity:
key: serverIdentity
value: security
plugin.nacos.token.secret.key: SecretKey012345678901234567890123456789012345678901234567890123456789
enabled: false
system.type: nacos
security:
ignore:
urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
urls: /actuator/**,/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
spring:
datasource:

View File

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

View File

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

View File

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

View File

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

View File

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