diff --git a/api.go b/api.go index 3d85d1e..b4e3a7d 100644 --- a/api.go +++ b/api.go @@ -134,11 +134,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) { return } - // TODO(kradalby): We need these fields to be unique, we need to add a hash or something at the end. - normalizedHostname, err := NormalizeToFQDNRules( - req.Hostinfo.Hostname, - h.cfg.OIDC.StripEmaildomain, - ) + givenName, err := h.GenerateGivenName(req.Hostinfo.Hostname) if err != nil { log.Error(). Caller(). @@ -156,7 +152,7 @@ func (h *Headscale) RegistrationHandler(ctx *gin.Context) { newMachine := Machine{ MachineKey: machineKeyStr, Hostname: req.Hostinfo.Hostname, - GivenName: normalizedHostname, + GivenName: givenName, NodeKey: NodePublicKeyStripPrefix(req.NodeKey), LastSeen: &now, Expiry: &time.Time{}, diff --git a/grpcv1.go b/grpcv1.go index 36c9ad1..9c59389 100644 --- a/grpcv1.go +++ b/grpcv1.go @@ -394,9 +394,15 @@ func (api headscaleV1APIServer) DebugCreateMachine( Hostname: "DebugTestMachine", } + givenName, err := api.h.GenerateGivenName(request.GetName()) + if err != nil { + return nil, err + } + newMachine := Machine{ MachineKey: request.GetKey(), Hostname: request.GetName(), + GivenName: givenName, Namespace: *namespace, Expiry: &time.Time{},