From 6741a9698f737c380da4744b68e9fdff631ba185 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Tue, 15 Oct 2024 17:17:30 +0800 Subject: [PATCH] fix: use correct type in user ID context key --- internal/lagoondb/client.go | 4 ++++ internal/sshtoken/authhandler.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/lagoondb/client.go b/internal/lagoondb/client.go index a13829b..c14fba3 100644 --- a/internal/lagoondb/client.go +++ b/internal/lagoondb/client.go @@ -107,6 +107,10 @@ func (c *Client) UserBySSHFingerprint( } return nil, err } + // usid column in set NOT NULL, so this should be impossible + if user.UUID == nil { + return nil, errors.New("NULL user UUID") + } return &user, nil } diff --git a/internal/sshtoken/authhandler.go b/internal/sshtoken/authhandler.go index fd8ba1d..c8b4584 100644 --- a/internal/sshtoken/authhandler.go +++ b/internal/sshtoken/authhandler.go @@ -64,7 +64,7 @@ func pubKeyAuth(log *slog.Logger, ldb LagoonDBService) ssh.PublicKeyHandler { // successful. Inject the user UUID into the context so it can be used in // the session handler. authnSuccessTotal.Inc() - ctx.SetValue(userUUIDkey, user.UUID) + ctx.SetValue(userUUIDkey, *user.UUID) log.Info("authentication successful", slog.String("userUUID", user.UUID.String())) return true