Skip to content

Commit

Permalink
Merge pull request #1341 from tufanbarisyildirim/auth_endpoint_1336
Browse files Browse the repository at this point in the history
ability to configure auth endpoint path
  • Loading branch information
ploxiln authored May 11, 2021
2 parents a1da117 + d28b50e commit 1039fc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/nsqd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func nsqdFlagSet(opts *nsqd.Options) *flag.FlagSet {
flagSet.String("http-address", opts.HTTPAddress, "<addr>:<port> to listen on for HTTP clients")
flagSet.String("tcp-address", opts.TCPAddress, "<addr>:<port> to listen on for TCP clients")
authHTTPAddresses := app.StringArray{}
flagSet.Var(&authHTTPAddresses, "auth-http-address", "<addr>:<port> to query auth server (may be given multiple times)")
flagSet.Var(&authHTTPAddresses, "auth-http-address", "<addr>:<port> or a full url to query auth server (may be given multiple times)")
flagSet.String("broadcast-address", opts.BroadcastAddress, "address that will be registered with lookupd (defaults to the OS hostname)")
flagSet.Int("broadcast-tcp-port", opts.BroadcastTCPPort, "TCP port that will be registered with lookupd (defaults to the TCP port that this nsqd is listening on)")
flagSet.Int("broadcast-http-port", opts.BroadcastHTTPPort, "HTTP port that will be registered with lookupd (defaults to the HTTP port that this nsqd is listening on)")
Expand Down
8 changes: 7 additions & 1 deletion internal/auth/authorizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/rand"
"net/url"
"regexp"
"strings"
"time"

"github.com/nsqio/nsq/internal/http_api"
Expand Down Expand Up @@ -105,7 +106,12 @@ func QueryAuthd(authd string, remoteIP string, tlsEnabled bool, commonName strin
v.Set("secret", authSecret)
v.Set("common_name", commonName)

endpoint := fmt.Sprintf("http://%s/auth?%s", authd, v.Encode())
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())
}

var authState State
client := http_api.NewClient(nil, connectTimeout, requestTimeout)
Expand Down

0 comments on commit 1039fc5

Please sign in to comment.