⬆️ Upgrading dependencies. nacos 1.1.4

This commit is contained in:
冷冷 committed 2019-11-01 12:34:23 +08:00
1 parent d9e7a740cf
commit d77d3be2cd
15 files changed
+89 -112

No files matched your search

@@ -19,7 +19,7 @@ package com.alibaba.nacos.console.config;
/**
* @author lengleng
* @date 2019-04-19
* @date 2019-10-31
* <p>
* 覆盖nacos 默认配置
*/
@@ -38,5 +38,4 @@ public interface ConfigConstants {
* tomcat 日志配置
*/
String TOMCAT_ACCESS_LOG = "server.tomcat.accesslog.enabled";
}
}
@@ -75,9 +75,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) {
String ignoreUrls = env.getProperty("nacos.security.ignore.urls", "/**");
for (String url : ignoreUrls.trim().split(SECURITY_IGNORE_URLS_SPILT_CHAR)) {
web.ignoring().antMatchers(url.trim());
String ignoreURLs = env.getProperty("nacos.security.ignore.urls", "/**");
for (String ignoreURL : ignoreURLs.trim().split(SECURITY_IGNORE_URLS_SPILT_CHAR)) {
web.ignoring().antMatchers(ignoreURL.trim());
}
}
@@ -15,11 +15,10 @@
*/
package com.alibaba.nacos.console.controller;
import com.alibaba.nacos.console.config.WebSecurityConfig;
import com.alibaba.nacos.config.server.model.RestResult;
import com.alibaba.nacos.console.config.WebSecurityConfig;
import com.alibaba.nacos.console.security.CustomUserDetailsServiceImpl;
import com.alibaba.nacos.console.utils.JwtTokenUtils;
import com.alibaba.nacos.console.utils.PasswordEncoderUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
@@ -30,7 +29,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
@@ -56,11 +54,8 @@ public class AuthController {
* Nacos is in broken states.
*/
@ResponseBody
@RequestMapping(value = "login", method = RequestMethod.POST)
public RestResult<String> login(HttpServletRequest request, HttpServletResponse response) throws Exception {
String username = request.getParameter("username");
String password = request.getParameter("password");
@PostMapping("login")
public RestResult<String> login(@RequestParam String username, @RequestParam String password, HttpServletResponse response) {
// 通过用户名和密码创建一个 Authentication 认证对象,实现类为 UsernamePasswordAuthenticationToken
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
@@ -85,11 +80,9 @@ public class AuthController {
}
}
@ResponseBody
@RequestMapping(value = "password", method = RequestMethod.PUT)
public RestResult<String> updatePassword(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "oldPassword", required = true) String oldPassword,
@RequestParam(value = "newPassword", required = true) String newPassword) throws Exception {
@PutMapping("password")
public RestResult<String> updatePassword(@RequestParam(value = "oldPassword") String oldPassword,
@RequestParam(value = "newPassword") String newPassword) {
RestResult<String> rr = new RestResult<String>();
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
@@ -21,9 +21,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@@ -52,8 +51,7 @@ public class HealthController {
* @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.
*/
@ResponseBody
@RequestMapping(value = "liveness", method = RequestMethod.GET)
@GetMapping("liveness")
public ResponseEntity liveness() {
return ResponseEntity.ok().body("OK");
}
@@ -64,8 +62,7 @@ public class HealthController {
* @return HTTP code equal to 200 indicates that Nacos is ready. HTTP code equal to 500 indicates that Nacos is not
* ready.
*/
@ResponseBody
@RequestMapping(value = "readiness", method = RequestMethod.GET)
@GetMapping("readiness")
public ResponseEntity readiness(HttpServletRequest request) {
boolean isConfigReadiness = isConfigReadiness();
boolean isNamingReadiness = isNamingReadiness(request);
@@ -15,19 +15,14 @@
*/
package com.alibaba.nacos.console.controller;
import com.alibaba.nacos.config.server.exception.NacosException;
import com.alibaba.nacos.config.server.model.RestResult;
import com.alibaba.nacos.config.server.model.TenantInfo;
import com.alibaba.nacos.config.server.service.PersistService;
import com.alibaba.nacos.config.server.utils.StringUtils;
import com.alibaba.nacos.console.model.Namespace;
import com.alibaba.nacos.console.model.NamespaceAllInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -40,12 +35,12 @@ import java.util.UUID;
*
* @author Nacos
*/
@Controller
@RestController
@RequestMapping("/v1/console/namespaces")
public class NamespaceController {
@Autowired
private transient PersistService persistService;
private PersistService persistService;
/**
* Get namespace list
@@ -54,8 +49,7 @@ public class NamespaceController {
* @param response response
* @return namespace list
*/
@ResponseBody
@RequestMapping(method = RequestMethod.GET)
@GetMapping
public RestResult<List<Namespace>> getNamespaces(HttpServletRequest request, HttpServletResponse response) {
RestResult<List<Namespace>> rr = new RestResult<List<Namespace>>();
rr.setCode(200);
@@ -82,21 +76,18 @@ public class NamespaceController {
* @param namespaceId namespaceId
* @return namespace all info
*/
@ResponseBody
@RequestMapping(params = "show=all", method = RequestMethod.GET)
@GetMapping(params = "show=all")
public NamespaceAllInfo getNamespace(HttpServletRequest request, HttpServletResponse response,
@RequestParam("namespaceId") String namespaceId) {
// TODO 获取用kp
if (StringUtils.isBlank(namespaceId)) {
NamespaceAllInfo namespaceTmp = new NamespaceAllInfo(namespaceId, "Public", 200, persistService.configInfoCount(""), 0,
"Public Namespace");
return namespaceTmp;
return new NamespaceAllInfo(namespaceId, "Public", 200,
persistService.configInfoCount(""), 0, "Public Namespace");
} else {
TenantInfo tenantInfo = persistService.findTenantByKp("1", namespaceId);
int configCount = persistService.configInfoCount(namespaceId);
NamespaceAllInfo namespaceTmp = new NamespaceAllInfo(namespaceId, tenantInfo.getTenantName(), 200,
return new NamespaceAllInfo(namespaceId, tenantInfo.getTenantName(), 200,
configCount, 2, tenantInfo.getTenantDesc());
return namespaceTmp;
}
}
@@ -108,14 +99,11 @@ public class NamespaceController {
* @param namespaceName namespace Name
* @param namespaceDesc namespace Desc
* @return whether create ok
* @throws NacosException
*/
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
@PostMapping
public Boolean createNamespace(HttpServletRequest request, HttpServletResponse response,
@RequestParam("namespaceName") String namespaceName,
@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc)
throws NacosException {
@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
// TODO 获取用kp
String namespaceId = UUID.randomUUID().toString();
persistService.insertTenantInfoAtomic("1", namespaceId, namespaceName, namespaceDesc, "nacos",
@@ -126,21 +114,15 @@ public class NamespaceController {
/**
* edit namespace
*
* @param request request
* @param response response
* @param namespace namespace
* @param namespaceShowName namespace ShowName
* @param namespaceDesc namespace Desc
* @return whether edit ok
* @throws NacosException NacosException
*/
@RequestMapping(method = RequestMethod.PUT)
@ResponseBody
public Boolean editNamespace(HttpServletRequest request, HttpServletResponse response,
@RequestParam("namespace") String namespace,
@PutMapping
public Boolean editNamespace(@RequestParam("namespace") String namespace,
@RequestParam("namespaceShowName") String namespaceShowName,
@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc)
throws NacosException {
@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
// TODO 获取用kp
persistService.updateTenantNameAtomic("1", namespace, namespaceShowName, namespaceDesc);
return true;
@@ -153,12 +135,10 @@ public class NamespaceController {
* @param response response
* @param namespaceId namespace Id
* @return whether del ok
* @throws NacosException NacosException
*/
@RequestMapping(method = RequestMethod.DELETE)
@ResponseBody
@DeleteMapping
public Boolean deleteConfig(HttpServletRequest request, HttpServletResponse response,
@RequestParam("namespaceId") String namespaceId) throws NacosException {
@RequestParam("namespaceId") String namespaceId) {
persistService.removeTenantInfoAtomic("1", namespaceId);
return true;
}
@@ -18,13 +18,11 @@ package com.alibaba.nacos.console.controller;
import com.alibaba.nacos.common.util.VersionUtils;
import com.alibaba.nacos.core.utils.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@@ -36,16 +34,9 @@ import java.util.Map;
@RequestMapping("/v1/console/server")
public class ServerStateController {
private static final Logger logger = LoggerFactory.getLogger(ServerStateController.class);
public static String VERSION ;
@ResponseBody
@RequestMapping(value = "state", method = RequestMethod.GET)
@GetMapping("state")
public ResponseEntity serverState() {
Map<String,String> serverState = new HashMap<String, String>(3);
Map<String,String> serverState = new HashMap<>(3);
serverState.put("standalone_mode",SystemUtils.STANDALONE_MODE ?
SystemUtils.STANDALONE_MODE_ALONE : SystemUtils.STANDALONE_MODE_CLUSTER);
@@ -55,6 +46,4 @@ public class ServerStateController {
return ResponseEntity.ok().body(serverState);
}
}
@@ -69,7 +69,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
private String resolveToken(HttpServletRequest request) {
String bearerToken = request.getHeader(WebSecurityConfig.AUTHORIZATION_HEADER);
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith(TOKEN_PREFIX)) {
return bearerToken.substring(7);
return bearerToken.substring(7, bearerToken.length());
}
String jwt = request.getParameter(WebSecurityConfig.AUTHORIZATION_TOKEN);
if (StringUtils.hasText(jwt)) {