✨ pigx-register支持开启认证模式

This commit is contained in:
lbw committed 2023-01-14 09:44:49 +08:00
1 parent 701a97184d
commit 39a7a4ebf8
21 files changed
+60 -26

No files matched your search

@@ -6,6 +6,8 @@ spring:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-register}:${NACOS_PORT:8848}
config:
+2 -6
View File
@@ -1,17 +1,13 @@
server:
port: 3000
security:
api:
encrypt:
aesKey: 'pigxpigxpigxpigx'
spring:
application:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-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:pigx-register}:${NACOS_PORT:8848}
config:
@@ -43,7 +43,7 @@ public class PigxNacosApplication {
*/
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, "true");
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,17 @@ 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());
@@ -1,8 +1,9 @@
server:
port: 8848
port: 18848
tomcat:
basedir: logs
error:
include-message: always
db:
num: 1
user: ${MYSQL_USER:root}
@@ -13,25 +14,29 @@ db:
nacos:
core:
auth:
server:
identity:
key: serverIdentity
value: security
system.type: nacos
plugin.nacos.token.secret.key: SecretKey012345678901234567890123456789012345678901234567890123456789
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:
platform: mysql #这个过期属性不能修改,nacos 代码对此有硬编码
security:
enabled: true
boot: # 接入 spring boot admin
boot: # 接入 spring boot admin
admin:
client:
url: http://pigx-monitor:5001
username: pig
password: pig
instance:
prefer-ip: true
service-host-type: ip
application:
name: @project.artifactId@
@@ -39,20 +39,19 @@ public class ClientDetailsInitRunner implements InitializingBean {
private final RedisTemplate redisTemplate;
/**
* WebServerInitializedEvent
* 使用 TransactionalEventListener 时启动时无法获取到事件
* WebServerInitializedEvent 使用 TransactionalEventListener 时启动时无法获取到事件
*/
@Async
@Order
@EventListener({ WebServerInitializedEvent.class })
public void WebServerInit(){
public void WebServerInit() {
this.initClientDetails();
}
@Async
@Order
@TransactionalEventListener({ ClientDetailsInitEvent.class})
@TransactionalEventListener({ ClientDetailsInitEvent.class })
public void initClientDetails() {
log.debug("初始化客户端信息开始 ");
@@ -60,18 +60,15 @@ public class DynamicRouteInitRunner implements InitializingBean {
private final RedisMessageListenerContainer listenerContainer;
/**
* WebServerInitializedEvent
* 使用 TransactionalEventListener 时启动时无法获取到事件
* WebServerInitializedEvent 使用 TransactionalEventListener 时启动时无法获取到事件
*/
@Async
@Order
@EventListener({ WebServerInitializedEvent.class })
public void WebServerInit(){
public void WebServerInit() {
this.initRoute();
}
@Async
@Order
@TransactionalEventListener({ DynamicRouteInitEvent.class })
@@ -6,6 +6,8 @@ spring:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-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:pigx-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:pigx-register}:${NACOS_PORT:8848}
config:
@@ -13,4 +15,4 @@ spring:
config:
import:
- optional:nacos:application-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml
@@ -9,6 +9,8 @@ spring:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-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:pigx-register}:${NACOS_PORT:8848}
service: @artifactId@
@@ -6,6 +6,8 @@ spring:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-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:pigx-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:pigx-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:pigx-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:pigx-register}:${NACOS_PORT:8848}
config:
@@ -8,6 +8,8 @@ spring:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-register}:${NACOS_PORT:8848}
@@ -38,4 +40,4 @@ auth:
sentinel:
dashboard:
version: @project.version@
version: @project.version@
@@ -9,6 +9,8 @@ spring:
name: @artifactId@
cloud:
nacos:
username: @nacos.username@
password: @nacos.password@
discovery:
server-addr: ${NACOS_HOST:pigx-register}:${NACOS_PORT:8848}
metadata:
+3 -1
View File
@@ -121,7 +121,7 @@
<module>pigx-common</module>
<module>pigx-visual</module>
<module>pigx-app-server</module>
</modules>
</modules>
<dependencyManagement>
<dependencies>
@@ -292,6 +292,8 @@
<properties>
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active>
<nacos.username>nacos</nacos.username>
<nacos.password>nacos</nacos.password>
</properties>
<activation>
<!-- 默认环境 -->