mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
ensure connect events are always sent
Signed-off-by: R.I.Pienaar <rip@devco.net>
This commit is contained in:
@@ -326,11 +326,20 @@ func (s *Server) isClientAuthorized(c *client) bool {
|
||||
// Check custom auth first, then jwts, then nkeys, then
|
||||
// multiple users with TLS map if enabled, then token,
|
||||
// then single user/pass.
|
||||
if opts.CustomClientAuthentication != nil {
|
||||
return opts.CustomClientAuthentication.Check(c)
|
||||
if opts.CustomClientAuthentication != nil && !opts.CustomClientAuthentication.Check(c) {
|
||||
return false
|
||||
}
|
||||
|
||||
return s.processClientOrLeafAuthentication(c, opts)
|
||||
if opts.CustomClientAuthentication == nil && !s.processClientOrLeafAuthentication(c, opts) {
|
||||
return false
|
||||
}
|
||||
|
||||
if c.kind == CLIENT || c.kind == LEAF {
|
||||
// Generate an event if we have a system account.
|
||||
s.accountConnectEvent(c)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *Server) processClientOrLeafAuthentication(c *client, opts *Options) bool {
|
||||
@@ -632,9 +641,6 @@ func (s *Server) processClientOrLeafAuthentication(c *client, opts *Options) boo
|
||||
c.nameTag = juc.Name
|
||||
c.mu.Unlock()
|
||||
|
||||
// Generate an event if we have a system account.
|
||||
s.accountConnectEvent(c)
|
||||
|
||||
// Check if we need to set an auth timer if the user jwt expires.
|
||||
c.setExpiration(juc.Claims(), validFor)
|
||||
|
||||
@@ -680,8 +686,6 @@ func (s *Server) processClientOrLeafAuthentication(c *client, opts *Options) boo
|
||||
// for pub/sub authorizations.
|
||||
if ok {
|
||||
c.RegisterUser(user)
|
||||
// Generate an event if we have a system account and this is not the $G account.
|
||||
s.accountConnectEvent(c)
|
||||
}
|
||||
return ok
|
||||
}
|
||||
@@ -1011,7 +1015,7 @@ func (s *Server) isLeafNodeAuthorized(c *client) bool {
|
||||
// Still, if the CONNECT has some user info, we will bind to the
|
||||
// user's account or to the specified default account (if provided)
|
||||
// or to the global account.
|
||||
return s.processClientOrLeafAuthentication(c, opts)
|
||||
return s.isClientAuthorized(c)
|
||||
}
|
||||
|
||||
// Support for bcrypt stored passwords and tokens.
|
||||
|
||||
Reference in New Issue
Block a user