types/authkey: include user object in response (#2542)
* types/authkey: include user object, not string Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * make preauthkeys use id Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * changelog Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * integration: wire up user id for auth keys Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> --------- Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
f1206328dc
commit
8f9fbf16f1
23 changed files with 454 additions and 779 deletions
|
@ -652,7 +652,7 @@ AND auth_key_id NOT IN (
|
|||
|
||||
for nodeID, routes := range nodeRoutes {
|
||||
tsaddr.SortPrefixes(routes)
|
||||
slices.Compact(routes)
|
||||
routes = slices.Compact(routes)
|
||||
|
||||
data, err := json.Marshal(routes)
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ func (api headscaleV1APIServer) CreatePreAuthKey(
|
|||
}
|
||||
}
|
||||
|
||||
user, err := api.h.db.GetUserByName(request.GetUser())
|
||||
user, err := api.h.db.GetUserByID(types.UserID(request.GetUser()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func (api headscaleV1APIServer) ExpirePreAuthKey(
|
|||
return err
|
||||
}
|
||||
|
||||
if preAuthKey.User.Name != request.GetUser() {
|
||||
if uint64(preAuthKey.User.ID) != request.GetUser() {
|
||||
return fmt.Errorf("preauth key does not belong to user")
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ func (api headscaleV1APIServer) ListPreAuthKeys(
|
|||
ctx context.Context,
|
||||
request *v1.ListPreAuthKeysRequest,
|
||||
) (*v1.ListPreAuthKeysResponse, error) {
|
||||
user, err := api.h.db.GetUserByName(request.GetUser())
|
||||
user, err := api.h.db.GetUserByID(types.UserID(request.GetUser()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ func generateUserProfiles(
|
|||
}
|
||||
|
||||
slices.Sort(ids)
|
||||
slices.Compact(ids)
|
||||
ids = slices.Compact(ids)
|
||||
var profiles []tailcfg.UserProfile
|
||||
for _, id := range ids {
|
||||
if userMap[id] != nil {
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/juanfont/headscale/hscontrol/util"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
|
@ -31,8 +29,8 @@ type PreAuthKey struct {
|
|||
|
||||
func (key *PreAuthKey) Proto() *v1.PreAuthKey {
|
||||
protoKey := v1.PreAuthKey{
|
||||
User: key.User.Username(),
|
||||
Id: strconv.FormatUint(key.ID, util.Base10),
|
||||
User: key.User.Proto(),
|
||||
Id: key.ID,
|
||||
Key: key.Key,
|
||||
Ephemeral: key.Ephemeral,
|
||||
Reusable: key.Reusable,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue