mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
feat(api): add normalisation at machine register step
This commit is contained in:
parent
1114449601
commit
6cc8bbc24f
1 changed files with 13 additions and 1 deletions
14
api.go
14
api.go
|
@ -134,6 +134,18 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
hname, err := NormalizeName(
|
||||||
|
req.Hostinfo.Hostname,
|
||||||
|
h.cfg.OIDC.StripEmaildomain,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().
|
||||||
|
Caller().
|
||||||
|
Str("func", "RegistrationHandler").
|
||||||
|
Str("hostinfo.name", req.Hostinfo.Hostname).
|
||||||
|
Err(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// The machine did not have a key to authenticate, which means
|
// 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)
|
// that we rely on a method that calls back some how (OpenID or CLI)
|
||||||
|
@ -141,7 +153,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) {
|
||||||
// happens
|
// happens
|
||||||
newMachine := Machine{
|
newMachine := Machine{
|
||||||
MachineKey: machineKeyStr,
|
MachineKey: machineKeyStr,
|
||||||
Name: req.Hostinfo.Hostname,
|
Name: hname,
|
||||||
NodeKey: NodePublicKeyStripPrefix(req.NodeKey),
|
NodeKey: NodePublicKeyStripPrefix(req.NodeKey),
|
||||||
LastSeen: &now,
|
LastSeen: &now,
|
||||||
Expiry: &time.Time{},
|
Expiry: &time.Time{},
|
||||||
|
|
Loading…
Reference in a new issue