mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-04 12:39:25 +09:00
api/v2: show a tagged device's creator as its user
A tagged device shows the login that made the key it joined with. Its owner stays its tags.
This commit is contained in:
1 parent
7210c01b60
commit
8ea774564d
7 files changed
+88
-27
No files matched your search
@@ -482,10 +482,18 @@ func routesFromView(view types.NodeView) DeviceRoutes {
|
||||
}
|
||||
}
|
||||
|
||||
// deviceUser is the owning login. [types.NodeView.Owner] already resolves the
|
||||
// tags-as-identity rule: tagged nodes present the special TaggedDevices user,
|
||||
// user-owned nodes present their login, orphaned nodes present nothing.
|
||||
// deviceUser is the owning login. A tagged device, owned by its tags, shows
|
||||
// the login that made the key it joined with, as Tailscale does: nothing when
|
||||
// a token made that key.
|
||||
func deviceUser(view types.NodeView) string {
|
||||
if view.IsTagged() {
|
||||
if key := view.AuthKey(); key.Valid() && key.User().Valid() {
|
||||
return key.User().Username()
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
owner := view.Owner()
|
||||
if owner.Valid() {
|
||||
return owner.Username()
|
||||
|
||||
Reference in new issue
Block a user