mirror of
https://github.com/minio/minio.git
synced 2025-01-12 07:23:23 -05:00
fix: honor token based authentication in NATS streaming (#9296)
fixes #9148
This commit is contained in:
parent
e51e465543
commit
2054ca5c9a
@ -121,6 +121,10 @@ func (n NATSArgs) Validate() error {
|
|||||||
return errors.New("cert and key must be specified as a pair")
|
return errors.New("cert and key must be specified as a pair")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if n.Username != "" && n.Password == "" || n.Username == "" && n.Password != "" {
|
||||||
|
return errors.New("username and password must be specified as a pair")
|
||||||
|
}
|
||||||
|
|
||||||
if n.Streaming.Enable {
|
if n.Streaming.Enable {
|
||||||
if n.Streaming.ClusterID == "" {
|
if n.Streaming.ClusterID == "" {
|
||||||
return errors.New("empty cluster id")
|
return errors.New("empty cluster id")
|
||||||
@ -168,7 +172,15 @@ func (n NATSArgs) connectStan() (stan.Conn, error) {
|
|||||||
if n.Secure {
|
if n.Secure {
|
||||||
scheme = "tls"
|
scheme = "tls"
|
||||||
}
|
}
|
||||||
addressURL := scheme + "://" + n.Username + ":" + n.Password + "@" + n.Address.String()
|
|
||||||
|
var addressURL string
|
||||||
|
if n.Username != "" && n.Password != "" {
|
||||||
|
addressURL = scheme + "://" + n.Username + ":" + n.Password + "@" + n.Address.String()
|
||||||
|
} else if n.Token != "" {
|
||||||
|
addressURL = scheme + "://" + n.Token + "@" + n.Address.String()
|
||||||
|
} else {
|
||||||
|
addressURL = scheme + "://" + n.Address.String()
|
||||||
|
}
|
||||||
|
|
||||||
clientID, err := getNewUUID()
|
clientID, err := getNewUUID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user