mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-29 20:42:22 +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>
191 lines
5.1 KiB
Go
191 lines
5.1 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Code generated by tailscale.com/cmd/cloner; DO NOT EDIT.
|
|
|
|
package ipn
|
|
|
|
import (
|
|
"maps"
|
|
"net/netip"
|
|
|
|
"tailscale.com/drive"
|
|
"tailscale.com/tailcfg"
|
|
"tailscale.com/types/persist"
|
|
"tailscale.com/types/preftype"
|
|
)
|
|
|
|
// Clone makes a deep copy of LoginProfile.
|
|
// The result aliases no memory with the original.
|
|
func (src *LoginProfile) Clone() *LoginProfile {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(LoginProfile)
|
|
*dst = *src
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _LoginProfileCloneNeedsRegeneration = LoginProfile(struct {
|
|
ID ProfileID
|
|
Name string
|
|
NetworkProfile NetworkProfile
|
|
Key StateKey
|
|
UserProfile tailcfg.UserProfile
|
|
NodeID tailcfg.StableNodeID
|
|
LocalUserID WindowsUserID
|
|
ControlURL string
|
|
}{})
|
|
|
|
// Clone makes a deep copy of Prefs.
|
|
// The result aliases no memory with the original.
|
|
func (src *Prefs) Clone() *Prefs {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(Prefs)
|
|
*dst = *src
|
|
dst.AdvertiseTags = append(src.AdvertiseTags[:0:0], src.AdvertiseTags...)
|
|
dst.AdvertiseRoutes = append(src.AdvertiseRoutes[:0:0], src.AdvertiseRoutes...)
|
|
if src.DriveShares != nil {
|
|
dst.DriveShares = make([]*drive.Share, len(src.DriveShares))
|
|
for i := range dst.DriveShares {
|
|
dst.DriveShares[i] = src.DriveShares[i].Clone()
|
|
}
|
|
}
|
|
dst.Persist = src.Persist.Clone()
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _PrefsCloneNeedsRegeneration = Prefs(struct {
|
|
ControlURL string
|
|
RouteAll bool
|
|
AllowSingleHosts bool
|
|
ExitNodeID tailcfg.StableNodeID
|
|
ExitNodeIP netip.Addr
|
|
InternalExitNodePrior tailcfg.StableNodeID
|
|
ExitNodeAllowLANAccess bool
|
|
CorpDNS bool
|
|
RunSSH bool
|
|
RunWebClient bool
|
|
WantRunning bool
|
|
LoggedOut bool
|
|
ShieldsUp bool
|
|
AdvertiseTags []string
|
|
Hostname string
|
|
NotepadURLs bool
|
|
ForceDaemon bool
|
|
Egg bool
|
|
AdvertiseRoutes []netip.Prefix
|
|
NoSNAT bool
|
|
NetfilterMode preftype.NetfilterMode
|
|
OperatorUser string
|
|
ProfileName string
|
|
AutoUpdate AutoUpdatePrefs
|
|
AppConnector AppConnectorPrefs
|
|
PostureChecking bool
|
|
NetfilterKind string
|
|
DriveShares []*drive.Share
|
|
Persist *persist.Persist
|
|
}{})
|
|
|
|
// Clone makes a deep copy of ServeConfig.
|
|
// The result aliases no memory with the original.
|
|
func (src *ServeConfig) Clone() *ServeConfig {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(ServeConfig)
|
|
*dst = *src
|
|
if dst.TCP != nil {
|
|
dst.TCP = map[uint16]*TCPPortHandler{}
|
|
for k, v := range src.TCP {
|
|
dst.TCP[k] = v.Clone()
|
|
}
|
|
}
|
|
if dst.Web != nil {
|
|
dst.Web = map[HostPort]*WebServerConfig{}
|
|
for k, v := range src.Web {
|
|
dst.Web[k] = v.Clone()
|
|
}
|
|
}
|
|
dst.AllowFunnel = maps.Clone(src.AllowFunnel)
|
|
if dst.Foreground != nil {
|
|
dst.Foreground = map[string]*ServeConfig{}
|
|
for k, v := range src.Foreground {
|
|
dst.Foreground[k] = v.Clone()
|
|
}
|
|
}
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _ServeConfigCloneNeedsRegeneration = ServeConfig(struct {
|
|
TCP map[uint16]*TCPPortHandler
|
|
Web map[HostPort]*WebServerConfig
|
|
AllowFunnel map[HostPort]bool
|
|
Foreground map[string]*ServeConfig
|
|
ETag string
|
|
}{})
|
|
|
|
// Clone makes a deep copy of TCPPortHandler.
|
|
// The result aliases no memory with the original.
|
|
func (src *TCPPortHandler) Clone() *TCPPortHandler {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(TCPPortHandler)
|
|
*dst = *src
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _TCPPortHandlerCloneNeedsRegeneration = TCPPortHandler(struct {
|
|
HTTPS bool
|
|
HTTP bool
|
|
TCPForward string
|
|
TerminateTLS string
|
|
}{})
|
|
|
|
// Clone makes a deep copy of HTTPHandler.
|
|
// The result aliases no memory with the original.
|
|
func (src *HTTPHandler) Clone() *HTTPHandler {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(HTTPHandler)
|
|
*dst = *src
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _HTTPHandlerCloneNeedsRegeneration = HTTPHandler(struct {
|
|
Path string
|
|
Proxy string
|
|
Text string
|
|
}{})
|
|
|
|
// Clone makes a deep copy of WebServerConfig.
|
|
// The result aliases no memory with the original.
|
|
func (src *WebServerConfig) Clone() *WebServerConfig {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(WebServerConfig)
|
|
*dst = *src
|
|
if dst.Handlers != nil {
|
|
dst.Handlers = map[string]*HTTPHandler{}
|
|
for k, v := range src.Handlers {
|
|
dst.Handlers[k] = v.Clone()
|
|
}
|
|
}
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _WebServerConfigCloneNeedsRegeneration = WebServerConfig(struct {
|
|
Handlers map[string]*HTTPHandler
|
|
}{})
|