update nacos 2.3.2 => 2.4.3

dev
疯狂的狮子Li 1 year ago
parent 2812948bb6
commit 3444a8d5f6

@ -18,7 +18,7 @@
<spring-cloud-alibaba.version>2023.0.1.2</spring-cloud-alibaba.version> <spring-cloud-alibaba.version>2023.0.1.2</spring-cloud-alibaba.version>
<sentinel.version>1.8.8</sentinel.version> <sentinel.version>1.8.8</sentinel.version>
<seata.version>1.7.1</seata.version> <seata.version>1.7.1</seata.version>
<nacos.client.version>2.3.3</nacos.client.version> <nacos.client.version>2.4.3</nacos.client.version>
<dubbo.version>3.2.14</dubbo.version> <dubbo.version>3.2.14</dubbo.version>
<spring.context.support.version>1.0.11</spring.context.support.version> <spring.context.support.version>1.0.11</spring.context.support.version>
</properties> </properties>

@ -27,7 +27,8 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<nacos.version>2.3.2</nacos.version> <nacos.version>2.4.3</nacos.version>
<SnakeYaml.version>2.0</SnakeYaml.version>
<!-- 需要与 Nacos 内置 Boot 版本保持一致 --> <!-- 需要与 Nacos 内置 Boot 版本保持一致 -->
<spring-boot.version>2.7.18</spring-boot.version> <spring-boot.version>2.7.18</spring-boot.version>
<spring-boot-admin.version>2.7.11</spring-boot-admin.version> <spring-boot-admin.version>2.7.11</spring-boot-admin.version>
@ -253,10 +254,6 @@
<artifactId>jjwt-jackson</artifactId> <artifactId>jjwt-jackson</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
@ -295,6 +292,13 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId> <artifactId>jul-to-slf4j</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${SnakeYaml.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>

@ -43,13 +43,13 @@ import java.time.ZoneId;
@EnableScheduling @EnableScheduling
@PropertySource("/application.properties") @PropertySource("/application.properties")
public class ConsoleConfig { public class ConsoleConfig {
@Autowired @Autowired
private ControllerMethodsCache methodsCache; private ControllerMethodsCache methodsCache;
@Value("${nacos.console.ui.enabled:true}") @Value("${nacos.console.ui.enabled:true}")
private boolean consoleUiEnabled; private boolean consoleUiEnabled;
/** /**
* Init. * Init.
*/ */
@ -60,7 +60,7 @@ public class ConsoleConfig {
methodsCache.initClassMethod("com.alibaba.nacos.config.server.controller"); methodsCache.initClassMethod("com.alibaba.nacos.config.server.controller");
methodsCache.initClassMethod("com.alibaba.nacos.console.controller"); methodsCache.initClassMethod("com.alibaba.nacos.console.controller");
} }
@Bean @Bean
public CorsFilter corsFilter() { public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration(); CorsConfiguration config = new CorsConfiguration();
@ -73,17 +73,17 @@ public class ConsoleConfig {
source.registerCorsConfiguration("/**", config); source.registerCorsConfiguration("/**", config);
return new CorsFilter(source); return new CorsFilter(source);
} }
@Bean @Bean
public XssFilter xssFilter() { public XssFilter xssFilter() {
return new XssFilter(); return new XssFilter();
} }
@Bean @Bean
public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() { public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString()); return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString());
} }
public boolean isConsoleUiEnabled() { public boolean isConsoleUiEnabled() {
return consoleUiEnabled; return consoleUiEnabled;
} }

