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

nsqd: ability to configure auth endpoint path #1336

Closed
Misiu opened this issue Apr 11, 2021 · 4 comments
Closed

nsqd: ability to configure auth endpoint path #1336

Misiu opened this issue Apr 11, 2021 · 4 comments

Comments

@Misiu
Copy link

Misiu commented Apr 11, 2021

Hi there,
Currently when using -auth-http-address=host:port the endpoint is hardcoded to /auth

endpoint := fmt.Sprintf("http://%s/auth?%s", authd, v.Encode())

I have an identity server in my solution that is already using this endpoint. I'd like to be able to customize the URL, for example, I'd like to change it from /auth to /nsq/auth.

Also, I noticed that the docs don't describe the common_name parameter that can be used with auth.

@mreiferson
Copy link
Member

seems reasonable to me, would you like to submit a PR?

@mreiferson mreiferson changed the title Give the ability to configure auth endpoint nsqd: ability to configure auth endpoint path Apr 14, 2021
@Misiu
Copy link
Author

Misiu commented Apr 14, 2021

@mreiferson sadly I don't know GO at all, so it might be hard for me to set up the dev environment and do that small change in a correct way.
Maybe instead of adding another parameter, we could reuse auth-http-address, so if someone will enter a value containing / then we would do:
endpoint := fmt.Sprintf("http://%s?%s", authd, v.Encode())

So we should check if the value entered in that parameter contains / and then do a proper replacement.

The second option would be to add auth-http-endpoint, but as I wrote I have no GO experience, so I can't say what option would be better.

@tufanbarisyildirim
Copy link
Contributor

tufanbarisyildirim commented Apr 25, 2021

Hi @Misiu setting the -auth-http-address option sth like -auth-http-address=auth.example.com/nsq worked for us, give it try maybe?. I also think, just checking the http prefix and not touching if it is already a url and just adding query params would be a good option. I would like to send a PR if that makes sense @mreiferson

so, this line

endpoint := fmt.Sprintf("http://%s/auth?%s", authd, v.Encode())

could be changed like, to keep it backward compatible.

	var endpoint string
	if strings.HasPrefix(authd, "http") {
		endpoint = fmt.Sprintf("%s?%s", authd, v.Encode())
	} else {
		endpoint = fmt.Sprintf("http://%s/auth?%s", authd, v.Encode())
	}

@mreiferson
Copy link
Member

@tufanbarisyildirim sure, feel free to open a PR, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants