mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-26 02:30:57 +00:00

We have a lot of access checks spread around the ipnserver, ipnlocal, localapi, and ipnauth packages, with a significant number of platform-specific checks that are used exclusively on either Windows or Unix-like platforms. Additionally, with the exception of a few Windows-specific checks, most of these checks are per-device rather than per-profile, which is not always correct even on single-user/single-session environments, but even more problematic on multi-user/multi-session environments such as Windows. We initially attempted to map all possible operations onto the permitRead/permitWrite access flags. However, these flags are not utilized on Windows and prove insufficient on Unix machines. Specifically, on Windows, the first user to connect is granted full access, while subsequent logged-in users have no access to the LocalAPI at all. This restriction applies regardless of the environment, local user roles (e.g., whether a Windows user is a local admin), or whether they are the active user on a shared Windows client device. Conversely, on Unix, we introduced the permitCert flag to enable granting non-root web servers (such as www-data, caddy, nginx, etc.) access to certificates. We also added additional access check to distinguish local admins (root on Unix-like platforms, elevated admins on Windows) from users with permitWrite access, and used it as a fix for the serve path LPE. A more fine-grained access control system could better suit our current and future needs, especially in improving the UX across various scenarios on corporate and personal Windows devices. This adds an API surface in ipnauth that will be used in LocalBackend to check access to individual Tailscale profiles as well as any device-wide information and operations. Updates tailscale/corp#18342 Signed-off-by: Nick Khyl <nickk@tailscale.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package ipnauth
|
|
|
|
import "tailscale.com/ipn"
|
|
|
|
// Self is a caller identity that represents the tailscaled itself and therefore has unlimited access.
|
|
//
|
|
// 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 specific user.
|
|
var Self Identity = unrestricted{}
|
|
|
|
// IsUnrestricted reports whether the specified identity has unrestricted access to the LocalBackend,
|
|
// including all user profiles and preferences, serving as a performance optimization
|
|
// and ensuring that tailscaled operates correctly, unaffected by Group Policy, MDM, or similar restrictions.
|
|
func IsUnrestricted(identity Identity) bool {
|
|
if _, ok := identity.(unrestricted); ok {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
type unrestricted struct {
|
|
}
|
|
|
|
// UserID returns an empty string.
|
|
func (unrestricted) UserID() ipn.WindowsUserID {
|
|
return ""
|
|
}
|
|
|
|
// Username returns an empty string.
|
|
func (unrestricted) Username() (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
// CheckAccess always allows the requested access.
|
|
func (unrestricted) CheckAccess(desired DeviceAccess) AccessCheckResult {
|
|
return AllowAccess()
|
|
}
|
|
|
|
// CheckProfileAccess always allows the requested profile access.
|
|
func (unrestricted) CheckProfileAccess(profile ipn.LoginProfileView, prefs ipn.PrefsGetter, requested ProfileAccess) AccessCheckResult {
|
|
return AllowAccess()
|
|
}
|