mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-04 12:39:25 +09:00
state: give another user's key on a tagged machine a new device
Only a key that speaks for a tagged node re-authenticates it: a tagged key, or one of the user it was tagged from. Another user's key or login adds that user's own device, or only wakes the node under its node key. Fixes ANT-2026-AWGRB7O1
This commit is contained in:
1 parent
e67ef8619a
commit
e1de83cbdf
9 files changed
+455
-144
No files matched your search
@@ -963,6 +963,20 @@ func (nv NodeView) IsTagged() bool {
|
||||
return nv.ж.IsTagged()
|
||||
}
|
||||
|
||||
// ClaimableBy reports whether a login by userID takes this tagged node back
|
||||
// as that user's device, rather than adding a device beside it: userID owns
|
||||
// or created the key it joined with. Tagging clears a node's user, so a node
|
||||
// that joined by login records no former owner and nobody claims it.
|
||||
func (nv NodeView) ClaimableBy(userID UserID) bool {
|
||||
if !nv.IsTagged() || nv.RegisterMethod() != util.RegisterMethodAuthKey {
|
||||
return false
|
||||
}
|
||||
|
||||
k := nv.AuthKey()
|
||||
|
||||
return k.Valid() && k.UserID().Valid() && UserID(k.UserID().Get()) == userID
|
||||
}
|
||||
|
||||
// IsExpired returns whether the node registration has expired.
|
||||
func (nv NodeView) IsExpired() bool {
|
||||
if !nv.Valid() {
|
||||
|
||||
Reference in new issue
Block a user