You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/ipn
Nick Khyl 80b2b45d60 ipn/ipnlocal: refactor and cleanup profileManager
In preparation for multi-user and unattended mode improvements, we are
refactoring and cleaning up `ipn/ipnlocal.profileManager`. The concept of the
"current user", which is only relevant on Windows, is being deprecated and will
soon be removed to allow more than one Windows user to connect and utilize
`LocalBackend` according to that user's access rights to the device and specific
Tailscale profiles.

We plan to pass the user's identity down to the `profileManager`, where it can
be used to determine the user's access rights to a given `LoginProfile`. While
the new permission model in `ipnauth` requires more work and is currently
blocked pending PR reviews, we are updating the `profileManager` to reduce its
reliance on the concept of a single OS user being connected to the backend at
the same time.

We extract the switching to the default Tailscale profile, which may also
trigger legacy profile migration, from `profileManager.SetCurrentUserID`. This
introduces `profileManager.DefaultUserProfileID`, which returns the default
profile ID for the current user, and `profileManager.SwitchToDefaultProfile`,
which is essentially a shorthand for `pm.SwitchProfile(pm.DefaultUserProfileID())`.
Both methods will eventually be updated to accept the user's identity and
utilize that user's default profile.

We make access checks more explicit by introducing the `profileManager.checkProfileAccess`
method. The current implementation continues to use `profileManager.currentUserID`
and `LoginProfile.LocalUserID` to determine whether access to a given profile
should be granted. This will be updated to utilize the `ipnauth` package and the
new permissions model once it's ready. We also expand access checks to be used
more widely in the `profileManager`, not just when switching or listing
profiles. This includes access checks in methods like `SetPrefs` and, most notably,
`DeleteProfile` and `DeleteAllProfiles`, preventing unprivileged Windows users
from deleting Tailscale profiles owned by other users on the same device,
including profiles owned by local admins.

We extract `profileManager.ProfilePrefs` and `profileManager.SetProfilePrefs`
methods that can be used to get and set preferences of a given `LoginProfile` if
`profileManager.checkProfileAccess` permits access to it.

We also update `profileManager.setUnattendedModeAsConfigured` to always enable
unattended mode on Windows if `Prefs.ForceDaemon` is true in the current
`LoginProfile`, even if `profileManager.currentUserID` is `""`. This facilitates
enabling unattended mode via `tailscale up --unattended` even if
`tailscale-ipn.exe` is not running, such as when a Group Policy or MDM-deployed
script runs at boot time, or when Tailscale is used on a Server Code or otherwise
headless Windows environments. See #12239, #2137, #3186 and
https://github.com/tailscale/tailscale/pull/6255#issuecomment-2016623838 for
details.

Fixes #12239
Updates tailscale/corp#18342
Updates #3186
Updates #2137

Signed-off-by: Nick Khyl <nickk@tailscale.com>
3 months ago
..
conffile cmd/tailscaled, ipn/conffile: support ec2 user-data config file 6 months ago
ipnauth ipn/{ipnauth,ipnlocal,ipnserver,localapi}: start baby step toward moving access checks from the localapi.Handler to the LocalBackend 3 months ago
ipnlocal ipn/ipnlocal: refactor and cleanup profileManager 3 months ago
ipnserver ipn/{ipnauth,ipnlocal,ipnserver,localapi}: start baby step toward moving access checks from the localapi.Handler to the LocalBackend 3 months ago
ipnstate cmd/tl-longchain: tool to re-sign nodes with long rotation signatures 3 months ago
localapi ipn/{ipnauth,ipnlocal,ipnserver,localapi}: start baby step toward moving access checks from the localapi.Handler to the LocalBackend 3 months ago
policy ipn,tailconfig: clean up unreleased and removed app connector service 1 year ago
store all: add test for package comments, fix, add comments as needed 5 months ago
backend.go health: begin work to use structured health warnings instead of strings, pipe changes into ipn.Notify (#12406) 6 months ago
conf.go ipn,wgengine/magicsock: allow setting static node endpoints via tailscaled configfile (#12882) 4 months ago
doc.go all: update copyright and license headers 2 years ago
ipn_clone.go cmd/cloner, cmd/viewer, util/codegen: add support for generic types and interfaces 5 months ago
ipn_test.go all: do not depend on the testing package 6 months ago
ipn_view.go ipn,wgengine: remove vestigial Prefs.AllowSingleHosts 7 months ago
prefs.go ipn: allow FQDN in exit node selection 5 months ago
prefs_test.go ipn: allow FQDN in exit node selection 5 months ago
serve.go cmd/serve: don't convert localhost to 127.0.0.1 5 months ago
serve_test.go cmd/serve: don't convert localhost to 127.0.0.1 5 months ago
store.go ipn: add comment about thread-safety to StateStore 9 months ago
store_test.go ipn: avoid useless no-op WriteState calls 1 year ago