@ -26,11 +26,11 @@ import com.alibaba.nacos.sys.utils.ApplicationUtils;
* @author xiweng.yy * @author xiweng.yy
*/ */
public class ConsoleModuleStateBuilder implements ModuleStateBuilder { public class ConsoleModuleStateBuilder implements ModuleStateBuilder {
public static final String CONSOLE_MODULE = "console"; public static final String CONSOLE_MODULE = "console";
private static final String CONSOLE_UI_ENABLED = "console_ui_enabled"; private static final String CONSOLE_UI_ENABLED = "console_ui_enabled";
@Override @Override
public ModuleState build() { public ModuleState build() {
ModuleState result = new ModuleState(CONSOLE_MODULE); ModuleState result = new ModuleState(CONSOLE_MODULE);

@ -37,7 +37,7 @@ import javax.servlet.http.HttpServletRequest;
@RequestMapping("/v1/console/health") @RequestMapping("/v1/console/health")
@ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class) @ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class)
public class HealthController { public class HealthController {
/** /**
* Whether the Nacos is in broken states or not, and cannot recover except by being restarted. * Whether the Nacos is in broken states or not, and cannot recover except by being restarted.
* *
@ -48,7 +48,7 @@ public class HealthController {
public ResponseEntity<String> liveness() { public ResponseEntity<String> liveness() {
return ResponseEntity.ok().body("OK"); return ResponseEntity.ok().body("OK");
} }
/** /**
* Ready to receive the request or not. * Ready to receive the request or not.
* *
@ -63,5 +63,5 @@ public class HealthController {
} }
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result.getResultMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result.getResultMessage());
} }
} }

@ -22,20 +22,14 @@ import com.alibaba.nacos.common.model.RestResult;
import com.alibaba.nacos.common.model.RestResultUtils; import com.alibaba.nacos.common.model.RestResultUtils;
import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor;
import com.alibaba.nacos.core.namespace.repository.NamespacePersistService;
import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.core.namespace.model.Namespace;
import com.alibaba.nacos.core.namespace.repository.NamespacePersistService;
import com.alibaba.nacos.core.paramcheck.ExtractorManager; import com.alibaba.nacos.core.paramcheck.ExtractorManager;
import com.alibaba.nacos.core.service.NamespaceOperationService; import com.alibaba.nacos.core.service.NamespaceOperationService;
import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.constant.ActionTypes;
import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants;
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.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -94,8 +88,8 @@ public class NamespaceController {
@PostMapping @PostMapping
@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE) @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
public Boolean createNamespace(@RequestParam("customNamespaceId") String namespaceId, public Boolean createNamespace(@RequestParam("customNamespaceId") String namespaceId,
@RequestParam("namespaceName") String namespaceName, @RequestParam("namespaceName") String namespaceName,
@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) { @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
if (StringUtils.isBlank(namespaceId)) { if (StringUtils.isBlank(namespaceId)) {
namespaceId = UUID.randomUUID().toString(); namespaceId = UUID.randomUUID().toString();
} else { } else {
@ -147,8 +141,8 @@ public class NamespaceController {
@PutMapping @PutMapping
@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE) @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
public Boolean editNamespace(@RequestParam("namespace") String namespace, public Boolean editNamespace(@RequestParam("namespace") String namespace,
@RequestParam("namespaceShowName") String namespaceShowName, @RequestParam("namespaceShowName") String namespaceShowName,
@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) { @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
// contains illegal chars // contains illegal chars
if (!namespaceNameCheckPattern.matcher(namespaceShowName).matches()) { if (!namespaceNameCheckPattern.matcher(namespaceShowName).matches()) {
return false; return false;

@ -34,9 +34,7 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.alibaba.nacos.common.utils.StringUtils.FOLDER_SEPARATOR; import static com.alibaba.nacos.common.utils.StringUtils.*;
import static com.alibaba.nacos.common.utils.StringUtils.TOP_PATH;
import static com.alibaba.nacos.common.utils.StringUtils.WINDOWS_FOLDER_SEPARATOR;
/** /**
* Server state controller. * Server state controller.
@ -68,7 +66,7 @@ public class ServerStateController {
@GetMapping("/announcement") @GetMapping("/announcement")
public RestResult<String> getAnnouncement( public RestResult<String> getAnnouncement(
@RequestParam(required = false, name = "language", defaultValue = "zh-CN") String language) { @RequestParam(required = false, name = "language", defaultValue = "zh-CN") String language) {
String file = ANNOUNCEMENT_FILE.substring(0, ANNOUNCEMENT_FILE.length() - 5) + "_" + language + ".conf"; String file = ANNOUNCEMENT_FILE.substring(0, ANNOUNCEMENT_FILE.length() - 5) + "_" + language + ".conf";
if (file.contains(TOP_PATH) || file.contains(FOLDER_SEPARATOR) || file.contains(WINDOWS_FOLDER_SEPARATOR)) { if (file.contains(TOP_PATH) || file.contains(FOLDER_SEPARATOR) || file.contains(WINDOWS_FOLDER_SEPARATOR)) {
throw new IllegalArgumentException("Invalid filename"); throw new IllegalArgumentException("Invalid filename");

@ -36,7 +36,7 @@ import javax.servlet.http.HttpServletRequest;
@RequestMapping("/v2/console/health") @RequestMapping("/v2/console/health")
@ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class) @ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class)
public class HealthControllerV2 { public class HealthControllerV2 {
/** /**
* Whether the Nacos is in broken states or not, and cannot recover except by being restarted. * Whether the Nacos is in broken states or not, and cannot recover except by being restarted.
* *
@ -47,7 +47,7 @@ public class HealthControllerV2 {
public Result<String> liveness() { public Result<String> liveness() {
return Result.success("ok"); return Result.success("ok");
} }
/** /**
* Ready to receive the request or not. * Ready to receive the request or not.
* *
@ -62,5 +62,5 @@ public class HealthControllerV2 {
} }
return Result.failure(result.getResultMessage()); return Result.failure(result.getResultMessage());
} }
} }

@ -33,13 +33,7 @@ import com.alibaba.nacos.plugin.auth.constant.ActionTypes;
import com.alibaba.nacos.plugin.auth.constant.SignType; import com.alibaba.nacos.plugin.auth.constant.SignType;
import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -90,7 +84,7 @@ public class NamespaceControllerV2 {
*/ */
@GetMapping() @GetMapping()
@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX
+ "namespaces", action = ActionTypes.READ, signType = SignType.CONSOLE) + "namespaces", action = ActionTypes.READ, signType = SignType.CONSOLE)
public Result<Namespace> getNamespace(@RequestParam("namespaceId") String namespaceId) throws NacosException { public Result<Namespace> getNamespace(@RequestParam("namespaceId") String namespaceId) throws NacosException {
return Result.success(namespaceOperationService.getNamespace(namespaceId)); return Result.success(namespaceOperationService.getNamespace(namespaceId));
} }
@ -103,7 +97,7 @@ public class NamespaceControllerV2 {
*/ */
@PostMapping @PostMapping
@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX
+ "namespaces", action = ActionTypes.WRITE, signType = SignType.CONSOLE) + "namespaces", action = ActionTypes.WRITE, signType = SignType.CONSOLE)
public Result<Boolean> createNamespace(NamespaceForm namespaceForm) throws NacosException { public Result<Boolean> createNamespace(NamespaceForm namespaceForm) throws NacosException {
namespaceForm.validate(); namespaceForm.validate();
@ -118,16 +112,16 @@ public class NamespaceControllerV2 {
namespaceId = namespaceId.trim(); namespaceId = namespaceId.trim();
if (!namespaceIdCheckPattern.matcher(namespaceId).matches()) { if (!namespaceIdCheckPattern.matcher(namespaceId).matches()) {
throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE, throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE,
"namespaceId [" + namespaceId + "] mismatch the pattern"); "namespaceId [" + namespaceId + "] mismatch the pattern");
} }
if (namespaceId.length() > NAMESPACE_ID_MAX_LENGTH) { if (namespaceId.length() > NAMESPACE_ID_MAX_LENGTH) {
throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE, throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE,
"too long namespaceId, over " + NAMESPACE_ID_MAX_LENGTH); "too long namespaceId, over " + NAMESPACE_ID_MAX_LENGTH);
} }
// check unique // check unique
if (namespacePersistService.tenantInfoCountByTenantId(namespaceId) > 0) { if (namespacePersistService.tenantInfoCountByTenantId(namespaceId) > 0) {
throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE, throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE,
"the namespaceId is existed, namespaceId: " + namespaceForm.getNamespaceId()); "the namespaceId is existed, namespaceId: " + namespaceForm.getNamespaceId());
} }
} }
// contains illegal chars // contains illegal chars
@ -146,7 +140,7 @@ public class NamespaceControllerV2 {
*/ */
@PutMapping @PutMapping
@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX
+ "namespaces", action = ActionTypes.WRITE, signType = SignType.CONSOLE) + "namespaces", action = ActionTypes.WRITE, signType = SignType.CONSOLE)
public Result<Boolean> editNamespace(NamespaceForm namespaceForm) throws NacosException { public Result<Boolean> editNamespace(NamespaceForm namespaceForm) throws NacosException {
namespaceForm.validate(); namespaceForm.validate();
// contains illegal chars // contains illegal chars
@ -155,8 +149,8 @@ public class NamespaceControllerV2 {
"namespaceName [" + namespaceForm.getNamespaceName() + "] contains illegal char"); "namespaceName [" + namespaceForm.getNamespaceName() + "] contains illegal char");
} }
return Result.success(namespaceOperationService return Result.success(namespaceOperationService
.editNamespace(namespaceForm.getNamespaceId(), namespaceForm.getNamespaceName(), .editNamespace(namespaceForm.getNamespaceId(), namespaceForm.getNamespaceName(),
namespaceForm.getNamespaceDesc())); namespaceForm.getNamespaceDesc()));
} }
/** /**
@ -167,7 +161,7 @@ public class NamespaceControllerV2 {
*/ */
@DeleteMapping @DeleteMapping
@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX
+ "namespaces", action = ActionTypes.WRITE, signType = SignType.CONSOLE) + "namespaces", action = ActionTypes.WRITE, signType = SignType.CONSOLE)
public Result<Boolean> deleteNamespace(@RequestParam("namespaceId") String namespaceId) { public Result<Boolean> deleteNamespace(@RequestParam("namespaceId") String namespaceId) {
return Result.success(namespaceOperationService.removeNamespace(namespaceId)); return Result.success(namespaceOperationService.removeNamespace(namespaceId));
} }

