Skip to content

Commit f1cc8ab

Browse files
committed
tailcfg: add UserProfile.Groups
Updates tailscale/corp#13375 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 2a6c237 commit f1cc8ab

File tree

6 files changed

+129
-12
lines changed

6 files changed

+129
-12
lines changed

tailcfg/tailcfg.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
package tailcfg
55

6-
//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
6+
//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
77

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

107108
type StableID string
108109

@@ -175,6 +176,27 @@ type UserProfile struct {
175176
// Roles exists for legacy reasons, to keep old macOS clients
176177
// happy. It JSON marshals as [].
177178
Roles emptyStructJSONSlice
179+
180+
// Groups contains group identifiers for any group that this user is
181+
// a part of and that the coordination server is configured to tell
182+
// your node about. (Thus, it may be empty or incomplete.)
183+
// There's no semantic difference between a nil and an empty list.
184+
// The list is always sorted.
185+
Groups []string `json:",omitempty"`
186+
}
187+
188+
func (p *UserProfile) Equal(p2 *UserProfile) bool {
189+
if p == nil && p2 == nil {
190+
return true
191+
}
192+
if p == nil || p2 == nil {
193+
return false
194+
}
195+
return p.ID == p2.ID &&
196+
p.LoginName == p2.LoginName &&
197+
p.DisplayName == p2.DisplayName &&
198+
p.ProfilePicURL == p2.ProfilePicURL &&
199+
(len(p.Groups) == 0 && len(p2.Groups) == 0 || reflect.DeepEqual(p.Groups, p2.Groups))
178200
}
179201

180202
type emptyStructJSONSlice struct{}

tailcfg/tailcfg_clone.go

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tailcfg/tailcfg_view.go

Lines changed: 64 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/persist/persist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (p *Persist) Equals(p2 *Persist) bool {
8181
p.OldPrivateNodeKey.Equal(p2.OldPrivateNodeKey) &&
8282
p.Provider == p2.Provider &&
8383
p.LoginName == p2.LoginName &&
84-
p.UserProfile == p2.UserProfile &&
84+
p.UserProfile.Equal(&p2.UserProfile) &&
8585
p.NetworkLockKey.Equal(p2.NetworkLockKey) &&
8686
p.NodeID == p2.NodeID &&
8787
reflect.DeepEqual(nilIfEmpty(p.DisallowedTKAStateIDs), nilIfEmpty(p2.DisallowedTKAStateIDs))

types/persist/persist_clone.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/persist/persist_view.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)