2025-01-29 15:49:31 -06:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
package ipnauth
|
|
|
|
|
|
|
|
import (
|
2025-02-07 10:47:14 -06:00
|
|
|
"context"
|
|
|
|
|
2025-01-29 15:49:31 -06:00
|
|
|
"tailscale.com/ipn"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Self is a caller identity that represents the tailscaled itself and therefore
|
|
|
|
// has unlimited access.
|
|
|
|
var Self Actor = unrestricted{}
|
|
|
|
|
|
|
|
// unrestricted is an [Actor] that has unlimited access to the currently running
|
|
|
|
// tailscaled instance. It's typically used for operations performed by tailscaled
|
|
|
|
// on its own, or upon a request from the control plane, rather on behalf of a user.
|
|
|
|
type unrestricted struct{}
|
|
|
|
|
|
|
|
// UserID implements [Actor].
|
2025-02-07 10:47:14 -06:00
|
|
|
func (unrestricted) UserID() ipn.WindowsUserID { return "" }
|
2025-01-29 15:49:31 -06:00
|
|
|
|
|
|
|
// Username implements [Actor].
|
2025-02-07 10:47:14 -06:00
|
|
|
func (unrestricted) Username() (string, error) { return "", nil }
|
|
|
|
|
|
|
|
// Context implements [Actor].
|
|
|
|
func (unrestricted) Context() context.Context { return context.Background() }
|
2025-01-29 15:49:31 -06:00
|
|
|
|
|
|
|
// ClientID implements [Actor].
|
|
|
|
// It always returns (NoClientID, false) because the tailscaled itself
|
|
|
|
// is not a connected LocalAPI client.
|
2025-02-07 10:47:14 -06:00
|
|
|
func (unrestricted) ClientID() (_ ClientID, ok bool) { return NoClientID, false }
|
2025-01-29 15:49:31 -06:00
|
|
|
|
|
|
|
// CheckProfileAccess implements [Actor].
|
2025-02-07 10:47:14 -06:00
|
|
|
func (unrestricted) CheckProfileAccess(_ ipn.LoginProfileView, _ ProfileAccess, _ AuditLogFunc) error {
|
2025-01-29 15:49:31 -06:00
|
|
|
// Unrestricted access to all profiles.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsLocalSystem implements [Actor].
|
|
|
|
//
|
|
|
|
// Deprecated: this method exists for compatibility with the current (as of 2025-01-28)
|
|
|
|
// permission model and will be removed as we progress on tailscale/corp#18342.
|
2025-02-07 10:47:14 -06:00
|
|
|
func (unrestricted) IsLocalSystem() bool { return false }
|
2025-01-29 15:49:31 -06:00
|
|
|
|
|
|
|
// IsLocalAdmin implements [Actor].
|
|
|
|
//
|
|
|
|
// Deprecated: this method exists for compatibility with the current (as of 2025-01-28)
|
|
|
|
// permission model and will be removed as we progress on tailscale/corp#18342.
|
2025-02-07 10:47:14 -06:00
|
|
|
func (unrestricted) IsLocalAdmin(operatorUID string) bool { return false }
|