⬆️ Upgrading dependencies. nacos 1.4.0 https://gitee.com/log4j/pig/issues/I249CF
@ -0,0 +1,36 @@
|
||||
package com.pig4cloud.pig.common.core.mybatis;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2020/10/12
|
||||
*/
|
||||
public class SqlFilterArgumentResolverTest {
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgument() {
|
||||
String param = "delete create_time";
|
||||
|
||||
System.out.println(clear(param));
|
||||
}
|
||||
|
||||
private String clear(String param) {
|
||||
if (StrUtil.isBlank(param)) {
|
||||
return StrUtil.trim(param);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < param.length(); i++) {
|
||||
char c = param.charAt(i);
|
||||
if (Character.isJavaIdentifierPart(c)) {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
@ -26,11 +26,16 @@
|
||||
<name>pig-register</name>
|
||||
<description>nacos 注册配置中心</description>
|
||||
|
||||
<properties>
|
||||
<jjwt.version>0.11.2</jjwt.version>
|
||||
<nacos.version>1.4.0</nacos.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud.nacos</groupId>
|
||||
<artifactId>nacos-config</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
@ -39,13 +44,13 @@
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud.nacos</groupId>
|
||||
<artifactId>nacos-naming</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud.nacos</groupId>
|
||||
<artifactId>nacos-istio</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -54,18 +59,18 @@
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>0.10.5</version>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>0.10.5</version>
|
||||
<version>${jjwt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.10.5</version>
|
||||
<version>${jjwt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package com.alibaba.nacos;
|
||||
|
||||
import com.alibaba.nacos.config.ConfigConstants;
|
||||
import com.alibaba.nacos.utils.StartUpEnvInitUtil;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@ -31,8 +31,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
public class PigNacosApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty(ConfigConstants.STANDALONE_MODE, "true");
|
||||
System.setProperty(ConfigConstants.AUTH_ENABLED, "false");
|
||||
StartUpEnvInitUtil.init();
|
||||
SpringApplication.run(PigNacosApplication.class, args);
|
||||
}
|
||||
|
||||
|
@ -35,4 +35,14 @@ public interface ConfigConstants {
|
||||
*/
|
||||
String AUTH_ENABLED = "nacos.core.auth.enabled";
|
||||
|
||||
/**
|
||||
* 开启 MCP server
|
||||
*/
|
||||
String MCP_SERVER_ENABLED = "nacos.istio.mcp.server.enabled";
|
||||
|
||||
/**
|
||||
* nacos tomcat basedir
|
||||
*/
|
||||
String NACOS_TOMCAT_BASEDIR = "server.tomcat.basedir";
|
||||
|
||||
}
|
||||
|
0
pig-register/src/main/java/com/alibaba/nacos/controller/HealthController.java
Normal file → Executable file
4
pig-register/src/main/java/com/alibaba/nacos/controller/NamespaceController.java
Normal file → Executable file
@ -16,14 +16,14 @@
|
||||
|
||||
package com.alibaba.nacos.controller;
|
||||
|
||||
import com.alibaba.nacos.auth.annotation.Secured;
|
||||
import com.alibaba.nacos.auth.common.ActionTypes;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.alibaba.nacos.config.server.model.TenantInfo;
|
||||
import com.alibaba.nacos.config.server.service.repository.PersistService;
|
||||
import com.alibaba.nacos.model.Namespace;
|
||||
import com.alibaba.nacos.model.NamespaceAllInfo;
|
||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||
import com.alibaba.nacos.core.auth.ActionTypes;
|
||||
import com.alibaba.nacos.core.auth.Secured;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
11
pig-register/src/main/java/com/alibaba/nacos/controller/PermissionController.java
Normal file → Executable file
@ -16,19 +16,14 @@
|
||||
|
||||
package com.alibaba.nacos.controller;
|
||||
|
||||
import com.alibaba.nacos.auth.annotation.Secured;
|
||||
import com.alibaba.nacos.auth.common.ActionTypes;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
||||
import com.alibaba.nacos.core.auth.ActionTypes;
|
||||
import com.alibaba.nacos.core.auth.Secured;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* Permission operation controller.
|
||||
|
24
pig-register/src/main/java/com/alibaba/nacos/controller/RoleController.java
Normal file → Executable file
@ -16,19 +16,16 @@
|
||||
|
||||
package com.alibaba.nacos.controller;
|
||||
|
||||
import com.alibaba.nacos.auth.annotation.Secured;
|
||||
import com.alibaba.nacos.auth.common.ActionTypes;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
||||
import com.alibaba.nacos.core.auth.ActionTypes;
|
||||
import com.alibaba.nacos.core.auth.Secured;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Role operation controller.
|
||||
@ -57,6 +54,17 @@ public class RoleController {
|
||||
return roleService.getRolesFromDatabase(username, pageNo, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fuzzy matching role name .
|
||||
* @param role role id
|
||||
* @return role list
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.READ)
|
||||
public List<String> searchRoles(@RequestParam String role) {
|
||||
return roleService.findRolesLikeRoleName(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a role to a user
|
||||
*
|
||||
|
2
pig-register/src/main/java/com/alibaba/nacos/controller/ServerStateController.java
Normal file → Executable file
@ -17,7 +17,7 @@
|
||||
package com.alibaba.nacos.controller;
|
||||
|
||||
import com.alibaba.nacos.common.utils.VersionUtils;
|
||||
import com.alibaba.nacos.core.utils.ApplicationUtils;
|
||||
import com.alibaba.nacos.sys.utils.ApplicationUtils;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
21
pig-register/src/main/java/com/alibaba/nacos/controller/UserController.java
Normal file → Executable file
@ -17,6 +17,11 @@
|
||||
package com.alibaba.nacos.controller;
|
||||
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.auth.annotation.Secured;
|
||||
import com.alibaba.nacos.auth.common.ActionTypes;
|
||||
import com.alibaba.nacos.auth.common.AuthConfigs;
|
||||
import com.alibaba.nacos.auth.common.AuthSystemTypes;
|
||||
import com.alibaba.nacos.auth.exception.AccessException;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.alibaba.nacos.common.utils.JacksonUtils;
|
||||
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
||||
@ -28,11 +33,6 @@ import com.alibaba.nacos.security.nacos.users.NacosUser;
|
||||
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
||||
import com.alibaba.nacos.utils.JwtTokenUtils;
|
||||
import com.alibaba.nacos.utils.PasswordEncoderUtil;
|
||||
import com.alibaba.nacos.core.auth.AccessException;
|
||||
import com.alibaba.nacos.core.auth.ActionTypes;
|
||||
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||
import com.alibaba.nacos.core.auth.AuthSystemTypes;
|
||||
import com.alibaba.nacos.core.auth.Secured;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
@ -249,4 +249,15 @@ public class UserController {
|
||||
return rr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fuzzy matching username.
|
||||
* @param username username
|
||||
* @return Matched username
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "users", action = ActionTypes.WRITE)
|
||||
public List<String> searchUsersLikeUsername(@RequestParam String username) {
|
||||
return userDetailsService.findUserLikeUsername(username);
|
||||
}
|
||||
|
||||
}
|
||||
|
2
pig-register/src/main/java/com/alibaba/nacos/exception/ConsoleExceptionHandler.java
Normal file → Executable file
@ -16,8 +16,8 @@
|
||||
|
||||
package com.alibaba.nacos.exception;
|
||||
|
||||
import com.alibaba.nacos.auth.exception.AccessException;
|
||||
import com.alibaba.nacos.common.utils.ExceptionUtil;
|
||||
import com.alibaba.nacos.core.auth.AccessException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
0
pig-register/src/main/java/com/alibaba/nacos/filter/JwtAuthenticationTokenFilter.java
Normal file → Executable file
0
pig-register/src/main/java/com/alibaba/nacos/model/Namespace.java
Normal file → Executable file
0
pig-register/src/main/java/com/alibaba/nacos/model/NamespaceAllInfo.java
Normal file → Executable file
0
pig-register/src/main/java/com/alibaba/nacos/security/nacos/CustomAuthenticationProvider.java
Normal file → Executable file
0
pig-register/src/main/java/com/alibaba/nacos/security/nacos/JwtAuthenticationEntryPoint.java
Normal file → Executable file
12
pig-register/src/main/java/com/alibaba/nacos/security/nacos/JwtTokenManager.java
Normal file → Executable file
@ -16,10 +16,11 @@
|
||||
|
||||
package com.alibaba.nacos.security.nacos;
|
||||
|
||||
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||
import com.alibaba.nacos.auth.common.AuthConfigs;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@ -67,9 +68,8 @@ public class JwtTokenManager {
|
||||
validity = new Date(now + authConfigs.getTokenValidityInSeconds() * 1000L);
|
||||
|
||||
Claims claims = Jwts.claims().setSubject(userName);
|
||||
|
||||
return Jwts.builder().setClaims(claims).setExpiration(validity)
|
||||
.signWith(SignatureAlgorithm.HS256, authConfigs.getSecretKey()).compact();
|
||||
.signWith(Keys.hmacShaKeyFor(authConfigs.getSecretKeyBytes()), SignatureAlgorithm.HS256).compact();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,8 +78,8 @@ public class JwtTokenManager {
|
||||
* @return auth info
|
||||
*/
|
||||
public Authentication getAuthentication(String token) {
|
||||
|
||||
Claims claims = Jwts.parser().setSigningKey(authConfigs.getSecretKey()).parseClaimsJws(token).getBody();
|
||||
Claims claims = Jwts.parserBuilder().setSigningKey(authConfigs.getSecretKeyBytes()).build()
|
||||
.parseClaimsJws(token).getBody();
|
||||
|
||||
List<GrantedAuthority> authorities = AuthorityUtils
|
||||
.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
|
||||
@ -93,7 +93,7 @@ public class JwtTokenManager {
|
||||
* @param token token
|
||||
*/
|
||||
public void validateToken(String token) {
|
||||
Jwts.parser().setSigningKey(authConfigs.getSecretKey()).parseClaimsJws(token);
|
||||
Jwts.parserBuilder().setSigningKey(authConfigs.getSecretKeyBytes()).build().parseClaimsJws(token);
|
||||
}
|
||||
|
||||
}
|
||||
|
4
pig-register/src/main/java/com/alibaba/nacos/security/nacos/NacosAuthConfig.java
Normal file → Executable file
@ -16,10 +16,10 @@
|
||||
|
||||
package com.alibaba.nacos.security.nacos;
|
||||
|
||||
import com.alibaba.nacos.auth.common.AuthConfigs;
|
||||
import com.alibaba.nacos.auth.common.AuthSystemTypes;
|
||||
import com.alibaba.nacos.filter.JwtAuthenticationTokenFilter;
|
||||
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
||||
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||
import com.alibaba.nacos.core.auth.AuthSystemTypes;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
11
pig-register/src/main/java/com/alibaba/nacos/security/nacos/NacosAuthManager.java
Normal file → Executable file
@ -17,13 +17,14 @@
|
||||
package com.alibaba.nacos.security.nacos;
|
||||
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.auth.AuthManager;
|
||||
import com.alibaba.nacos.auth.exception.AccessException;
|
||||
import com.alibaba.nacos.auth.model.Permission;
|
||||
import com.alibaba.nacos.auth.model.User;
|
||||
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
||||
import com.alibaba.nacos.config.server.utils.RequestUtil;
|
||||
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
||||
import com.alibaba.nacos.security.nacos.users.NacosUser;
|
||||
import com.alibaba.nacos.core.auth.AccessException;
|
||||
import com.alibaba.nacos.core.auth.AuthManager;
|
||||
import com.alibaba.nacos.core.auth.Permission;
|
||||
import com.alibaba.nacos.core.auth.User;
|
||||
import com.alibaba.nacos.core.utils.Loggers;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -92,7 +93,7 @@ public class NacosAuthManager implements AuthManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
req.setAttribute(RequestUtil.NACOS_USER_KEY, user);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
8
pig-register/src/main/java/com/alibaba/nacos/security/nacos/roles/NacosRoleServiceImpl.java
Normal file → Executable file
@ -16,6 +16,8 @@
|
||||
|
||||
package com.alibaba.nacos.security.nacos.roles;
|
||||
|
||||
import com.alibaba.nacos.auth.common.AuthConfigs;
|
||||
import com.alibaba.nacos.auth.model.Permission;
|
||||
import com.alibaba.nacos.config.server.auth.PermissionInfo;
|
||||
import com.alibaba.nacos.config.server.auth.PermissionPersistService;
|
||||
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
||||
@ -23,8 +25,6 @@ import com.alibaba.nacos.config.server.auth.RolePersistService;
|
||||
import com.alibaba.nacos.config.server.model.Page;
|
||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
||||
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||
import com.alibaba.nacos.core.auth.Permission;
|
||||
import com.alibaba.nacos.core.utils.Loggers;
|
||||
import io.jsonwebtoken.lang.Collections;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -235,4 +235,8 @@ public class NacosRoleServiceImpl {
|
||||
permissionPersistService.deletePermission(role, resource, action);
|
||||
}
|
||||
|
||||
public List<String> findRolesLikeRoleName(String role) {
|
||||
return rolePersistService.findRolesLikeRoleName(role);
|
||||
}
|
||||
|
||||
}
|
||||
|
2
pig-register/src/main/java/com/alibaba/nacos/security/nacos/users/NacosUser.java
Normal file → Executable file
@ -16,7 +16,7 @@
|
||||
|
||||
package com.alibaba.nacos.security.nacos.users;
|
||||
|
||||
import com.alibaba.nacos.core.auth.User;
|
||||
import com.alibaba.nacos.auth.model.User;
|
||||
|
||||
/**
|
||||
* Nacos User.
|
||||
|
0
pig-register/src/main/java/com/alibaba/nacos/security/nacos/users/NacosUserDetails.java
Normal file → Executable file
7
pig-register/src/main/java/com/alibaba/nacos/security/nacos/users/NacosUserDetailsServiceImpl.java
Normal file → Executable file
@ -16,10 +16,10 @@
|
||||
|
||||
package com.alibaba.nacos.security.nacos.users;
|
||||
|
||||
import com.alibaba.nacos.auth.common.AuthConfigs;
|
||||
import com.alibaba.nacos.config.server.auth.UserPersistService;
|
||||
import com.alibaba.nacos.config.server.model.Page;
|
||||
import com.alibaba.nacos.config.server.model.User;
|
||||
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||
import com.alibaba.nacos.core.utils.Loggers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@ -28,6 +28,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -101,6 +102,10 @@ public class NacosUserDetailsServiceImpl implements UserDetailsService {
|
||||
return userPersistService.findUserByUsername(username);
|
||||
}
|
||||
|
||||
public List<String> findUserLikeUsername(String username) {
|
||||
return userPersistService.findUserLikeUsername(username);
|
||||
}
|
||||
|
||||
public void createUser(String username, String password) {
|
||||
userPersistService.createUser(username, password);
|
||||
}
|
||||
|
10
pig-register/src/main/java/com/alibaba/nacos/utils/JwtTokenUtils.java
Normal file → Executable file
@ -21,9 +21,9 @@ import io.jsonwebtoken.ExpiredJwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.MalformedJwtException;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.SignatureException;
|
||||
import io.jsonwebtoken.UnsupportedJwtException;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import io.jsonwebtoken.security.SecurityException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -126,9 +126,7 @@ public class JwtTokenUtils {
|
||||
* @return auth info
|
||||
*/
|
||||
public Authentication getAuthentication(String token) {
|
||||
|
||||
Claims claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token).getBody();
|
||||
|
||||
Claims claims = Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token).getBody();
|
||||
List<GrantedAuthority> authorities = AuthorityUtils
|
||||
.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
|
||||
|
||||
@ -143,10 +141,10 @@ public class JwtTokenUtils {
|
||||
*/
|
||||
public boolean validateToken(String token) {
|
||||
try {
|
||||
Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
|
||||
Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token);
|
||||
return true;
|
||||
}
|
||||
catch (SignatureException e) {
|
||||
catch (SecurityException e) {
|
||||
log.info("Invalid JWT signature.");
|
||||
log.trace("Invalid JWT signature trace: {}", e);
|
||||
}
|
||||
|
0
pig-register/src/main/java/com/alibaba/nacos/utils/PasswordEncoderUtil.java
Normal file → Executable file
@ -0,0 +1,33 @@
|
||||
package com.alibaba.nacos.utils;
|
||||
|
||||
import com.alibaba.nacos.config.ConfigConstants;
|
||||
import com.alibaba.nacos.sys.utils.ApplicationUtils;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2020/11/7
|
||||
* <p>
|
||||
* 初始化启动配置
|
||||
*/
|
||||
@UtilityClass
|
||||
public class StartUpEnvInitUtil {
|
||||
|
||||
@SneakyThrows
|
||||
public void init() {
|
||||
// 启动时候, 创建对应目录. 避免 1.4.0 启动失败
|
||||
String confFilePath = ApplicationUtils.getConfFilePath();
|
||||
FileUtils.forceMkdir(new File(confFilePath));
|
||||
|
||||
// 设置环境变量,Nacos 读取这部分配置
|
||||
System.setProperty(ConfigConstants.NACOS_TOMCAT_BASEDIR, ApplicationUtils.getNacosTmpDir());
|
||||
System.setProperty(ConfigConstants.STANDALONE_MODE, Boolean.TRUE.toString());
|
||||
System.setProperty(ConfigConstants.AUTH_ENABLED, Boolean.FALSE.toString());
|
||||
System.setProperty(ConfigConstants.MCP_SERVER_ENABLED, Boolean.FALSE.toString());
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
server:
|
||||
port: 8848
|
||||
tomcat:
|
||||
basedir: logs
|
||||
|
||||
db:
|
||||
num: 1
|
||||
@ -21,17 +19,33 @@ nacos:
|
||||
urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
datasource:
|
||||
platform: mysql
|
||||
security:
|
||||
enabled: true
|
||||
boot: # 接入 spring boot admin
|
||||
admin:
|
||||
client:
|
||||
url: http://pig-monitor:5001
|
||||
username: pig
|
||||
password: pig
|
||||
|
||||
useAddressServer: true
|
||||
|
||||
# 关闭监控埋点采集
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
metrics:
|
||||
export:
|
||||
influx:
|
||||
enabled: false
|
||||
elastic:
|
||||
enabled: false
|
||||
influx:
|
||||
enabled: false
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"useBuiltIns": "entry"
|
||||
}
|
||||
],
|
||||
"react-app"
|
||||
],
|
||||
"plugins": [
|
||||
[
|
||||
"@babel/plugin-proposal-decorators",
|
||||
{
|
||||
"legacy": true
|
||||
}
|
||||
],
|
||||
[
|
||||
"babel-plugin-import",
|
||||
{
|
||||
"libraryName": "@alifd/next",
|
||||
"style": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
@ -1,6 +0,0 @@
|
||||
*.svg
|
||||
*.ejs
|
||||
.DS_Store
|
||||
build
|
||||
node_modules
|
||||
public
|
@ -1,36 +0,0 @@
|
||||
{
|
||||
"extends": "eslint-config-ali/react",
|
||||
"parser": "babel-eslint",
|
||||
"env": {},
|
||||
"globals": {
|
||||
"window": true
|
||||
},
|
||||
"rules": {
|
||||
"no-shadow": "off",
|
||||
"no-empty": "off",
|
||||
"no-useless-escape": "off",
|
||||
"no-template-curly-in-string": "off",
|
||||
"no-unused-vars": "off",
|
||||
"no-tabs": "off",
|
||||
"no-param-reassign": "off",
|
||||
"react/no-string-refs": "off",
|
||||
"react/no-unused-state": "off",
|
||||
"no-return-assign": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-script-url": "off",
|
||||
"no-mixed-operators": "off",
|
||||
"react/jsx-indent": "off",
|
||||
"react/jsx-no-bind": "off",
|
||||
"react/forbid-prop-types": "off",
|
||||
"react/no-array-index-key": "off",
|
||||
"react/sort-comp": "off",
|
||||
"implicit-arrow-linebreak": "off",
|
||||
"prefer-const": "off",
|
||||
"space-before-function-paren": "off",
|
||||
"generator-star-spacing": "off",
|
||||
"wrap-iife": "off",
|
||||
"arrow-parens": "off",
|
||||
"indent": "off",
|
||||
"comma-dangle": "off"
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# production
|
||||
/dist
|
||||
|
||||
# log
|
||||
yarn-error.log
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
npm-debug.log*
|
||||
|
||||
# test
|
||||
test/uirecorder.log
|
||||
test/reports
|
||||
test/screenshots/*
|
@ -1,6 +0,0 @@
|
||||
*.svg
|
||||
*.ejs
|
||||
.DS_Store
|
||||
build
|
||||
node_modules
|
||||
public
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"useTabs": false,
|
||||
"bracketSpacing": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
# 开始项目
|
||||
## cnpm 安装(可忽略)
|
||||
```sh
|
||||
npm install -g cnpm --registry=https://registry.npm.taobao.org
|
||||
|
||||
# 设置匿名
|
||||
alias cnpm="npm --registry=https://registry.npm.taobao.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=https://npm.taobao.org/dist \
|
||||
--userconfig=$HOME/.cnpmrc"
|
||||
|
||||
# Or alias it in .bashrc or .zshrc
|
||||
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=https://npm.taobao.org/dist \
|
||||
--userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc
|
||||
|
||||
```
|
||||
[详情地址: http://npm.taobao.org/](http://npm.taobao.org/)
|
||||
|
||||
## 安装依赖
|
||||
```sh
|
||||
yarn
|
||||
```
|
||||
或
|
||||
```
|
||||
cnpm install
|
||||
```
|
||||
|
||||
## 启动
|
||||
```sh
|
||||
yarn start
|
||||
```
|
||||
或
|
||||
```
|
||||
npm start
|
||||
```
|
||||
|
||||
## 构建打包
|
||||
```sh
|
||||
yarn build
|
||||
```
|
||||
或
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
##
|
||||
|
||||
# 代理配置
|
||||
`build/webpack.dev.conf.js`
|
||||
修改proxy属性
|
||||
|
||||
```
|
||||
proxy: [{
|
||||
context: ['/'],
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
target: 'http://ip:port',
|
||||
}],
|
||||
```
|
@ -1,83 +0,0 @@
|
||||
{
|
||||
"name": "console-fe",
|
||||
"version": "1.0.0",
|
||||
"description": "console fe",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "cross-env NODE_ENV=development webpack-dev-server --config build/webpack.dev.conf.js",
|
||||
"build": "cross-env NODE_ENV=production webpack --config build/webpack.prod.conf.js && node build/copyFile.js",
|
||||
"eslint": "eslint --ext .js src/",
|
||||
"eslint-fix": "eslint --ext .js --fix src/"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,css,less}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/alibaba/nacos.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alifd/next-theme-loader": "^1.3.1",
|
||||
"@babel/cli": "^7.7.7",
|
||||
"@babel/core": "^7.7.7",
|
||||
"@babel/plugin-proposal-decorators": "^7.7.4",
|
||||
"@babel/preset-env": "^7.7.7",
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-import": "^1.13.0",
|
||||
"babel-preset-react-app": "^9.1.0",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"copy-webpack-plugin": "^5.1.1 ",
|
||||
"cross-env": "^6.0.3",
|
||||
"css-loader": "^3.4.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-ali": "^9.0.2",
|
||||
"eslint-config-prettier": "^6.8.0",
|
||||
"eslint-loader": "^3.0.3",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"eslint-plugin-react": "^7.17.0",
|
||||
"eslint-plugin-react-hooks": "^2.3.0",
|
||||
"file-loader": "^5.0.2",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"husky": "^3.1.0",
|
||||
"lint-staged": "^9.5.0",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"node-sass": "^4.13.0",
|
||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||
"prettier": "1.19.1",
|
||||
"sass-loader": "^8.0.0",
|
||||
"style-loader": "^1.1.2",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"url-loader": "^3.0.0",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"webpack-dev-server": "^3.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.17.4",
|
||||
"axios": "^0.18.0",
|
||||
"moment": "^2.23.0",
|
||||
"qs": "^6.8.2",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"react-redux": "^7.1.3",
|
||||
"react-router": "^5.1.2",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"react-router-redux": "^4.0.8",
|
||||
"redux": "^4.0.5",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"yamljs": "^0.3.0"
|
||||
}
|
||||
}
|
0
pig-register/src/main/resources/static/console-fe/public/css/bootstrap.css
vendored
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/codemirror.css
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/console1412.css
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/font-awesome.css
vendored
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/aliyun-console-font.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/aliyun-console-font.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/aliyun-console-font.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/font_515771_emcns5054x3whfr.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/font_515771_emcns5054x3whfr.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/roboto-bold.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/roboto-bold.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/roboto-bold.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/roboto-regular.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/roboto-regular.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/fonts/roboto-regular.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/icon.css
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/css/merge.css
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-bold.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-bold.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-bold.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-bold.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-light.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-light.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-light.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-light.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-medium.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-medium.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-medium.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-medium.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-regular.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-regular.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-regular.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-regular.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-thin.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-thin.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-thin.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/fonts/roboto-thin.woff2
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/icons/icon-font.eot
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/icons/icon-font.svg
Normal file → Executable file
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
0
pig-register/src/main/resources/static/console-fe/public/icons/icon-font.ttf
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/icons/icon-font.woff
Normal file → Executable file
0
pig-register/src/main/resources/static/console-fe/public/img/black_dot.png
Normal file → Executable file
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 114 B |
0
pig-register/src/main/resources/static/console-fe/public/img/favicon.ico
Normal file → Executable file
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
0
pig-register/src/main/resources/static/console-fe/public/img/logo-2000-390.svg
Normal file → Executable file
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
0
pig-register/src/main/resources/static/console-fe/public/img/nacos.png
Normal file → Executable file
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
2
pig-register/src/main/resources/static/console-fe/public/index.html
Normal file → Executable file
@ -23,7 +23,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Nacos</title>
|
||||
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="img/nacos-logo.png" type="image/x-icon" />
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/console1412.css">
|
||||
<!-- 第三方css开始 -->
|
||||
|