ipn/ipnauth: implement WindowsActor

WindowsActor is an ipnauth.Actor implementation that represents a logged-in
Windows user by wrapping their Windows user token.

Updates #14823

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl
2025-02-07 14:01:52 -06:00
committed by Nick Khyl
parent e9e2bc5bd7
commit 5eacf61844
2 changed files with 109 additions and 3 deletions
+7 -3
View File
@@ -36,6 +36,12 @@ type token struct {
t windows.Token
}
func newToken(t windows.Token) *token {
tok := &token{t: t}
runtime.SetFinalizer(tok, func(t *token) { t.Close() })
return tok
}
func (t *token) UID() (ipn.WindowsUserID, error) {
sid, err := t.uid()
if err != nil {
@@ -184,7 +190,5 @@ func (ci *ConnIdentity) WindowsToken() (WindowsToken, error) {
return nil, err
}
result := &token{t: windows.Token(h)}
runtime.SetFinalizer(result, func(t *token) { t.Close() })
return result, nil
return newToken(windows.Token(h)), nil
}