From 683887ca97eb7f3829c03500addcd7eba9aa07dd Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Thu, 29 Apr 2021 12:28:37 +0200 Subject: [PATCH] allow custom authenticators to set a username Signed-off-by: R.I.Pienaar --- server/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/client.go b/server/client.go index 802b5d37..b57d5f99 100644 --- a/server/client.go +++ b/server/client.go @@ -793,10 +793,17 @@ func (c *client) RegisterUser(user *User) { } else { c.setPermissions(user.Permissions) } + + // allows custom authenticators to set a username to be reported in + // server events and more + if user.Username != _EMPTY_ { + c.opts.Username = user.Username + } + c.mu.Unlock() } -// RegisterNkey allows auth to call back into a new nkey +// RegisterNkeyUser allows auth to call back into a new nkey // client with the authenticated user. This is used to map // any permissions into the client and setup accounts. func (c *client) RegisterNkeyUser(user *NkeyUser) error {