From 8dcc82ceb38123ac417c79da734e9fd7654d4695 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 26 Sep 2022 09:51:23 +0200 Subject: [PATCH] Use oidc if it initialised, not if it is configured OIDC might be configured, but unable to be initialised, this only runs the oidc cycle if it is actually successfully set up/initialised. Prep for next commit Signed-off-by: Kristoffer Dalby --- protocol_common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol_common.go b/protocol_common.go index b4c6223..465279a 100644 --- a/protocol_common.go +++ b/protocol_common.go @@ -483,7 +483,7 @@ func (h *Headscale) handleNewMachineCommon( Bool("noise", machineKey.IsZero()). Str("machine", registerRequest.Hostinfo.Hostname). Msg("The node seems to be new, sending auth url") - if h.cfg.OIDC.Issuer != "" { + if h.oauth2Config != nil { resp.AuthURL = fmt.Sprintf( "%s/oidc/register/%s", strings.TrimSuffix(h.cfg.ServerURL, "/"), @@ -716,7 +716,7 @@ func (h *Headscale) handleMachineExpiredCommon( return } - if h.cfg.OIDC.Issuer != "" { + if h.oauth2Config != nil { resp.AuthURL = fmt.Sprintf("%s/oidc/register/%s", strings.TrimSuffix(h.cfg.ServerURL, "/"), NodePublicKeyStripPrefix(registerRequest.NodeKey))