Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rocketmq-console login auth #1116

Merged
merged 7 commits into from
Dec 25, 2024

Conversation

waynedream
Copy link
Contributor

rocketmq-offset插件支持登录认证功能,rocketmq-console在开启登录认证时,原插件无法直接调用接口获取信息,需要先请求login接口获取cookie

rocketmq_offset.toml 配置文件中增加username 和 password 字段
如果配置了账号密码,会先请求登录接口,如果没配置账号密码,还是和原逻辑一样

例子:

collect interval

interval = 15

[[instances]]
rocketmq_console_ip_port="127.0.0.1:8080"
username="admin"
password="123456"
ignored_topics=[]


func (ins *Instance) Login() (string, error) {
loginURL := fmt.Sprintf("%s/login/login.do", consoleSchema + ins.RocketMQConsoleIPAndPort)
data := url.Values{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

net/url 的package没有导入

req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

// 获取 set-cookie 头
cookies := res.Header.Get("Set-Cookie")
Copy link
Collaborator

@kongfei605 kongfei605 Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的代码被误删了

res, err := http.DefaultClient.Do(req)
	if err != nil {
		return "", err
	}

@kongfei605
Copy link
Collaborator

Thank you @waynedream

@kongfei605 kongfei605 merged commit 0d6a10c into flashcatcloud:main Dec 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants