From 0710e1aa4ca9fdca681c3882e4808f8445981261 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 17 Nov 2024 19:49:51 -0700 Subject: [PATCH] nits Signed-off-by: Kristoffer Dalby --- hscontrol/db/routes.go | 2 +- hscontrol/types/preauth_key.go | 2 +- hscontrol/types/users.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hscontrol/db/routes.go b/hscontrol/db/routes.go index 086261aa..d8fe7b3f 100644 --- a/hscontrol/db/routes.go +++ b/hscontrol/db/routes.go @@ -639,7 +639,7 @@ func EnableAutoApprovedRoutes( log.Trace(). Str("node", node.Hostname). - Str("user", node.User.Name). + Uint("user.id", node.User.ID). Strs("routeApprovers", routeApprovers). Str("prefix", netip.Prefix(advertisedRoute.Prefix).String()). Msg("looking up route for autoapproving") diff --git a/hscontrol/types/preauth_key.go b/hscontrol/types/preauth_key.go index ba3b597b..0174c9e8 100644 --- a/hscontrol/types/preauth_key.go +++ b/hscontrol/types/preauth_key.go @@ -26,7 +26,7 @@ type PreAuthKey struct { func (key *PreAuthKey) Proto() *v1.PreAuthKey { protoKey := v1.PreAuthKey{ - User: key.User.Name, + User: key.User.Username(), Id: strconv.FormatUint(key.ID, util.Base10), Key: key.Key, Ephemeral: key.Ephemeral, diff --git a/hscontrol/types/users.go b/hscontrol/types/users.go index 9e0bfeb0..8b3d2e83 100644 --- a/hscontrol/types/users.go +++ b/hscontrol/types/users.go @@ -21,7 +21,7 @@ type User struct { gorm.Model // The index `idx_name_provider_identifier` is to enforce uniqueness // between Name and ProviderIdentifier. This ensures that - // you can have multiple usersnames of the same name in OIDC, + // you can have multiple users with the same name in OIDC, // but not if you only run with CLI users. // Username for the user, is used if email is empty @@ -54,9 +54,9 @@ type User struct { // enabled with OIDC, which means that there is a domain involved which // should be used throughout headscale, in information returned to the // user and the Policy engine. -// If the username does not contain an '@' it will be added to the end. func (u *User) Username() string { username := cmp.Or(u.Email, u.Name, u.ProviderIdentifier, strconv.FormatUint(uint64(u.ID), 10)) + // TODO(kradalby): Wire up all of this for the future // if !strings.Contains(username, "@") { // username = username + "@"