mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
feat(coderd/x/nats): require client auth when ClusterAuthToken is set
This commit is contained in:
@@ -34,6 +34,9 @@ func buildServerOptions(opts Options) (*natsserver.Options, error) {
|
||||
sopts.DontListen = false
|
||||
sopts.Host = "127.0.0.1"
|
||||
sopts.Port = natsserver.RANDOM_PORT
|
||||
if opts.ClusterAuthToken != "" {
|
||||
sopts.Authorization = opts.ClusterAuthToken
|
||||
}
|
||||
|
||||
if !opts.disableCluster {
|
||||
clusterHost := opts.ClusterHost
|
||||
@@ -94,6 +97,9 @@ func connectClient(ns *natsserver.Server, opts Options, handlers connHandlers, c
|
||||
connOpts := []natsgo.Option{
|
||||
natsgo.Name(connName),
|
||||
}
|
||||
if opts.ClusterAuthToken != "" {
|
||||
connOpts = append(connOpts, natsgo.Token(opts.ClusterAuthToken))
|
||||
}
|
||||
if opts.ReconnectWait > 0 {
|
||||
connOpts = append(connOpts, natsgo.ReconnectWait(opts.ReconnectWait))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user