ipnlocal: support setting authkey at login using syspolicy (#13061)
Updates tailscale/corp#22120 Adds the ability to start the backend by reading an authkey stored in the syspolicy database (MDM). This is useful for devices that are provisioned in an unattended fashion. Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
This commit is contained in:
parent
16bb541adb
commit
9d2b1820f1
|
@ -1868,6 +1868,14 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||
opts.AuthKey = v
|
||||
}
|
||||
|
||||
if b.state != ipn.Running && b.conf == nil && opts.AuthKey == "" {
|
||||
sysak, _ := syspolicy.GetString(syspolicy.AuthKey, "")
|
||||
if sysak != "" {
|
||||
b.logf("Start: setting opts.AuthKey by syspolicy, len=%v", len(sysak))
|
||||
opts.AuthKey = strings.TrimSpace(sysak)
|
||||
}
|
||||
}
|
||||
|
||||
hostinfo := hostinfo.New()
|
||||
applyConfigToHostinfo(hostinfo, b.conf)
|
||||
hostinfo.BackendLogID = b.backendLogID.String()
|
||||
|
|
|
@ -94,6 +94,10 @@ const (
|
|||
// organization. A button in the client UI provides easy access to this URL.
|
||||
ManagedByURL Key = "ManagedByURL"
|
||||
|
||||
// AuthKey is an auth key that will be used to login whenever the backend starts. This can be used to
|
||||
// automatically authenticate managed devices, without requiring user interaction.
|
||||
AuthKey Key = "AuthKey"
|
||||
|
||||
// Keys with a string array value.
|
||||
// AllowedSuggestedExitNodes's string array value is a list of exit node IDs that restricts which exit nodes are considered when generating suggestions for exit nodes.
|
||||
AllowedSuggestedExitNodes Key = "AllowedSuggestedExitNodes"
|
||||
|
|
Loading…
Reference in New Issue