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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user