mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed issue #4941 , remove default passwd
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.io.PrintWriter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -26,8 +28,24 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Value(value = "${canal.adminUser}")
|
||||
private String user;
|
||||
|
||||
@Value(value = "${canal.adminPasswd}")
|
||||
private String passwd;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
if (StringUtils.isEmpty(user)) {
|
||||
throw new IllegalArgumentException(
|
||||
"canal.adminUser is empty , pls check https://github.com/alibaba/canal/issues/4941");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(passwd)) {
|
||||
throw new IllegalArgumentException(
|
||||
"canal.adminPasswd is empty , pls check https://github.com/alibaba/canal/issues/4941");
|
||||
}
|
||||
|
||||
registry.addInterceptor(new HandlerInterceptor() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,15 +2,11 @@ package com.alibaba.otter.canal.admin.controller;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.alibaba.otter.canal.admin.model.BaseModel;
|
||||
import com.alibaba.otter.canal.admin.model.CanalConfig;
|
||||
@@ -28,7 +24,7 @@ import com.alibaba.otter.canal.protocol.SecurityUtil;
|
||||
@RequestMapping("/api/{env}/config")
|
||||
public class PollingConfigController {
|
||||
|
||||
private static final byte[] seeds = "canal is best!".getBytes();
|
||||
private static final byte[] seeds = RandomStringUtils.random(16).getBytes();
|
||||
|
||||
@Value(value = "${canal.adminUser}")
|
||||
String user;
|
||||
|
||||
@@ -18,4 +18,4 @@ spring.datasource:
|
||||
|
||||
canal:
|
||||
adminUser: admin
|
||||
adminPasswd: admin
|
||||
adminPasswd:
|
||||
|
||||
@@ -117,8 +117,14 @@ public class CanalController {
|
||||
|
||||
this.adminUser = getProperty(properties, CanalConstants.CANAL_ADMIN_USER);
|
||||
this.adminPasswd = getProperty(properties, CanalConstants.CANAL_ADMIN_PASSWD);
|
||||
embeddedCanalServer.setUser(getProperty(properties, CanalConstants.CANAL_USER));
|
||||
embeddedCanalServer.setPasswd(getProperty(properties, CanalConstants.CANAL_PASSWD));
|
||||
String user = getProperty(properties, CanalConstants.CANAL_USER);
|
||||
String passwd = getProperty(properties, CanalConstants.CANAL_PASSWD);
|
||||
if (StringUtils.isNotEmpty(user) && StringUtils.isEmpty(passwd)) {
|
||||
throw new IllegalArgumentException(
|
||||
"canal.user = " + user + " , but canal.passwd is empty , pls check https://github.com/alibaba/canal/issues/4941");
|
||||
}
|
||||
embeddedCanalServer.setUser(user);
|
||||
embeddedCanalServer.setPasswd(passwd);
|
||||
|
||||
String canalWithoutNetty = getProperty(properties, CanalConstants.CANAL_WITHOUT_NETTY);
|
||||
if (canalWithoutNetty == null || "false".equals(canalWithoutNetty)) {
|
||||
|
||||
@@ -54,6 +54,10 @@ public class CanalLauncher {
|
||||
if (StringUtils.isNotEmpty(managerAddress)) {
|
||||
String user = CanalController.getProperty(properties, CanalConstants.CANAL_ADMIN_USER);
|
||||
String passwd = CanalController.getProperty(properties, CanalConstants.CANAL_ADMIN_PASSWD);
|
||||
if (StringUtils.isEmpty(passwd)) {
|
||||
throw new IllegalArgumentException(
|
||||
"canal.admin.passwd is empty , pls check https://github.com/alibaba/canal/issues/4941");
|
||||
}
|
||||
String adminPort = CanalController.getProperty(properties, CanalConstants.CANAL_ADMIN_PORT, "11110");
|
||||
boolean autoRegister = BooleanUtils.toBoolean(CanalController.getProperty(properties,
|
||||
CanalConstants.CANAL_ADMIN_AUTO_REGISTER));
|
||||
|
||||
@@ -115,7 +115,6 @@ public class CanalStarter {
|
||||
CanalAdminController canalAdmin = new CanalAdminController(this);
|
||||
canalAdmin.setUser(user);
|
||||
canalAdmin.setPasswd(passwd);
|
||||
|
||||
String ip = CanalController.getProperty(properties, CanalConstants.CANAL_IP);
|
||||
|
||||
logger.debug("canal admin port:{}, canal admin user:{}, canal admin password: {}, canal ip:{}",
|
||||
|
||||
@@ -9,13 +9,13 @@ canal.port = 11111
|
||||
canal.metrics.pull.port = 11112
|
||||
# canal instance user/passwd
|
||||
# canal.user = canal
|
||||
# canal.passwd = E3619321C1A937C46A0D8BD1DAC39F93B27D4458
|
||||
# canal.passwd =
|
||||
|
||||
# canal admin config
|
||||
#canal.admin.manager = 127.0.0.1:8089
|
||||
canal.admin.port = 11110
|
||||
canal.admin.user = admin
|
||||
canal.admin.passwd = 4ACFE3202A5FF5CF467898FC58AAB1D615029441
|
||||
canal.admin.passwd =
|
||||
# admin auto register
|
||||
#canal.admin.register.auto = true
|
||||
#canal.admin.register.cluster =
|
||||
|
||||
Reference in New Issue
Block a user