@ -17,10 +17,10 @@
package com.alibaba.nacos.console.exception; package com.alibaba.nacos.console.exception;
import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException; import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException;
import com.alibaba.nacos.plugin.auth.exception.AccessException;
import com.alibaba.nacos.common.model.RestResultUtils; import com.alibaba.nacos.common.model.RestResultUtils;
import com.alibaba.nacos.common.utils.ExceptionUtil; import com.alibaba.nacos.common.utils.ExceptionUtil;
import com.alibaba.nacos.core.utils.Commons; import com.alibaba.nacos.core.utils.Commons;
import com.alibaba.nacos.plugin.auth.exception.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;
@ -65,9 +65,9 @@ public class ConsoleExceptionHandler {
LOGGER.error("CONSOLE {}", uri, e); LOGGER.error("CONSOLE {}", uri, e);
if (uri.contains(Commons.NACOS_SERVER_VERSION_V2)) { if (uri.contains(Commons.NACOS_SERVER_VERSION_V2)) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(RestResultUtils.failed(HtmlUtils.htmlEscape(ExceptionUtil.getAllExceptionMsg(e), "utf-8"))); .body(RestResultUtils.failed(HtmlUtils.htmlEscape(ExceptionUtil.getAllExceptionMsg(e), "utf-8")));
} }
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(HtmlUtils.htmlEscape(ExceptionUtil.getAllExceptionMsg(e), "utf-8")); .body(HtmlUtils.htmlEscape(ExceptionUtil.getAllExceptionMsg(e), "utf-8"));
} }
} }

@ -52,15 +52,15 @@ import java.io.IOException;
@ControllerAdvice(annotations = {NacosApi.class}) @ControllerAdvice(annotations = {NacosApi.class})
@ResponseBody @ResponseBody
public class NacosApiExceptionHandler { public class NacosApiExceptionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(NacosApiExceptionHandler.class); private static final Logger LOGGER = LoggerFactory.getLogger(NacosApiExceptionHandler.class);
@ExceptionHandler(NacosApiException.class) @ExceptionHandler(NacosApiException.class)
public ResponseEntity<Result<String>> handleNacosApiException(NacosApiException e) { public ResponseEntity<Result<String>> handleNacosApiException(NacosApiException e) {
LOGGER.error("got exception. {} {}", e.getErrAbstract(), e.getErrMsg()); LOGGER.error("got exception. {} {}", e.getErrAbstract(), e.getErrMsg());
return ResponseEntity.status(e.getErrCode()).body(new Result<>(e.getDetailErrCode(), e.getErrAbstract(), e.getErrMsg())); return ResponseEntity.status(e.getErrCode()).body(new Result<>(e.getDetailErrCode(), e.getErrAbstract(), e.getErrMsg()));
} }
@ExceptionHandler(NacosException.class) @ExceptionHandler(NacosException.class)
public ResponseEntity<Result<String>> handleNacosException(NacosException e) { public ResponseEntity<Result<String>> handleNacosException(NacosException e) {
LOGGER.error("got exception. {}", e.getErrMsg()); LOGGER.error("got exception. {}", e.getErrMsg());
@ -72,63 +72,63 @@ public class NacosApiExceptionHandler {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return ResponseEntity.status(e.getErrCode()).body(Result.failure(ErrorCode.SERVER_ERROR, e.getMessage())); return ResponseEntity.status(e.getErrCode()).body(Result.failure(ErrorCode.SERVER_ERROR, e.getMessage()));
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(HttpMessageNotReadableException.class) @ExceptionHandler(HttpMessageNotReadableException.class)
public Result<String> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) { public Result<String> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.PARAMETER_MISSING, e.getMessage()); return Result.failure(ErrorCode.PARAMETER_MISSING, e.getMessage());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(HttpMessageConversionException.class) @ExceptionHandler(HttpMessageConversionException.class)
public Result<String> handleHttpMessageConversionException(HttpMessageConversionException e) { public Result<String> handleHttpMessageConversionException(HttpMessageConversionException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.PARAMETER_VALIDATE_ERROR, e.getMessage()); return Result.failure(ErrorCode.PARAMETER_VALIDATE_ERROR, e.getMessage());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(NumberFormatException.class) @ExceptionHandler(NumberFormatException.class)
public Result<String> handleNumberFormatException(NumberFormatException e) { public Result<String> handleNumberFormatException(NumberFormatException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.PARAMETER_VALIDATE_ERROR, e.getMessage()); return Result.failure(ErrorCode.PARAMETER_VALIDATE_ERROR, e.getMessage());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(IllegalArgumentException.class) @ExceptionHandler(IllegalArgumentException.class)
public Result<String> handleIllegalArgumentException(IllegalArgumentException e) { public Result<String> handleIllegalArgumentException(IllegalArgumentException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.PARAMETER_VALIDATE_ERROR, e.getMessage()); return Result.failure(ErrorCode.PARAMETER_VALIDATE_ERROR, e.getMessage());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MissingServletRequestParameterException.class) @ExceptionHandler(MissingServletRequestParameterException.class)
public Result<String> handleMissingServletRequestParameterException(MissingServletRequestParameterException e) { public Result<String> handleMissingServletRequestParameterException(MissingServletRequestParameterException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.PARAMETER_MISSING, e.getMessage()); return Result.failure(ErrorCode.PARAMETER_MISSING, e.getMessage());
} }
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(HttpMediaTypeException.class) @ExceptionHandler(HttpMediaTypeException.class)
public Result<String> handleHttpMediaTypeException(HttpMediaTypeException e) { public Result<String> handleHttpMediaTypeException(HttpMediaTypeException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.MEDIA_TYPE_ERROR, e.getMessage()); return Result.failure(ErrorCode.MEDIA_TYPE_ERROR, e.getMessage());
} }
@ResponseStatus(HttpStatus.FORBIDDEN) @ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(AccessException.class) @ExceptionHandler(AccessException.class)
public Result<String> handleAccessException(AccessException e) { public Result<String> handleAccessException(AccessException e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.ACCESS_DENIED, e.getErrMsg()); return Result.failure(ErrorCode.ACCESS_DENIED, e.getErrMsg());
} }
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = {DataAccessException.class, ServletException.class, IOException.class}) @ExceptionHandler(value = {DataAccessException.class, ServletException.class, IOException.class})
public Result<String> handleDataAccessException(Exception e) { public Result<String> handleDataAccessException(Exception e) {
LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e)); LOGGER.error("got exception. {} {}", e.getMessage(), ExceptionUtil.getAllExceptionMsg(e));
return Result.failure(ErrorCode.DATA_ACCESS_ERROR, e.getMessage()); return Result.failure(ErrorCode.DATA_ACCESS_ERROR, e.getMessage());
} }
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public Result<String> handleOtherException(Exception e) { public Result<String> handleOtherException(Exception e) {

@ -29,15 +29,15 @@ import java.io.IOException;
* @author onewe * @author onewe
*/ */
public class XssFilter extends OncePerRequestFilter { public class XssFilter extends OncePerRequestFilter {
private static final String CONTENT_SECURITY_POLICY_HEADER = "Content-Security-Policy"; private static final String CONTENT_SECURITY_POLICY_HEADER = "Content-Security-Policy";
private static final String CONTENT_SECURITY_POLICY = "script-src 'self'"; private static final String CONTENT_SECURITY_POLICY = "script-src 'self'";
@Override @Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException { throws ServletException, IOException {
response.setHeader(CONTENT_SECURITY_POLICY_HEADER, CONTENT_SECURITY_POLICY); response.setHeader(CONTENT_SECURITY_POLICY_HEADER, CONTENT_SECURITY_POLICY);
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
} }

@ -30,7 +30,7 @@ import java.util.List;
* @author zhuoguang * @author zhuoguang
*/ */
public class ConsoleDefaultHttpParamExtractor extends AbstractHttpParamExtractor { public class ConsoleDefaultHttpParamExtractor extends AbstractHttpParamExtractor {
@Override @Override
public List<ParamInfo> extractParam(HttpServletRequest request) { public List<ParamInfo> extractParam(HttpServletRequest request) {
ParamInfo paramInfo = new ParamInfo(); ParamInfo paramInfo = new ParamInfo();
@ -40,7 +40,7 @@ public class ConsoleDefaultHttpParamExtractor extends AbstractHttpParamExtractor
paramInfos.add(paramInfo); paramInfos.add(paramInfo);
return paramInfos; return paramInfos;
} }
private String getAliasNamespaceId(HttpServletRequest request) { private String getAliasNamespaceId(HttpServletRequest request) {
String namespaceId = request.getParameter("namespaceId"); String namespaceId = request.getParameter("namespaceId");
if (StringUtils.isBlank(namespaceId)) { if (StringUtils.isBlank(namespaceId)) {
@ -48,7 +48,7 @@ public class ConsoleDefaultHttpParamExtractor extends AbstractHttpParamExtractor
} }
return namespaceId; return namespaceId;
} }
private String getAliasNamespaceShowName(HttpServletRequest request) { private String getAliasNamespaceShowName(HttpServletRequest request) {
String namespaceShowName = request.getParameter("namespaceName"); String namespaceShowName = request.getParameter("namespaceName");
return namespaceShowName; return namespaceShowName;

@ -48,14 +48,6 @@ db.password.0=root
nacos.config.push.maxRetryTime=50 nacos.config.push.maxRetryTime=50
#*************** Naming Module Related Configurations ***************# #*************** Naming Module Related Configurations ***************#
### Data dispatch task execution period in milliseconds:
### If enable data warmup. If set to false, the server would accept request without local data preparation: ### If enable data warmup. If set to false, the server would accept request without local data preparation:
# nacos.naming.data.warmup=true # nacos.naming.data.warmup=true

@ -172,7 +172,7 @@ CREATE TABLE `his_config_info` (
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
`op_type` char(10) DEFAULT NULL COMMENT 'operation type', `op_type` char(10) DEFAULT NULL COMMENT 'operation type',
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`encrypted_data_key` text NOT NULL COMMENT '密钥', `encrypted_data_key` varchar(1024) NOT NULL DEFAULT '' COMMENT '密钥',
PRIMARY KEY (`nid`), PRIMARY KEY (`nid`),
KEY `idx_gmt_create` (`gmt_create`), KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`), KEY `idx_gmt_modified` (`gmt_modified`),

Loading…
Cancel
Save