diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java
index 35d1d819..74bef319 100755
--- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java
+++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java
@@ -19,12 +19,10 @@ package com.pig4cloud.pig.auth.endpoint;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.pig4cloud.pig.auth.handler.PigLogoutSuccessEventHandler;
import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.CommonConstants;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.core.util.SpringContextHolder;
-import com.pig4cloud.pig.common.log.event.SysLogEvent;
import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.pig.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
@@ -38,7 +36,6 @@ import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.http.HttpHeaders;
-import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.authentication.event.LogoutSuccessEvent;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
@@ -148,7 +145,7 @@ public class PigTokenEndpoint {
OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
tokenStore.removeRefreshToken(refreshToken);
- //处理自定义退出事件,保存相关日志
+ // 处理自定义退出事件,保存相关日志
SpringContextHolder.publishEvent(new LogoutSuccessEvent(auth2Authentication));
return R.ok();
}
diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/handler/PigLogoutSuccessEventHandler.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/handler/PigLogoutSuccessEventHandler.java
index 50edc245..f7908c75 100644
--- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/handler/PigLogoutSuccessEventHandler.java
+++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/handler/PigLogoutSuccessEventHandler.java
@@ -39,7 +39,6 @@ public class PigLogoutSuccessEventHandler extends AbstractLogoutSuccessEventHand
* 处理退出成功方法
*
* 获取到登录的authentication 对象
- *
* @param authentication 登录对象
*/
@Override
diff --git a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java
index c45808a4..ff0176e7 100755
--- a/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java
+++ b/pig-common/pig-common-log/src/main/java/com/pig4cloud/pig/common/log/util/SysLogUtils.java
@@ -69,13 +69,14 @@ public class SysLogUtils {
OAuth2Authentication auth2Authentication = (OAuth2Authentication) authentication;
return auth2Authentication.getOAuth2Request().getClientId();
}
- if (authentication instanceof UsernamePasswordAuthenticationToken){
+ if (authentication instanceof UsernamePasswordAuthenticationToken) {
// 通过请求参数拿到clientId
String authorizationHeaderValue = request.getHeader("Authorization");
String base64AuthorizationHeader = Optional.ofNullable(authorizationHeaderValue)
- .map(headerValue->headerValue.substring("Basic ".length())).orElse("");
- if(StrUtil.isNotEmpty(base64AuthorizationHeader)) {
- String decodedAuthorizationHeader = new String(Base64.getDecoder().decode(base64AuthorizationHeader), Charset.forName("UTF-8"));
+ .map(headerValue -> headerValue.substring("Basic ".length())).orElse("");
+ if (StrUtil.isNotEmpty(base64AuthorizationHeader)) {
+ String decodedAuthorizationHeader = new String(Base64.getDecoder().decode(base64AuthorizationHeader),
+ Charset.forName("UTF-8"));
return decodedAuthorizationHeader.split(":")[0];
}
}
diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/handler/AbstractLogoutSuccessEventHandler.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/handler/AbstractLogoutSuccessEventHandler.java
index 0863cd2a..add83481 100644
--- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/handler/AbstractLogoutSuccessEventHandler.java
+++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/handler/AbstractLogoutSuccessEventHandler.java
@@ -26,8 +26,7 @@ import org.springframework.security.core.Authentication;
* @author zhangran
* @date 2021/6/23 退出成功事件处理器
*/
-public abstract class AbstractLogoutSuccessEventHandler
- implements ApplicationListener {
+public abstract class AbstractLogoutSuccessEventHandler implements ApplicationListener {
/**
* Handle an application event.
diff --git a/pig-register/src/main/java/com/alibaba/nacos/config/ConsoleConfig.java b/pig-register/src/main/java/com/alibaba/nacos/config/ConsoleConfig.java
index cb51b0a9..76d295fe 100644
--- a/pig-register/src/main/java/com/alibaba/nacos/config/ConsoleConfig.java
+++ b/pig-register/src/main/java/com/alibaba/nacos/config/ConsoleConfig.java
@@ -42,37 +42,37 @@ import org.springframework.web.filter.CorsFilter;
@EnableScheduling
@PropertySource("/application.properties")
public class ConsoleConfig {
-
- @Autowired
- private ControllerMethodsCache methodsCache;
-
- /**
- * Init.
- */
- @PostConstruct
- public void init() {
- methodsCache.initClassMethod("com.alibaba.nacos.core.controller");
- methodsCache.initClassMethod("com.alibaba.nacos.naming.controllers");
- methodsCache.initClassMethod("com.alibaba.nacos.config.server.controller");
- methodsCache.initClassMethod("com.alibaba.nacos.controller");
- }
-
- @Bean
- public CorsFilter corsFilter() {
- CorsConfiguration config = new CorsConfiguration();
- config.setAllowCredentials(true);
- config.addAllowedOrigin("*");
- config.addAllowedHeader("*");
- config.setMaxAge(18000L);
- config.addAllowedMethod("*");
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- source.registerCorsConfiguration("/**", config);
- return new CorsFilter(source);
- }
-
- @Bean
- public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
- return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString());
- }
+
+ @Autowired
+ private ControllerMethodsCache methodsCache;
+
+ /**
+ * Init.
+ */
+ @PostConstruct
+ public void init() {
+ methodsCache.initClassMethod("com.alibaba.nacos.core.controller");
+ methodsCache.initClassMethod("com.alibaba.nacos.naming.controllers");
+ methodsCache.initClassMethod("com.alibaba.nacos.config.server.controller");
+ methodsCache.initClassMethod("com.alibaba.nacos.controller");
+ }
+
+ @Bean
+ public CorsFilter corsFilter() {
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ config.addAllowedOrigin("*");
+ config.addAllowedHeader("*");
+ config.setMaxAge(18000L);
+ config.addAllowedMethod("*");
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ source.registerCorsConfiguration("/**", config);
+ return new CorsFilter(source);
+ }
+
+ @Bean
+ public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
+ return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(ZoneId.systemDefault().toString());
+ }
}
diff --git a/pig-register/src/main/java/com/alibaba/nacos/controller/HealthController.java b/pig-register/src/main/java/com/alibaba/nacos/controller/HealthController.java
index cf889cb6..4cb798ac 100644
--- a/pig-register/src/main/java/com/alibaba/nacos/controller/HealthController.java
+++ b/pig-register/src/main/java/com/alibaba/nacos/controller/HealthController.java
@@ -37,74 +37,77 @@ import javax.servlet.http.HttpServletRequest;
@RestController("consoleHealth")
@RequestMapping("/v1/console/health")
public class HealthController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class);
-
- private final PersistService persistService;
-
- private final OperatorController apiCommands;
-
- @Autowired
- public HealthController(PersistService persistService, OperatorController apiCommands) {
- this.persistService = persistService;
- this.apiCommands = apiCommands;
- }
-
- /**
- * Whether the Nacos is in broken states or not, and cannot recover except by being restarted.
- *
- * @return HTTP code equal to 200 indicates that Nacos is in right states. HTTP code equal to 500 indicates that
- * Nacos is in broken states.
- */
- @GetMapping("/liveness")
- public ResponseEntity liveness() {
- return ResponseEntity.ok().body("OK");
- }
-
- /**
- * Ready to receive the request or not.
- *
- * @return HTTP code equal to 200 indicates that Nacos is ready. HTTP code equal to 500 indicates that Nacos is not
- * ready.
- */
- @GetMapping("/readiness")
- public ResponseEntity readiness(HttpServletRequest request) {
- boolean isConfigReadiness = isConfigReadiness();
- boolean isNamingReadiness = isNamingReadiness(request);
-
- if (isConfigReadiness && isNamingReadiness) {
- return ResponseEntity.ok().body("OK");
- }
-
- if (!isConfigReadiness && !isNamingReadiness) {
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Config and Naming are not in readiness");
- }
-
- if (!isConfigReadiness) {
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Config is not in readiness");
- }
-
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Naming is not in readiness");
- }
-
- private boolean isConfigReadiness() {
- // check db
- try {
- persistService.configInfoCount("");
- return true;
- } catch (Exception e) {
- LOGGER.error("Config health check fail.", e);
- }
- return false;
- }
-
- private boolean isNamingReadiness(HttpServletRequest request) {
- try {
- apiCommands.metrics(request);
- return true;
- } catch (Exception e) {
- LOGGER.error("Naming health check fail.", e);
- }
- return false;
- }
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class);
+
+ private final PersistService persistService;
+
+ private final OperatorController apiCommands;
+
+ @Autowired
+ public HealthController(PersistService persistService, OperatorController apiCommands) {
+ this.persistService = persistService;
+ this.apiCommands = apiCommands;
+ }
+
+ /**
+ * Whether the Nacos is in broken states or not, and cannot recover except by being
+ * restarted.
+ * @return HTTP code equal to 200 indicates that Nacos is in right states. HTTP code
+ * equal to 500 indicates that Nacos is in broken states.
+ */
+ @GetMapping("/liveness")
+ public ResponseEntity liveness() {
+ return ResponseEntity.ok().body("OK");
+ }
+
+ /**
+ * Ready to receive the request or not.
+ * @return HTTP code equal to 200 indicates that Nacos is ready. HTTP code equal to
+ * 500 indicates that Nacos is not ready.
+ */
+ @GetMapping("/readiness")
+ public ResponseEntity readiness(HttpServletRequest request) {
+ boolean isConfigReadiness = isConfigReadiness();
+ boolean isNamingReadiness = isNamingReadiness(request);
+
+ if (isConfigReadiness && isNamingReadiness) {
+ return ResponseEntity.ok().body("OK");
+ }
+
+ if (!isConfigReadiness && !isNamingReadiness) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body("Config and Naming are not in readiness");
+ }
+
+ if (!isConfigReadiness) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Config is not in readiness");
+ }
+
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Naming is not in readiness");
+ }
+
+ private boolean isConfigReadiness() {
+ // check db
+ try {
+ persistService.configInfoCount("");
+ return true;
+ }
+ catch (Exception e) {
+ LOGGER.error("Config health check fail.", e);
+ }
+ return false;
+ }
+
+ private boolean isNamingReadiness(HttpServletRequest request) {
+ try {
+ apiCommands.metrics(request);
+ return true;
+ }
+ catch (Exception e) {
+ LOGGER.error("Naming health check fail.", e);
+ }
+ return false;
+ }
+
}
diff --git a/pig-register/src/main/java/com/alibaba/nacos/controller/NamespaceController.java b/pig-register/src/main/java/com/alibaba/nacos/controller/NamespaceController.java
index b9b7c20a..6a9d6070 100644
--- a/pig-register/src/main/java/com/alibaba/nacos/controller/NamespaceController.java
+++ b/pig-register/src/main/java/com/alibaba/nacos/controller/NamespaceController.java
@@ -69,8 +69,7 @@ public class NamespaceController {
/**
* Get namespace list.
- *
- * @param request request
+ * @param request request
* @param response response
* @return namespace list
*/
@@ -78,8 +77,8 @@ public class NamespaceController {
public RestResult> getNamespaces(HttpServletRequest request, HttpServletResponse response) {
// TODO 获取用kp
List tenantInfos = persistService.findTenantByKp(DEFAULT_KP);
- Namespace namespace0 = new Namespace("", DEFAULT_NAMESPACE, DEFAULT_QUOTA, persistService.configInfoCount(DEFAULT_TENANT),
- NamespaceTypeEnum.GLOBAL.getType());
+ Namespace namespace0 = new Namespace("", DEFAULT_NAMESPACE, DEFAULT_QUOTA,
+ persistService.configInfoCount(DEFAULT_TENANT), NamespaceTypeEnum.GLOBAL.getType());
List namespaces = new ArrayList();
namespaces.add(namespace0);
for (TenantInfo tenantInfo : tenantInfos) {
@@ -93,32 +92,32 @@ public class NamespaceController {
/**
* get namespace all info by namespace id.
- *
- * @param request request
- * @param response response
+ * @param request request
+ * @param response response
* @param namespaceId namespaceId
* @return namespace all info
*/
@GetMapping(params = "show=all")
public NamespaceAllInfo getNamespace(HttpServletRequest request, HttpServletResponse response,
- @RequestParam("namespaceId") String namespaceId) {
+ @RequestParam("namespaceId") String namespaceId) {
// TODO 获取用kp
if (StringUtils.isBlank(namespaceId)) {
- return new NamespaceAllInfo(namespaceId, DEFAULT_NAMESPACE_SHOW_NAME, DEFAULT_QUOTA, persistService.configInfoCount(DEFAULT_TENANT),
- NamespaceTypeEnum.GLOBAL.getType(), DEFAULT_NAMESPACE_DESCRIPTION);
- } else {
+ return new NamespaceAllInfo(namespaceId, DEFAULT_NAMESPACE_SHOW_NAME, DEFAULT_QUOTA,
+ persistService.configInfoCount(DEFAULT_TENANT), NamespaceTypeEnum.GLOBAL.getType(),
+ DEFAULT_NAMESPACE_DESCRIPTION);
+ }
+ else {
TenantInfo tenantInfo = persistService.findTenantByKp(DEFAULT_KP, namespaceId);
int configCount = persistService.configInfoCount(namespaceId);
- return new NamespaceAllInfo(namespaceId, tenantInfo.getTenantName(), DEFAULT_QUOTA, configCount, NamespaceTypeEnum.CUSTOM.getType(),
- tenantInfo.getTenantDesc());
+ return new NamespaceAllInfo(namespaceId, tenantInfo.getTenantName(), DEFAULT_QUOTA, configCount,
+ NamespaceTypeEnum.CUSTOM.getType(), tenantInfo.getTenantDesc());
}
}
/**
* create namespace.
- *
- * @param request request
- * @param response response
+ * @param request request
+ * @param response response
* @param namespaceName namespace Name
* @param namespaceDesc namespace Desc
* @return whether create ok
@@ -126,12 +125,13 @@ public class NamespaceController {
@PostMapping
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
public Boolean createNamespace(HttpServletRequest request, HttpServletResponse response,
- @RequestParam("customNamespaceId") String namespaceId, @RequestParam("namespaceName") String namespaceName,
- @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
+ @RequestParam("customNamespaceId") String namespaceId, @RequestParam("namespaceName") String namespaceName,
+ @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
// TODO 获取用kp
if (StringUtils.isBlank(namespaceId)) {
namespaceId = UUID.randomUUID().toString();
- } else {
+ }
+ else {
namespaceId = namespaceId.trim();
if (!namespaceIdCheckPattern.matcher(namespaceId).matches()) {
return false;
@@ -143,14 +143,13 @@ public class NamespaceController {
return false;
}
}
- persistService.insertTenantInfoAtomic(DEFAULT_KP, namespaceId, namespaceName, namespaceDesc, DEFAULT_CREATE_SOURCE,
- System.currentTimeMillis());
+ persistService.insertTenantInfoAtomic(DEFAULT_KP, namespaceId, namespaceName, namespaceDesc,
+ DEFAULT_CREATE_SOURCE, System.currentTimeMillis());
return true;
}
/**
* check namespaceId exist.
- *
* @param namespaceId namespace id
* @return true if exist, otherwise false
*/
@@ -164,17 +163,16 @@ public class NamespaceController {
/**
* edit namespace.
- *
- * @param namespace namespace
+ * @param namespace namespace
* @param namespaceShowName namespace ShowName
- * @param namespaceDesc namespace Desc
+ * @param namespaceDesc namespace Desc
* @return whether edit ok
*/
@PutMapping
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
public Boolean editNamespace(@RequestParam("namespace") String namespace,
- @RequestParam("namespaceShowName") String namespaceShowName,
- @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
+ @RequestParam("namespaceShowName") String namespaceShowName,
+ @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
// TODO 获取用kp
persistService.updateTenantNameAtomic(DEFAULT_KP, namespace, namespaceShowName, namespaceDesc);
return true;
@@ -182,16 +180,15 @@ public class NamespaceController {
/**
* del namespace by id.
- *
- * @param request request
- * @param response response
+ * @param request request
+ * @param response response
* @param namespaceId namespace Id
* @return whether del ok
*/
@DeleteMapping
@Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
public Boolean deleteConfig(HttpServletRequest request, HttpServletResponse response,
- @RequestParam("namespaceId") String namespaceId) {
+ @RequestParam("namespaceId") String namespaceId) {
persistService.removeTenantInfoAtomic(DEFAULT_KP, namespaceId);
return true;
}
diff --git a/pig-register/src/main/java/com/alibaba/nacos/controller/PermissionController.java b/pig-register/src/main/java/com/alibaba/nacos/controller/PermissionController.java
index 1acb2d96..74cc79e1 100644
--- a/pig-register/src/main/java/com/alibaba/nacos/controller/PermissionController.java
+++ b/pig-register/src/main/java/com/alibaba/nacos/controller/PermissionController.java
@@ -39,53 +39,51 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/v1/auth/permissions")
public class PermissionController {
-
- @Autowired
- private NacosRoleServiceImpl nacosRoleService;
-
- /**
- * Query permissions of a role.
- *
- * @param role the role
- * @param pageNo page index
- * @param pageSize page size
- * @return permission of a role
- */
- @GetMapping
- @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.READ)
- public Object getPermissions(@RequestParam int pageNo, @RequestParam int pageSize,
- @RequestParam(name = "role", defaultValue = StringUtils.EMPTY) String role) {
- return nacosRoleService.getPermissionsFromDatabase(role, pageNo, pageSize);
- }
-
- /**
- * Add a permission to a role.
- *
- * @param role the role
- * @param resource the related resource
- * @param action the related action
- * @return ok if succeed
- */
- @PostMapping
- @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.WRITE)
- public Object addPermission(@RequestParam String role, @RequestParam String resource, @RequestParam String action) {
- nacosRoleService.addPermission(role, resource, action);
- return RestResultUtils.success("add permission ok!");
- }
-
- /**
- * Delete a permission from a role.
- *
- * @param role the role
- * @param resource the related resource
- * @param action the related action
- * @return ok if succeed
- */
- @DeleteMapping
- @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.WRITE)
- public Object deletePermission(@RequestParam String role, @RequestParam String resource,
- @RequestParam String action) {
- nacosRoleService.deletePermission(role, resource, action);
- return RestResultUtils.success("delete permission ok!");
- }
+
+ @Autowired
+ private NacosRoleServiceImpl nacosRoleService;
+
+ /**
+ * Query permissions of a role.
+ * @param role the role
+ * @param pageNo page index
+ * @param pageSize page size
+ * @return permission of a role
+ */
+ @GetMapping
+ @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.READ)
+ public Object getPermissions(@RequestParam int pageNo, @RequestParam int pageSize,
+ @RequestParam(name = "role", defaultValue = StringUtils.EMPTY) String role) {
+ return nacosRoleService.getPermissionsFromDatabase(role, pageNo, pageSize);
+ }
+
+ /**
+ * Add a permission to a role.
+ * @param role the role
+ * @param resource the related resource
+ * @param action the related action
+ * @return ok if succeed
+ */
+ @PostMapping
+ @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.WRITE)
+ public Object addPermission(@RequestParam String role, @RequestParam String resource, @RequestParam String action) {
+ nacosRoleService.addPermission(role, resource, action);
+ return RestResultUtils.success("add permission ok!");
+ }
+
+ /**
+ * Delete a permission from a role.
+ * @param role the role
+ * @param resource the related resource
+ * @param action the related action
+ * @return ok if succeed
+ */
+ @DeleteMapping
+ @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.WRITE)
+ public Object deletePermission(@RequestParam String role, @RequestParam String resource,
+ @RequestParam String action) {
+ nacosRoleService.deletePermission(role, resource, action);
+ return RestResultUtils.success("delete permission ok!");
+ }
+
}
diff --git a/pig-register/src/main/java/com/alibaba/nacos/controller/RoleController.java b/pig-register/src/main/java/com/alibaba/nacos/controller/RoleController.java
index 71a9c2be..5c31c376 100644
--- a/pig-register/src/main/java/com/alibaba/nacos/controller/RoleController.java
+++ b/pig-register/src/main/java/com/alibaba/nacos/controller/RoleController.java
@@ -41,70 +41,69 @@ import java.util.List;
@RestController
@RequestMapping("/v1/auth/roles")
public class RoleController {
-
- @Autowired
- private NacosRoleServiceImpl roleService;
-
- /**
- * Get roles list.
- *
- * @param pageNo number index of page
- * @param pageSize page size
- * @param username optional, username of user
- * @return role list
- */
- @GetMapping
- @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.READ)
- public Object getRoles(@RequestParam int pageNo, @RequestParam int pageSize,
- @RequestParam(name = "username", defaultValue = "") String username) {
- 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 searchRoles(@RequestParam String role) {
- return roleService.findRolesLikeRoleName(role);
- }
-
- /**
- * Add a role to a user
- *
- * This method is used for 2 functions: 1. create a role and bind it to GLOBAL_ADMIN. 2. bind a role to an user.
- *
- * @param role role name
- * @param username username
- * @return Code 200 and message 'add role ok!'
- */
- @PostMapping
- @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.WRITE)
- public Object addRole(@RequestParam String role, @RequestParam String username) {
- roleService.addRole(role, username);
- return RestResultUtils.success("add role ok!");
- }
-
- /**
- * Delete a role. If no username is specified, all users under this role are deleted.
- *
- * @param role role
- * @param username username
- * @return ok if succeed
- */
- @DeleteMapping
- @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.WRITE)
- public Object deleteRole(@RequestParam String role,
- @RequestParam(name = "username", defaultValue = StringUtils.EMPTY) String username) {
- if (StringUtils.isBlank(username)) {
- roleService.deleteRole(role);
- } else {
- roleService.deleteRole(role, username);
- }
- return RestResultUtils.success("delete role of user " + username + " ok!");
- }
-
+
+ @Autowired
+ private NacosRoleServiceImpl roleService;
+
+ /**
+ * Get roles list.
+ * @param pageNo number index of page
+ * @param pageSize page size
+ * @param username optional, username of user
+ * @return role list
+ */
+ @GetMapping
+ @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.READ)
+ public Object getRoles(@RequestParam int pageNo, @RequestParam int pageSize,
+ @RequestParam(name = "username", defaultValue = "") String username) {
+ 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 searchRoles(@RequestParam String role) {
+ return roleService.findRolesLikeRoleName(role);
+ }
+
+ /**
+ * Add a role to a user
+ *
+ *
+ * This method is used for 2 functions: 1. create a role and bind it to GLOBAL_ADMIN.
+ * 2. bind a role to an user.
+ * @param role role name
+ * @param username username
+ * @return Code 200 and message 'add role ok!'
+ */
+ @PostMapping
+ @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.WRITE)
+ public Object addRole(@RequestParam String role, @RequestParam String username) {
+ roleService.addRole(role, username);
+ return RestResultUtils.success("add role ok!");
+ }
+
+ /**
+ * Delete a role. If no username is specified, all users under this role are deleted.
+ * @param role role
+ * @param username username
+ * @return ok if succeed
+ */
+ @DeleteMapping
+ @Secured(resource = NacosAuthConfig.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.WRITE)
+ public Object deleteRole(@RequestParam String role,
+ @RequestParam(name = "username", defaultValue = StringUtils.EMPTY) String username) {
+ if (StringUtils.isBlank(username)) {
+ roleService.deleteRole(role);
+ }
+ else {
+ roleService.deleteRole(role, username);
+ }
+ return RestResultUtils.success("delete role of user " + username + " ok!");
+ }
+
}
diff --git a/pig-register/src/main/java/com/alibaba/nacos/controller/ServerStateController.java b/pig-register/src/main/java/com/alibaba/nacos/controller/ServerStateController.java
index c5c2db42..1ed07f9d 100644
--- a/pig-register/src/main/java/com/alibaba/nacos/controller/ServerStateController.java
+++ b/pig-register/src/main/java/com/alibaba/nacos/controller/ServerStateController.java
@@ -34,22 +34,21 @@ import java.util.Map;
@RestController
@RequestMapping("/v1/console/server")
public class ServerStateController {
-
- /**
- * Get server state of current server.
- *
- * @return state json.
- */
- @GetMapping("/state")
- public ResponseEntity