mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
When no_auth_user is set, do not require a CONNECT proto.
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -147,8 +147,7 @@ func (c *client) parse(buf []byte) error {
|
||||
// proper CONNECT if needed.
|
||||
authSet := c.awaitingAuth()
|
||||
// Snapshot max control line as well.
|
||||
mcl := c.mcl
|
||||
trace := c.trace
|
||||
s, mcl, trace := c.srv, c.mcl, c.trace
|
||||
c.mu.Unlock()
|
||||
|
||||
// Move to loop instead of range syntax to allow jumping of i
|
||||
@@ -160,7 +159,24 @@ func (c *client) parse(buf []byte) error {
|
||||
c.op = b
|
||||
if b != 'C' && b != 'c' {
|
||||
if authSet {
|
||||
goto authErr
|
||||
if s == nil {
|
||||
goto authErr
|
||||
}
|
||||
var ok bool
|
||||
// Check here for NoAuthUser. If this is set allow non CONNECT protos as our first.
|
||||
// E.g. telnet proto demos.
|
||||
if noAuthUser := s.getOpts().NoAuthUser; noAuthUser != _EMPTY_ {
|
||||
s.mu.Lock()
|
||||
user, exists := s.users[noAuthUser]
|
||||
s.mu.Unlock()
|
||||
if exists {
|
||||
c.RegisterUser(user)
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
goto authErr
|
||||
}
|
||||
}
|
||||
// If the connection is a gateway connection, make sure that
|
||||
// if this is an inbound, it starts with a CONNECT.
|
||||
|
||||
Reference in New Issue
Block a user