Skip to content

Commit

Permalink
tailcfg: add UserProfile.Groups
Browse files Browse the repository at this point in the history
Updates tailscale/corp#13375

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Signed-off-by: Alex Paguis <alex@windscribe.com>
  • Loading branch information
bradfitz authored and alexelisenko committed Feb 15, 2024
1 parent d898b87 commit 9bc3a03
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 12 deletions.
26 changes: 24 additions & 2 deletions tailcfg/tailcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package tailcfg

//go:generate go run tailscale.com/cmd/viewer --type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location --clonefunc
//go:generate go run tailscale.com/cmd/viewer --type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile --clonefunc

import (
"bytes"
Expand Down Expand Up @@ -102,7 +102,8 @@ type CapabilityVersion int
// - 63: 2023-06-08: Client understands SSHAction.AllowRemotePortForwarding.
// - 64: 2023-07-11: Client understands s/CapabilityTailnetLockAlpha/CapabilityTailnetLock
// - 65: 2023-07-12: Client understands DERPMap.HomeParams + incremental DERPMap updates with params
const CurrentCapabilityVersion CapabilityVersion = 65
// - 66: 2023-07-23: UserProfile.Groups added (available via WhoIs)
const CurrentCapabilityVersion CapabilityVersion = 66

type StableID string

Expand Down Expand Up @@ -175,6 +176,27 @@ type UserProfile struct {
// Roles exists for legacy reasons, to keep old macOS clients
// happy. It JSON marshals as [].
Roles emptyStructJSONSlice

// Groups contains group identifiers for any group that this user is
// a part of and that the coordination server is configured to tell
// your node about. (Thus, it may be empty or incomplete.)
// There's no semantic difference between a nil and an empty list.
// The list is always sorted.
Groups []string `json:",omitempty"`
}

func (p *UserProfile) Equal(p2 *UserProfile) bool {
if p == nil && p2 == nil {
return true
}
if p == nil || p2 == nil {
return false
}
return p.ID == p2.ID &&
p.LoginName == p2.LoginName &&
p.DisplayName == p2.DisplayName &&
p.ProfilePicURL == p2.ProfilePicURL &&
(len(p.Groups) == 0 && len(p2.Groups) == 0 || reflect.DeepEqual(p.Groups, p2.Groups))
}

type emptyStructJSONSlice struct{}
Expand Down
33 changes: 32 additions & 1 deletion tailcfg/tailcfg_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 64 additions & 1 deletion tailcfg/tailcfg_view.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/persist/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (p *Persist) Equals(p2 *Persist) bool {
p.OldPrivateNodeKey.Equal(p2.OldPrivateNodeKey) &&
p.Provider == p2.Provider &&
p.LoginName == p2.LoginName &&
p.UserProfile == p2.UserProfile &&
p.UserProfile.Equal(&p2.UserProfile) &&
p.NetworkLockKey.Equal(p2.NetworkLockKey) &&
p.NodeID == p2.NodeID &&
reflect.DeepEqual(nilIfEmpty(p.DisallowedTKAStateIDs), nilIfEmpty(p2.DisallowedTKAStateIDs))
Expand Down
1 change: 1 addition & 0 deletions types/persist/persist_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions types/persist/persist_view.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9bc3a03

Please sign in to comment.