mirror of
https://github.com/juanfont/headscale.git
synced 2025-01-19 10:20:05 +09:00
Add missing iff to handle expired preauthkey machines
This commit is contained in:
parent
9968992be0
commit
fdd64d98c8
1 changed files with 13 additions and 7 deletions
20
api.go
20
api.go
|
@ -364,15 +364,21 @@ func (h *Headscale) handleMachineExpired(
|
||||||
Str("machine", machine.Name).
|
Str("machine", machine.Name).
|
||||||
Msg("Machine registration has expired. Sending a authurl to register")
|
Msg("Machine registration has expired. Sending a authurl to register")
|
||||||
|
|
||||||
if h.cfg.OIDC.Issuer != "" {
|
if registerRequest.Auth.AuthKey != "" {
|
||||||
resp.AuthURL = fmt.Sprintf("%s/oidc/register/%s",
|
h.handleAuthKey(ctx, machineKey, registerRequest, machine)
|
||||||
strings.TrimSuffix(h.cfg.ServerURL, "/"), idKey.HexString())
|
|
||||||
} else {
|
return
|
||||||
resp.AuthURL = fmt.Sprintf("%s/register?key=%s",
|
|
||||||
strings.TrimSuffix(h.cfg.ServerURL, "/"), idKey.HexString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
if h.cfg.OIDC.Issuer != "" {
|
||||||
|
resp.AuthURL = fmt.Sprintf("%s/oidc/register/%s",
|
||||||
|
strings.TrimSuffix(h.cfg.ServerURL, "/"), machineKey.HexString())
|
||||||
|
} else {
|
||||||
|
resp.AuthURL = fmt.Sprintf("%s/register?key=%s",
|
||||||
|
strings.TrimSuffix(h.cfg.ServerURL, "/"), machineKey.HexString())
|
||||||
|
}
|
||||||
|
|
||||||
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("handler", "Registration").
|
Str("handler", "Registration").
|
||||||
|
|
Loading…
Reference in a new issue