From cbf57e27a78922c88edd8de8f02c99810a653786 Mon Sep 17 00:00:00 2001 From: DeveloperDragon <42499964+TotoTheDragon@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:45:35 +0100 Subject: [PATCH] Login with OIDC after having been logged out (#1719) --- hscontrol/auth.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hscontrol/auth.go b/hscontrol/auth.go index 4fe5a16b..9b44c2d8 100644 --- a/hscontrol/auth.go +++ b/hscontrol/auth.go @@ -199,6 +199,19 @@ func (h *Headscale) handleRegister( return } + // When logged out and reauthenticating with OIDC, the OldNodeKey is not passed, but the NodeKey has changed + if node.NodeKey.String() != registerRequest.NodeKey.String() && + registerRequest.OldNodeKey.IsZero() && !node.IsExpired() { + h.handleNodeKeyRefresh( + writer, + registerRequest, + *node, + machineKey, + ) + + return + } + if registerRequest.Followup != "" { select { case <-req.Context().Done():