Merge pull request #2084 from ripienaar/client_auth_kind

expose the connection kind to CustomClientAuthentication
This commit is contained in:
Ivan Kozlovic
2021-04-08 10:55:33 -06:00
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

@@ -47,6 +47,8 @@ type ClientAuthentication interface {
RegisterUser(*User)
// RemoteAddress expose the connection information of the client
RemoteAddress() net.Addr
// Kind indicates what type of connection this is matching defined constants like CLIENT, ROUTER, GATEWAY, LEAF etc
Kind() int
}
// NkeyUser is for multiple nkey based users

View File

@@ -643,6 +643,15 @@ func (c *client) reportErrRegisterAccount(acc *Account, err error) {
c.sendErr("Failed Account Registration")
}
// Kind returns the client kind and will be one of the defined constants like CLIENT, ROUTER, GATEWAY, LEAF
func (c *client) Kind() int {
c.mu.Lock()
kind := c.kind
c.mu.Unlock()
return kind
}
// registerWithAccount will register the given user with a specific
// account. This will change the subject namespace.
func (c *client) registerWithAccount(acc *Account) error {