2023-05-10 03:24:05 -04:00
|
|
|
package hscontrol
|
2022-08-14 15:15:58 -04:00
|
|
|
|
|
|
|
import (
|
2022-08-19 08:20:24 -04:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
2022-08-14 15:15:58 -04:00
|
|
|
"net/http"
|
2022-08-19 08:20:24 -04:00
|
|
|
"strings"
|
|
|
|
"time"
|
2022-08-14 15:15:58 -04:00
|
|
|
|
2023-05-26 06:26:34 -04:00
|
|
|
"github.com/juanfont/headscale/hscontrol/mapper"
|
2023-05-21 12:37:59 -04:00
|
|
|
"github.com/juanfont/headscale/hscontrol/types"
|
2023-05-11 03:09:18 -04:00
|
|
|
"github.com/juanfont/headscale/hscontrol/util"
|
2022-08-14 15:15:58 -04:00
|
|
|
"github.com/rs/zerolog/log"
|
2022-08-19 08:20:24 -04:00
|
|
|
"gorm.io/gorm"
|
2022-08-14 15:15:58 -04:00
|
|
|
"tailscale.com/tailcfg"
|
2022-08-19 08:20:24 -04:00
|
|
|
"tailscale.com/types/key"
|
2022-08-14 15:15:58 -04:00
|
|
|
)
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
// handleRegister is the common logic for registering a client in the legacy and Noise protocols
|
2022-08-19 08:20:24 -04:00
|
|
|
//
|
|
|
|
// When using Noise, the machineKey is Zero.
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleRegister(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
|
|
|
req *http.Request,
|
|
|
|
registerRequest tailcfg.RegisterRequest,
|
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
now := time.Now().UTC()
|
2023-05-11 03:09:18 -04:00
|
|
|
machine, err := h.db.GetMachineByAnyKey(machineKey, registerRequest.NodeKey, registerRequest.OldNodeKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
// If the machine has AuthKey set, handle registration via PreAuthKeys
|
|
|
|
if registerRequest.Auth.AuthKey != "" {
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleAuthKey(writer, registerRequest, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the node is waiting for interactive login.
|
|
|
|
//
|
|
|
|
// TODO(juan): We could use this field to improve our protocol implementation,
|
|
|
|
// and hold the request until the client closes it, or the interactive
|
|
|
|
// login is completed (i.e., the user registers the machine).
|
|
|
|
// This is not implemented yet, as it is no strictly required. The only side-effect
|
|
|
|
// is that the client will hammer headscale with requests until it gets a
|
|
|
|
// successful RegisterResponse.
|
|
|
|
if registerRequest.Followup != "" {
|
2023-05-11 03:09:18 -04:00
|
|
|
if _, ok := h.registrationCache.Get(util.NodePublicKeyStripPrefix(registerRequest.NodeKey)); ok {
|
2022-08-19 08:20:24 -04:00
|
|
|
log.Debug().
|
|
|
|
Caller().
|
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
2022-12-09 11:56:43 -05:00
|
|
|
Str("machine_key", machineKey.ShortString()).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("node_key", registerRequest.NodeKey.ShortString()).
|
|
|
|
Str("node_key_old", registerRequest.OldNodeKey.ShortString()).
|
|
|
|
Str("follow_up", registerRequest.Followup).
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Msg("Machine is waiting for interactive login")
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-req.Context().Done():
|
|
|
|
return
|
2023-03-20 06:14:34 -04:00
|
|
|
case <-time.After(registrationHoldoff):
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleNewMachine(writer, registerRequest, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info().
|
|
|
|
Caller().
|
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
2022-12-09 11:56:43 -05:00
|
|
|
Str("machine_key", machineKey.ShortString()).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("node_key", registerRequest.NodeKey.ShortString()).
|
|
|
|
Str("node_key_old", registerRequest.OldNodeKey.ShortString()).
|
|
|
|
Str("follow_up", registerRequest.Followup).
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Msg("New machine not yet in the database")
|
|
|
|
|
2023-05-11 03:09:18 -04:00
|
|
|
givenName, err := h.db.GenerateGivenName(
|
2022-10-21 08:42:37 -04:00
|
|
|
machineKey.String(),
|
|
|
|
registerRequest.Hostinfo.Hostname,
|
|
|
|
)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
|
|
|
Str("func", "RegistrationHandler").
|
|
|
|
Str("hostinfo.name", registerRequest.Hostinfo.Hostname).
|
|
|
|
Err(err)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// The machine did not have a key to authenticate, which means
|
|
|
|
// that we rely on a method that calls back some how (OpenID or CLI)
|
|
|
|
// We create the machine and then keep it around until a callback
|
|
|
|
// happens
|
2023-05-21 12:37:59 -04:00
|
|
|
newMachine := types.Machine{
|
2023-05-11 03:09:18 -04:00
|
|
|
MachineKey: util.MachinePublicKeyStripPrefix(machineKey),
|
2022-08-19 08:20:24 -04:00
|
|
|
Hostname: registerRequest.Hostinfo.Hostname,
|
|
|
|
GivenName: givenName,
|
2023-05-11 03:09:18 -04:00
|
|
|
NodeKey: util.NodePublicKeyStripPrefix(registerRequest.NodeKey),
|
2022-08-19 08:20:24 -04:00
|
|
|
LastSeen: &now,
|
|
|
|
Expiry: &time.Time{},
|
|
|
|
}
|
|
|
|
|
|
|
|
if !registerRequest.Expiry.IsZero() {
|
|
|
|
log.Trace().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Time("expiry", registerRequest.Expiry).
|
|
|
|
Msg("Non-zero expiry time requested")
|
|
|
|
newMachine.Expiry = ®isterRequest.Expiry
|
|
|
|
}
|
|
|
|
|
|
|
|
h.registrationCache.Set(
|
|
|
|
newMachine.NodeKey,
|
|
|
|
newMachine,
|
|
|
|
registerCacheExpiration,
|
|
|
|
)
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleNewMachine(writer, registerRequest, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
// The machine is already in the DB. This could mean one of the following:
|
|
|
|
// - The machine is authenticated and ready to /map
|
|
|
|
// - We are doing a key refresh
|
|
|
|
// - The machine is logged out (or expired) and pending to be authorized. TODO(juan): We need to keep alive the connection here
|
2022-08-19 08:20:24 -04:00
|
|
|
if machine != nil {
|
2022-12-09 11:56:43 -05:00
|
|
|
// (juan): For a while we had a bug where we were not storing the MachineKey for the nodes using the TS2021,
|
|
|
|
// due to a misunderstanding of the protocol https://github.com/juanfont/headscale/issues/1054
|
|
|
|
// So if we have a not valid MachineKey (but we were able to fetch the machine with the NodeKeys), we update it.
|
|
|
|
var storedMachineKey key.MachinePublic
|
|
|
|
err = storedMachineKey.UnmarshalText(
|
2023-05-11 03:09:18 -04:00
|
|
|
[]byte(util.MachinePublicKeyEnsurePrefix(machine.MachineKey)),
|
2022-12-09 11:56:43 -05:00
|
|
|
)
|
|
|
|
if err != nil || storedMachineKey.IsZero() {
|
2023-05-21 12:37:59 -04:00
|
|
|
if err := h.db.MachineSetMachineKey(machine, machineKey); err != nil {
|
2022-12-09 11:56:43 -05:00
|
|
|
log.Error().
|
|
|
|
Caller().
|
|
|
|
Str("func", "RegistrationHandler").
|
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Err(err).
|
|
|
|
Msg("Error saving machine key to database")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-19 08:20:24 -04:00
|
|
|
// If the NodeKey stored in headscale is the same as the key presented in a registration
|
|
|
|
// request, then we have a node that is either:
|
|
|
|
// - Trying to log out (sending a expiry in the past)
|
2022-12-09 11:56:43 -05:00
|
|
|
// - A valid, registered machine, looking for /map
|
2022-08-19 08:20:24 -04:00
|
|
|
// - Expired machine wanting to reauthenticate
|
2023-05-11 03:09:18 -04:00
|
|
|
if machine.NodeKey == util.NodePublicKeyStripPrefix(registerRequest.NodeKey) {
|
2022-08-19 08:20:24 -04:00
|
|
|
// The client sends an Expiry in the past if the client is requesting to expire the key (aka logout)
|
|
|
|
// https://github.com/tailscale/tailscale/blob/main/tailcfg/tailcfg.go#L648
|
|
|
|
if !registerRequest.Expiry.IsZero() &&
|
|
|
|
registerRequest.Expiry.UTC().Before(now) {
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleMachineLogOut(writer, *machine, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
// If machine is not expired, and it is register, we have a already accepted this machine,
|
2022-08-19 08:20:24 -04:00
|
|
|
// let it proceed with a valid registration
|
2023-05-21 12:37:59 -04:00
|
|
|
if !machine.IsExpired() {
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleMachineWithValidRegistration(writer, *machine, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The NodeKey we have matches OldNodeKey, which means this is a refresh after a key expiration
|
2023-05-11 03:09:18 -04:00
|
|
|
if machine.NodeKey == util.NodePublicKeyStripPrefix(registerRequest.OldNodeKey) &&
|
2023-05-21 12:37:59 -04:00
|
|
|
!machine.IsExpired() {
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleMachineKeyRefresh(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer,
|
|
|
|
registerRequest,
|
|
|
|
*machine,
|
|
|
|
machineKey,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise,
|
2022-08-19 08:20:24 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-20 06:14:34 -04:00
|
|
|
if registerRequest.Followup != "" {
|
|
|
|
select {
|
|
|
|
case <-req.Context().Done():
|
|
|
|
return
|
|
|
|
case <-time.After(registrationHoldoff):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
// The machine has expired or it is logged out
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleMachineExpiredOrLoggedOut(writer, registerRequest, *machine, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
// TODO(juan): RegisterRequest includes an Expiry time, that we could optionally use
|
2022-08-20 05:46:44 -04:00
|
|
|
machine.Expiry = &time.Time{}
|
2022-12-09 11:56:43 -05:00
|
|
|
|
|
|
|
// If we are here it means the client needs to be reauthorized,
|
|
|
|
// we need to make sure the NodeKey matches the one in the request
|
|
|
|
// TODO(juan): What happens when using fast user switching between two
|
|
|
|
// headscale-managed tailnets?
|
2023-05-11 03:09:18 -04:00
|
|
|
machine.NodeKey = util.NodePublicKeyStripPrefix(registerRequest.NodeKey)
|
2022-08-20 05:46:44 -04:00
|
|
|
h.registrationCache.Set(
|
2023-05-11 03:09:18 -04:00
|
|
|
util.NodePublicKeyStripPrefix(registerRequest.NodeKey),
|
2022-08-20 05:46:44 -04:00
|
|
|
*machine,
|
|
|
|
registerCacheExpiration,
|
|
|
|
)
|
|
|
|
|
2022-08-19 08:20:24 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
// handleAuthKey contains the logic to manage auth key client registration
|
2022-08-19 08:20:24 -04:00
|
|
|
// It is used both by the legacy and the new Noise protocol.
|
|
|
|
// When using Noise, the machineKey is Zero.
|
|
|
|
//
|
|
|
|
// TODO: check if any locks are needed around IP allocation.
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleAuthKey(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
|
|
|
registerRequest tailcfg.RegisterRequest,
|
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
log.Debug().
|
2023-06-06 11:14:56 -04:00
|
|
|
Caller().
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Msgf("Processing auth key for %s", registerRequest.Hostinfo.Hostname)
|
|
|
|
resp := tailcfg.RegisterResponse{}
|
|
|
|
|
2023-05-21 12:37:59 -04:00
|
|
|
pak, err := h.db.ValidatePreAuthKey(registerRequest.Auth.AuthKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Err(err).
|
|
|
|
Msg("Failed authentication via AuthKey")
|
|
|
|
resp.MachineAuthorized = false
|
|
|
|
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "error", pak.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusUnauthorized)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Msg("Failed authentication via AuthKey")
|
|
|
|
|
|
|
|
if pak != nil {
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "error", pak.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
} else {
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "error", "unknown").Inc()
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug().
|
2023-06-06 11:14:56 -04:00
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Msg("Authentication key was valid, proceeding to acquire IP addresses")
|
|
|
|
|
2023-05-11 03:09:18 -04:00
|
|
|
nodeKey := util.NodePublicKeyStripPrefix(registerRequest.NodeKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
// retrieve machine information if it exist
|
|
|
|
// The error is not important, because if it does not
|
|
|
|
// exist, then this is a new machine and we will move
|
|
|
|
// on to registration.
|
2023-05-11 03:09:18 -04:00
|
|
|
machine, _ := h.db.GetMachineByAnyKey(machineKey, registerRequest.NodeKey, registerRequest.OldNodeKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if machine != nil {
|
|
|
|
log.Trace().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("machine was already registered before, refreshing with new auth key")
|
|
|
|
|
|
|
|
machine.NodeKey = nodeKey
|
|
|
|
machine.AuthKeyID = uint(pak.ID)
|
2023-05-11 03:09:18 -04:00
|
|
|
err := h.db.RefreshMachine(machine, registerRequest.Expiry)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Err(err).
|
|
|
|
Msg("Failed to refresh machine")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2022-08-25 06:43:15 -04:00
|
|
|
|
2023-05-21 12:37:59 -04:00
|
|
|
aclTags := pak.Proto().AclTags
|
2022-08-25 06:43:15 -04:00
|
|
|
if len(aclTags) > 0 {
|
|
|
|
// This conditional preserves the existing behaviour, although SaaS would reset the tags on auth-key login
|
2023-05-21 12:37:59 -04:00
|
|
|
err = h.db.SetTags(machine, aclTags)
|
2022-08-25 06:43:15 -04:00
|
|
|
|
2022-09-23 03:58:06 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-09-23 03:58:06 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Strs("aclTags", aclTags).
|
|
|
|
Err(err).
|
|
|
|
Msg("Failed to set tags after refreshing machine")
|
2022-08-25 06:43:15 -04:00
|
|
|
|
2022-09-23 03:58:06 -04:00
|
|
|
return
|
|
|
|
}
|
2022-08-25 06:43:15 -04:00
|
|
|
}
|
2022-08-19 08:20:24 -04:00
|
|
|
} else {
|
|
|
|
now := time.Now().UTC()
|
|
|
|
|
2023-05-11 03:09:18 -04:00
|
|
|
givenName, err := h.db.GenerateGivenName(util.MachinePublicKeyStripPrefix(machineKey), registerRequest.Hostinfo.Hostname)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("func", "RegistrationHandler").
|
|
|
|
Str("hostinfo.name", registerRequest.Hostinfo.Hostname).
|
|
|
|
Err(err)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-05-21 12:37:59 -04:00
|
|
|
machineToRegister := types.Machine{
|
2022-08-19 08:20:24 -04:00
|
|
|
Hostname: registerRequest.Hostinfo.Hostname,
|
|
|
|
GivenName: givenName,
|
2023-01-17 14:36:46 -05:00
|
|
|
UserID: pak.User.ID,
|
2023-05-11 03:09:18 -04:00
|
|
|
MachineKey: util.MachinePublicKeyStripPrefix(machineKey),
|
2023-05-21 12:37:59 -04:00
|
|
|
RegisterMethod: util.RegisterMethodAuthKey,
|
2022-08-19 08:20:24 -04:00
|
|
|
Expiry: ®isterRequest.Expiry,
|
|
|
|
NodeKey: nodeKey,
|
|
|
|
LastSeen: &now,
|
|
|
|
AuthKeyID: uint(pak.ID),
|
2023-05-21 12:37:59 -04:00
|
|
|
ForcedTags: pak.Proto().AclTags,
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|
|
|
|
|
2023-05-11 03:09:18 -04:00
|
|
|
machine, err = h.db.RegisterMachine(
|
2022-08-19 08:20:24 -04:00
|
|
|
machineToRegister,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("could not register machine")
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "error", pak.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-11 03:09:18 -04:00
|
|
|
err = h.db.UsePreAuthKey(pak)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to use pre-auth key")
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "error", pak.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp.MachineAuthorized = true
|
2023-05-21 12:37:59 -04:00
|
|
|
resp.User = *pak.User.TailscaleUser()
|
2022-10-18 05:56:00 -04:00
|
|
|
// Provide LoginName when registering with pre-auth key
|
|
|
|
// Otherwise it will need to exec `tailscale up` twice to fetch the *LoginName*
|
2023-05-21 12:37:59 -04:00
|
|
|
resp.Login = *pak.User.TailscaleLogin()
|
2022-10-18 05:56:00 -04:00
|
|
|
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "error", pak.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2023-05-21 12:37:59 -04:00
|
|
|
machineRegistrations.WithLabelValues("new", util.RegisterMethodAuthKey, "success", pak.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusOK)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
2023-05-31 03:59:37 -04:00
|
|
|
Str("ips", strings.Join(machine.IPAddresses.StringSlice(), ", ")).
|
2022-08-19 08:20:24 -04:00
|
|
|
Msg("Successfully authenticated via AuthKey")
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
// handleNewMachine exposes for both legacy and Noise the functionality to get a URL
|
2022-08-19 08:20:24 -04:00
|
|
|
// for authorizing the machine. This url is then showed to the user by the local Tailscale client.
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleNewMachine(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
|
|
|
registerRequest tailcfg.RegisterRequest,
|
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
resp := tailcfg.RegisterResponse{}
|
|
|
|
|
|
|
|
// The machine registration is new, redirect the client to the registration URL
|
|
|
|
log.Debug().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Msg("The node seems to be new, sending auth url")
|
2022-11-15 09:08:49 -05:00
|
|
|
|
2022-09-26 03:51:23 -04:00
|
|
|
if h.oauth2Config != nil {
|
2022-08-19 08:20:24 -04:00
|
|
|
resp.AuthURL = fmt.Sprintf(
|
|
|
|
"%s/oidc/register/%s",
|
|
|
|
strings.TrimSuffix(h.cfg.ServerURL, "/"),
|
2022-11-05 04:07:22 -04:00
|
|
|
registerRequest.NodeKey,
|
2022-08-19 08:20:24 -04:00
|
|
|
)
|
|
|
|
} else {
|
|
|
|
resp.AuthURL = fmt.Sprintf("%s/register/%s",
|
|
|
|
strings.TrimSuffix(h.cfg.ServerURL, "/"),
|
2022-11-05 04:07:22 -04:00
|
|
|
registerRequest.NodeKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|
|
|
|
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusOK)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Caller().
|
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-11-14 14:38:32 -05:00
|
|
|
Str("AuthURL", resp.AuthURL).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", registerRequest.Hostinfo.Hostname).
|
|
|
|
Msg("Successfully sent auth url")
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleMachineLogOut(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
2023-05-21 12:37:59 -04:00
|
|
|
machine types.Machine,
|
2022-08-19 08:20:24 -04:00
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
resp := tailcfg.RegisterResponse{}
|
|
|
|
|
|
|
|
log.Info().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("Client requested logout")
|
|
|
|
|
2023-05-11 03:09:18 -04:00
|
|
|
err := h.db.ExpireMachine(&machine)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to expire machine")
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp.AuthURL = ""
|
|
|
|
resp.MachineAuthorized = false
|
2022-12-09 11:56:43 -05:00
|
|
|
resp.NodeKeyExpired = true
|
2023-05-21 12:37:59 -04:00
|
|
|
resp.User = *machine.User.TailscaleUser()
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusOK)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Caller().
|
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
2022-12-27 06:33:51 -05:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-05-21 12:37:59 -04:00
|
|
|
if machine.IsEphemeral() {
|
2023-05-11 03:09:18 -04:00
|
|
|
err = h.db.HardDeleteMachine(&machine)
|
2022-12-27 06:33:51 -05:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Err(err).
|
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("Cannot delete ephemeral machine from the database")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
log.Info().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("Successfully logged out")
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleMachineWithValidRegistration(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
2023-05-21 12:37:59 -04:00
|
|
|
machine types.Machine,
|
2022-08-19 08:20:24 -04:00
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
resp := tailcfg.RegisterResponse{}
|
|
|
|
|
|
|
|
// The machine registration is valid, respond with redirect to /map
|
|
|
|
log.Debug().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("Client is registered and we have the current NodeKey. All clear to /map")
|
|
|
|
|
|
|
|
resp.AuthURL = ""
|
|
|
|
resp.MachineAuthorized = true
|
2023-05-21 12:37:59 -04:00
|
|
|
resp.User = *machine.User.TailscaleUser()
|
|
|
|
resp.Login = *machine.User.TailscaleLogin()
|
2022-08-19 08:20:24 -04:00
|
|
|
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
2023-01-17 11:43:44 -05:00
|
|
|
machineRegistrations.WithLabelValues("update", "web", "error", machine.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2023-01-17 11:43:44 -05:00
|
|
|
machineRegistrations.WithLabelValues("update", "web", "success", machine.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusOK)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("Machine successfully authorized")
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleMachineKeyRefresh(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
|
|
|
registerRequest tailcfg.RegisterRequest,
|
2023-05-21 12:37:59 -04:00
|
|
|
machine types.Machine,
|
2022-08-19 08:20:24 -04:00
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
resp := tailcfg.RegisterResponse{}
|
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
log.Info().
|
2022-08-19 08:20:24 -04:00
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Msg("We have the OldNodeKey in the database. This is a key refresh")
|
|
|
|
|
2023-05-21 12:37:59 -04:00
|
|
|
err := h.db.MachineSetNodeKey(&machine, registerRequest.NodeKey)
|
|
|
|
if err != nil {
|
2022-08-19 08:20:24 -04:00
|
|
|
log.Error().
|
|
|
|
Caller().
|
|
|
|
Err(err).
|
|
|
|
Msg("Failed to update machine key in the database")
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp.AuthURL = ""
|
2023-05-21 12:37:59 -04:00
|
|
|
resp.User = *machine.User.TailscaleUser()
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusOK)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("node_key", registerRequest.NodeKey.ShortString()).
|
|
|
|
Str("old_node_key", registerRequest.OldNodeKey.ShortString()).
|
|
|
|
Str("machine", machine.Hostname).
|
2022-12-09 11:56:43 -05:00
|
|
|
Msg("Node key successfully refreshed")
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|
|
|
|
|
2023-06-06 11:14:56 -04:00
|
|
|
func (h *Headscale) handleMachineExpiredOrLoggedOut(
|
2022-08-19 08:20:24 -04:00
|
|
|
writer http.ResponseWriter,
|
|
|
|
registerRequest tailcfg.RegisterRequest,
|
2023-05-21 12:37:59 -04:00
|
|
|
machine types.Machine,
|
2022-08-19 08:20:24 -04:00
|
|
|
machineKey key.MachinePublic,
|
2022-12-09 11:56:43 -05:00
|
|
|
isNoise bool,
|
2022-08-19 08:20:24 -04:00
|
|
|
) {
|
|
|
|
resp := tailcfg.RegisterResponse{}
|
|
|
|
|
|
|
|
if registerRequest.Auth.AuthKey != "" {
|
2023-06-06 11:14:56 -04:00
|
|
|
h.handleAuthKey(writer, registerRequest, machineKey, isNoise)
|
2022-08-19 08:20:24 -04:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
// The client has registered before, but has expired or logged out
|
|
|
|
log.Trace().
|
|
|
|
Caller().
|
|
|
|
Bool("noise", isNoise).
|
|
|
|
Str("machine", machine.Hostname).
|
|
|
|
Str("machine_key", machineKey.ShortString()).
|
|
|
|
Str("node_key", registerRequest.NodeKey.ShortString()).
|
|
|
|
Str("node_key_old", registerRequest.OldNodeKey.ShortString()).
|
|
|
|
Msg("Machine registration has expired or logged out. Sending a auth url to register")
|
|
|
|
|
2022-09-26 03:51:23 -04:00
|
|
|
if h.oauth2Config != nil {
|
2022-08-19 08:20:24 -04:00
|
|
|
resp.AuthURL = fmt.Sprintf("%s/oidc/register/%s",
|
|
|
|
strings.TrimSuffix(h.cfg.ServerURL, "/"),
|
2022-11-15 09:08:49 -05:00
|
|
|
registerRequest.NodeKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
} else {
|
|
|
|
resp.AuthURL = fmt.Sprintf("%s/register/%s",
|
|
|
|
strings.TrimSuffix(h.cfg.ServerURL, "/"),
|
2022-11-05 04:07:22 -04:00
|
|
|
registerRequest.NodeKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|
|
|
|
|
2023-05-31 11:26:19 -04:00
|
|
|
respBody, err := mapper.MarshalResponse(resp, isNoise, h.privateKey2019, machineKey)
|
2022-08-19 08:20:24 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Cannot encode message")
|
2023-01-17 11:43:44 -05:00
|
|
|
machineRegistrations.WithLabelValues("reauth", "web", "error", machine.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
http.Error(writer, "Internal server error", http.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2023-01-17 11:43:44 -05:00
|
|
|
machineRegistrations.WithLabelValues("reauth", "web", "success", machine.User.Name).
|
2022-08-19 08:20:24 -04:00
|
|
|
Inc()
|
|
|
|
|
|
|
|
writer.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
writer.WriteHeader(http.StatusOK)
|
|
|
|
_, err = writer.Write(respBody)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().
|
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
2022-08-19 08:20:24 -04:00
|
|
|
Err(err).
|
|
|
|
Msg("Failed to write response")
|
|
|
|
}
|
|
|
|
|
2022-12-09 11:56:43 -05:00
|
|
|
log.Trace().
|
2022-08-19 08:20:24 -04:00
|
|
|
Caller().
|
2022-12-09 11:56:43 -05:00
|
|
|
Bool("noise", isNoise).
|
|
|
|
Str("machine_key", machineKey.ShortString()).
|
|
|
|
Str("node_key", registerRequest.NodeKey.ShortString()).
|
|
|
|
Str("node_key_old", registerRequest.OldNodeKey.ShortString()).
|
2022-08-19 08:20:24 -04:00
|
|
|
Str("machine", machine.Hostname).
|
2022-12-09 11:56:43 -05:00
|
|
|
Msg("Machine logged out. Sent AuthURL for reauthentication")
|
2022-08-19 08:20:24 -04:00
|
|
|
}
|