提交 56751368 编写于 作者: A aeizzz

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

上级 c48bc207
......@@ -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:
......
......@@ -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:
......
......@@ -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;
......
......@@ -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());
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -249,6 +249,8 @@
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active>
<nacos.username>nacos</nacos.username>
<nacos.password>nacos</nacos.password>
</properties>
<activation>
<!-- 默认环境 -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册