@@ -218,7 +218,7 @@ func (h *Headscale) OIDCCallback(
218218 return
219219 }
220220
221- nodeKey , machineExists , err := h .validateMachineForOIDCCallback (writer , state , claims )
221+ nodeKey , machineExists , err := h .validateMachineForOIDCCallback (writer , state , claims , idToken . Expiry )
222222 if err != nil || machineExists {
223223 return
224224 }
@@ -476,6 +476,7 @@ func (h *Headscale) validateMachineForOIDCCallback(
476476 writer http.ResponseWriter ,
477477 state string ,
478478 claims * IDTokenClaims ,
479+ expiry time.Time ,
479480) (* key.NodePublic , bool , error ) {
480481 // retrieve machinekey from state cache
481482 nodeKeyIf , nodeKeyFound := h .registrationCache .Get (state )
@@ -546,7 +547,7 @@ func (h *Headscale) validateMachineForOIDCCallback(
546547 Str ("machine" , machine .Hostname ).
547548 Msg ("machine already registered, reauthenticating" )
548549
549- err := h .RefreshMachine (machine , time. Time {} )
550+ err := h .RefreshMachine (machine , expiry )
550551 if err != nil {
551552 log .Error ().
552553 Caller ().
@@ -560,6 +561,10 @@ func (h *Headscale) validateMachineForOIDCCallback(
560561
561562 return nil , true , err
562563 }
564+ log .Debug ().
565+ Str ("machine" , machine .Hostname ).
566+ Str ("expiresAt" , fmt .Sprintf ("%v" , expiry )).
567+ Msg ("successfully refreshed machine" )
563568
564569 var content bytes.Buffer
565570 if err := oidcCallbackTemplate .Execute (& content , oidcCallbackTemplateConfig {
0 commit comments