mirror of https://gitee.com/maxjhandsome/pig
⬇️ Downgrading dependencies. nacos 1.3.2
This commit is contained in:
parent
96e2d3f061
commit
9f69920a2a
|
@ -4,7 +4,7 @@ ARG JAR_FILE=target/pig-register.jar
|
||||||
COPY ${JAR_FILE} app.jar
|
COPY ${JAR_FILE} app.jar
|
||||||
RUN java -Djarmode=layertools -jar app.jar extract && rm app.jar
|
RUN java -Djarmode=layertools -jar app.jar extract && rm app.jar
|
||||||
|
|
||||||
FROM openjdk:8-jre
|
FROM moxm/java:1.8-full
|
||||||
LABEL maintainer="jclazz@outlook.com"
|
LABEL maintainer="jclazz@outlook.com"
|
||||||
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom"
|
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom"
|
||||||
WORKDIR pig-register
|
WORKDIR pig-register
|
||||||
|
|
|
@ -28,32 +28,9 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jjwt.version>0.11.2</jjwt.version>
|
<jjwt.version>0.11.2</jjwt.version>
|
||||||
<nacos.version>1.4.0</nacos.version>
|
<nacos.version>1.3.2</nacos.version>
|
||||||
<netty-all.version>4.1.42.Final</netty-all.version>
|
|
||||||
<grpc-java.version>1.24.0</grpc-java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 管理依赖版本号,子项目不会默认依赖 -->
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-bom</artifactId>
|
|
||||||
<version>${grpc-java.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.netty</groupId>
|
|
||||||
<artifactId>netty-bom</artifactId>
|
|
||||||
<version>${netty-all.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud.nacos</groupId>
|
<groupId>com.pig4cloud.nacos</groupId>
|
||||||
|
@ -64,6 +41,7 @@
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
<artifactId>tomcat-embed-jasper</artifactId>
|
<artifactId>tomcat-embed-jasper</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.pig4cloud.nacos</groupId>
|
<groupId>com.pig4cloud.nacos</groupId>
|
||||||
<artifactId>nacos-naming</artifactId>
|
<artifactId>nacos-naming</artifactId>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package com.alibaba.nacos;
|
package com.alibaba.nacos;
|
||||||
|
|
||||||
import com.alibaba.nacos.utils.StartUpEnvInitUtil;
|
import com.alibaba.nacos.config.ConfigConstants;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
@ -31,7 +31,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
public class PigNacosApplication {
|
public class PigNacosApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
StartUpEnvInitUtil.init();
|
System.setProperty(ConfigConstants.STANDALONE_MODE, "true");
|
||||||
|
System.setProperty(ConfigConstants.AUTH_ENABLED, "false");
|
||||||
SpringApplication.run(PigNacosApplication.class, args);
|
SpringApplication.run(PigNacosApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
pig-register/src/main/java/com/alibaba/nacos/config/ConfigConstants.java
Normal file → Executable file
10
pig-register/src/main/java/com/alibaba/nacos/config/ConfigConstants.java
Normal file → Executable file
|
@ -35,14 +35,4 @@ public interface ConfigConstants {
|
||||||
*/
|
*/
|
||||||
String AUTH_ENABLED = "nacos.core.auth.enabled";
|
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";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.controller;
|
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.common.model.RestResult;
|
||||||
import com.alibaba.nacos.config.server.model.TenantInfo;
|
import com.alibaba.nacos.config.server.model.TenantInfo;
|
||||||
import com.alibaba.nacos.config.server.service.repository.PersistService;
|
import com.alibaba.nacos.config.server.service.repository.PersistService;
|
||||||
import com.alibaba.nacos.model.Namespace;
|
import com.alibaba.nacos.model.Namespace;
|
||||||
import com.alibaba.nacos.model.NamespaceAllInfo;
|
import com.alibaba.nacos.model.NamespaceAllInfo;
|
||||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
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.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
|
|
@ -16,14 +16,19 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.controller;
|
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.common.model.RestResult;
|
||||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||||
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
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.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission operation controller.
|
* Permission operation controller.
|
||||||
|
|
|
@ -16,16 +16,19 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.controller;
|
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.common.model.RestResult;
|
||||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||||
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
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.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import java.util.List;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Role operation controller.
|
* Role operation controller.
|
||||||
|
@ -54,17 +57,6 @@ public class RoleController {
|
||||||
return roleService.getRolesFromDatabase(username, pageNo, pageSize);
|
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
|
* Add a role to a user
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package com.alibaba.nacos.controller;
|
package com.alibaba.nacos.controller;
|
||||||
|
|
||||||
import com.alibaba.nacos.common.utils.VersionUtils;
|
import com.alibaba.nacos.common.utils.VersionUtils;
|
||||||
import com.alibaba.nacos.sys.utils.ApplicationUtils;
|
import com.alibaba.nacos.core.utils.ApplicationUtils;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
|
@ -17,11 +17,6 @@
|
||||||
package com.alibaba.nacos.controller;
|
package com.alibaba.nacos.controller;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
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.model.RestResult;
|
||||||
import com.alibaba.nacos.common.utils.JacksonUtils;
|
import com.alibaba.nacos.common.utils.JacksonUtils;
|
||||||
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
||||||
|
@ -33,6 +28,11 @@ import com.alibaba.nacos.security.nacos.users.NacosUser;
|
||||||
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
||||||
import com.alibaba.nacos.utils.JwtTokenUtils;
|
import com.alibaba.nacos.utils.JwtTokenUtils;
|
||||||
import com.alibaba.nacos.utils.PasswordEncoderUtil;
|
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 com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
@ -249,15 +249,4 @@ public class UserController {
|
||||||
return rr;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.exception;
|
package com.alibaba.nacos.exception;
|
||||||
|
|
||||||
import com.alibaba.nacos.auth.exception.AccessException;
|
|
||||||
import com.alibaba.nacos.common.utils.ExceptionUtil;
|
import com.alibaba.nacos.common.utils.ExceptionUtil;
|
||||||
|
import com.alibaba.nacos.core.auth.AccessException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.security.nacos;
|
package com.alibaba.nacos.security.nacos;
|
||||||
|
|
||||||
import com.alibaba.nacos.auth.common.AuthConfigs;
|
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import io.jsonwebtoken.security.Keys;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
@ -68,8 +67,9 @@ public class JwtTokenManager {
|
||||||
validity = new Date(now + authConfigs.getTokenValidityInSeconds() * 1000L);
|
validity = new Date(now + authConfigs.getTokenValidityInSeconds() * 1000L);
|
||||||
|
|
||||||
Claims claims = Jwts.claims().setSubject(userName);
|
Claims claims = Jwts.claims().setSubject(userName);
|
||||||
|
|
||||||
return Jwts.builder().setClaims(claims).setExpiration(validity)
|
return Jwts.builder().setClaims(claims).setExpiration(validity)
|
||||||
.signWith(Keys.hmacShaKeyFor(authConfigs.getSecretKeyBytes()), SignatureAlgorithm.HS256).compact();
|
.signWith(SignatureAlgorithm.HS256, authConfigs.getSecretKey()).compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,8 +78,8 @@ public class JwtTokenManager {
|
||||||
* @return auth info
|
* @return auth info
|
||||||
*/
|
*/
|
||||||
public Authentication getAuthentication(String token) {
|
public Authentication getAuthentication(String token) {
|
||||||
Claims claims = Jwts.parserBuilder().setSigningKey(authConfigs.getSecretKeyBytes()).build()
|
|
||||||
.parseClaimsJws(token).getBody();
|
Claims claims = Jwts.parser().setSigningKey(authConfigs.getSecretKey()).parseClaimsJws(token).getBody();
|
||||||
|
|
||||||
List<GrantedAuthority> authorities = AuthorityUtils
|
List<GrantedAuthority> authorities = AuthorityUtils
|
||||||
.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
|
.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
|
||||||
|
@ -93,7 +93,7 @@ public class JwtTokenManager {
|
||||||
* @param token token
|
* @param token token
|
||||||
*/
|
*/
|
||||||
public void validateToken(String token) {
|
public void validateToken(String token) {
|
||||||
Jwts.parserBuilder().setSigningKey(authConfigs.getSecretKeyBytes()).build().parseClaimsJws(token);
|
Jwts.parser().setSigningKey(authConfigs.getSecretKey()).parseClaimsJws(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.security.nacos;
|
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.filter.JwtAuthenticationTokenFilter;
|
||||||
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
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.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
package com.alibaba.nacos.security.nacos;
|
package com.alibaba.nacos.security.nacos;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
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.auth.RoleInfo;
|
||||||
import com.alibaba.nacos.config.server.utils.RequestUtil;
|
|
||||||
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
import com.alibaba.nacos.security.nacos.roles.NacosRoleServiceImpl;
|
||||||
import com.alibaba.nacos.security.nacos.users.NacosUser;
|
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 com.alibaba.nacos.core.utils.Loggers;
|
||||||
import io.jsonwebtoken.ExpiredJwtException;
|
import io.jsonwebtoken.ExpiredJwtException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -93,7 +92,7 @@ public class NacosAuthManager implements AuthManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.setAttribute(RequestUtil.NACOS_USER_KEY, user);
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.security.nacos.roles;
|
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.PermissionInfo;
|
||||||
import com.alibaba.nacos.config.server.auth.PermissionPersistService;
|
import com.alibaba.nacos.config.server.auth.PermissionPersistService;
|
||||||
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
import com.alibaba.nacos.config.server.auth.RoleInfo;
|
||||||
|
@ -25,6 +23,8 @@ import com.alibaba.nacos.config.server.auth.RolePersistService;
|
||||||
import com.alibaba.nacos.config.server.model.Page;
|
import com.alibaba.nacos.config.server.model.Page;
|
||||||
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
import com.alibaba.nacos.security.nacos.NacosAuthConfig;
|
||||||
import com.alibaba.nacos.security.nacos.users.NacosUserDetailsServiceImpl;
|
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 com.alibaba.nacos.core.utils.Loggers;
|
||||||
import io.jsonwebtoken.lang.Collections;
|
import io.jsonwebtoken.lang.Collections;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -235,8 +235,4 @@ public class NacosRoleServiceImpl {
|
||||||
permissionPersistService.deletePermission(role, resource, action);
|
permissionPersistService.deletePermission(role, resource, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> findRolesLikeRoleName(String role) {
|
|
||||||
return rolePersistService.findRolesLikeRoleName(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.security.nacos.users;
|
package com.alibaba.nacos.security.nacos.users;
|
||||||
|
|
||||||
import com.alibaba.nacos.auth.model.User;
|
import com.alibaba.nacos.core.auth.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nacos User.
|
* Nacos User.
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
package com.alibaba.nacos.security.nacos.users;
|
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.auth.UserPersistService;
|
||||||
import com.alibaba.nacos.config.server.model.Page;
|
import com.alibaba.nacos.config.server.model.Page;
|
||||||
import com.alibaba.nacos.config.server.model.User;
|
import com.alibaba.nacos.config.server.model.User;
|
||||||
|
import com.alibaba.nacos.core.auth.AuthConfigs;
|
||||||
import com.alibaba.nacos.core.utils.Loggers;
|
import com.alibaba.nacos.core.utils.Loggers;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
@ -28,7 +28,6 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -102,10 +101,6 @@ public class NacosUserDetailsServiceImpl implements UserDetailsService {
|
||||||
return userPersistService.findUserByUsername(username);
|
return userPersistService.findUserByUsername(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> findUserLikeUsername(String username) {
|
|
||||||
return userPersistService.findUserLikeUsername(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createUser(String username, String password) {
|
public void createUser(String username, String password) {
|
||||||
userPersistService.createUser(username, password);
|
userPersistService.createUser(username, password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ import io.jsonwebtoken.ExpiredJwtException;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.MalformedJwtException;
|
import io.jsonwebtoken.MalformedJwtException;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
import io.jsonwebtoken.SignatureException;
|
||||||
import io.jsonwebtoken.UnsupportedJwtException;
|
import io.jsonwebtoken.UnsupportedJwtException;
|
||||||
import io.jsonwebtoken.security.Keys;
|
import io.jsonwebtoken.security.Keys;
|
||||||
import io.jsonwebtoken.security.SecurityException;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -126,7 +126,9 @@ public class JwtTokenUtils {
|
||||||
* @return auth info
|
* @return auth info
|
||||||
*/
|
*/
|
||||||
public Authentication getAuthentication(String token) {
|
public Authentication getAuthentication(String token) {
|
||||||
Claims claims = Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token).getBody();
|
|
||||||
|
Claims claims = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token).getBody();
|
||||||
|
|
||||||
List<GrantedAuthority> authorities = AuthorityUtils
|
List<GrantedAuthority> authorities = AuthorityUtils
|
||||||
.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
|
.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
|
||||||
|
|
||||||
|
@ -141,10 +143,10 @@ public class JwtTokenUtils {
|
||||||
*/
|
*/
|
||||||
public boolean validateToken(String token) {
|
public boolean validateToken(String token) {
|
||||||
try {
|
try {
|
||||||
Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token);
|
Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (SecurityException e) {
|
catch (SignatureException e) {
|
||||||
log.info("Invalid JWT signature.");
|
log.info("Invalid JWT signature.");
|
||||||
log.trace("Invalid JWT signature trace: {}", e);
|
log.trace("Invalid JWT signature trace: {}", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
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,5 +1,7 @@
|
||||||
server:
|
server:
|
||||||
port: 8848
|
port: 8848
|
||||||
|
tomcat:
|
||||||
|
basedir: logs
|
||||||
|
|
||||||
db:
|
db:
|
||||||
num: 1
|
num: 1
|
||||||
|
@ -19,8 +21,6 @@ nacos:
|
||||||
urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
|
||||||
name: @artifactId@
|
|
||||||
datasource:
|
datasource:
|
||||||
platform: mysql
|
platform: mysql
|
||||||
security:
|
security:
|
||||||
|
@ -34,22 +34,10 @@ spring:
|
||||||
|
|
||||||
useAddressServer: true
|
useAddressServer: true
|
||||||
|
|
||||||
# 关闭监控埋点采集
|
|
||||||
management:
|
management:
|
||||||
endpoints:
|
|
||||||
web:
|
|
||||||
exposure:
|
|
||||||
include: '*'
|
|
||||||
endpoint:
|
|
||||||
health:
|
|
||||||
show-details: always
|
|
||||||
metrics:
|
metrics:
|
||||||
export:
|
export:
|
||||||
elastic:
|
|
||||||
enabled: false
|
|
||||||
influx:
|
influx:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
elastic:
|
||||||
logging:
|
enabled: false
|
||||||
level:
|
|
||||||
org.apache.tomcat.util.scan.StandardJarScanner: ERROR
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>Nacos</title>
|
<title>Nacos</title>
|
||||||
<link rel="shortcut icon" href="img/nacos-logo.png" type="image/x-icon" />
|
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
|
||||||
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
|
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
|
||||||
<link rel="stylesheet" type="text/css" href="css/console1412.css">
|
<link rel="stylesheet" type="text/css" href="css/console1412.css">
|
||||||
<!-- 第三方css开始 -->
|
<!-- 第三方css开始 -->
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
pom.xml
2
pom.xml
|
@ -41,7 +41,7 @@
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<spring-boot-admin.version>2.3.1</spring-boot-admin.version>
|
<spring-boot-admin.version>2.3.1</spring-boot-admin.version>
|
||||||
<hutool.version>5.4.7</hutool.version>
|
<hutool.version>5.5.1</hutool.version>
|
||||||
<mybatis-plus.version>3.4.1</mybatis-plus.version>
|
<mybatis-plus.version>3.4.1</mybatis-plus.version>
|
||||||
<dynamic-ds.version>3.2.0</dynamic-ds.version>
|
<dynamic-ds.version>3.2.0</dynamic-ds.version>
|
||||||
<captcha.version>2.2.0</captcha.version>
|
<captcha.version>2.2.0</captcha.version>
|
||||||
|
|
Loading…
Reference in New Issue