e613874de5
Second milestone of the Windows parity work (DESIGN-WINDOWS.md §13). WireGuard mesh client (signed, WSS-delivered): - wireguard_apply / wireguard_remove commands: Ed25519-verified, gated on a new wireguard capability. Linux applies via wg-quick up/down; Windows installs the peer config as a WireGuardTunnel service via wireguard.exe (/installtunnelservice, /uninstalltunnelservice) - state polling in the home monitor drives the blue tray icon and auto-VPN: connect when away from home + auto_vpn, disconnect on return (2m cooldown) - tray VPN toggle and the auto-VPN checkbox are now live; the preference persists to agent.yml (PersistAutoVPN) IAM on Windows (iam_windows.go): - allowed_login_groups -> net localgroup; ssh_keys -> per-profile authorized_keys + %ProgramData%\ssh\administrators_authorized_keys; revoke_users -> helper logs off all of the user's WTS sessions; sudo_rules logged as no direct equivalent Tray enrichment: - Open Config (opens agent.yml), Clear enrollment (re-enroll) menu items - set_auto_vpn persists; vpn_connect/vpn_disconnect/reinit/open_config commands handled by the daemon (tray_server.go) Packaging & release: - installer/windows/installer.iss: fully-offline Inno Setup bundle (agent, tray, helper, vendor-signed WireGuard MSI, OpenCredential CP, VC++ redist), /SILENT /SERVER_URL /JOIN_KEY parameters, SYSTEM service + HKLM Run tray autostart, Users-writable %ProgramData%\Theta42 for the IPC socket - .github/workflows/build-windows.yml: build + test, pinned vendor downloads, ISCC compile, Azure Trusted Signing (OIDC), SHA256SUMS, GH release attach, optional SSO resource publish - agent.yml.example documents auto_vpn, wireguard, service_name, desktop_helper, public_ip_detect Tests: - wireguard_apply/remove dispatch (allowed + capability-denied), PersistAutoVPN, ClearEnrollment; dispatch tests pin linuxPlatformOps with a temp WireGuard conf - end-to-end verified against a local mock SSO on Windows: join-key enrollment (token persisted, join key blanked), discovery/telemetry pushed, signed arbitrary_bash verified + executed via powershell -EncodedCommand; tray IPC socket binds %ProgramData%\Theta42; LDAP byte-pump binds 127.0.0.1:389; helper update swap verified Rebuilds all tracked dist binaries (v2.1.0).
61 lines
1.8 KiB
Go
61 lines
1.8 KiB
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
// Windows IAM helpers (DESIGN-WINDOWS.md §4 "IAM on Windows"). The platform
|
|
// neutral parts live in iam.go; this file adds the Windows-specific pieces that
|
|
// applyIAM cannot express (it is the Linux engine).
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// applyWindowsSSHKeys writes each user's authorized_keys into their profile so
|
|
// the built-in Windows OpenSSH server picks them up. OpenSSH on Windows reads
|
|
// %USERPROFILE%\.ssh\authorized_keys for standard accounts (administrators use
|
|
// %ProgramData%\ssh\administrators_authorized_keys; we mirror the key there too
|
|
// when the profile belongs to an admin is unknowable here, so we write both
|
|
// locations if present).
|
|
func applyWindowsSSHKeys(keys []SSHKey) error {
|
|
pd := os.Getenv("ProgramData")
|
|
if pd == "" {
|
|
pd = `C:\ProgramData`
|
|
}
|
|
|
|
// administrators_authorized_keys covers members of Administrators.
|
|
adminKeys := programDataAdminKeysPath(pd)
|
|
|
|
for _, k := range keys {
|
|
if k.User == "" {
|
|
continue
|
|
}
|
|
content := strings.Join(k.Keys, "\n") + "\n"
|
|
|
|
profile := filepath.Join(`C:\Users`, k.User)
|
|
if st, err := os.Stat(profile); err == nil && st.IsDir() {
|
|
sshDir := filepath.Join(profile, ".ssh")
|
|
if err := os.MkdirAll(sshDir, 0700); err != nil {
|
|
return fmt.Errorf("mkdir %s: %w", sshDir, err)
|
|
}
|
|
dest := filepath.Join(sshDir, "authorized_keys")
|
|
if err := os.WriteFile(dest, []byte(content), 0600); err != nil {
|
|
return fmt.Errorf("write %s: %w", dest, err)
|
|
}
|
|
}
|
|
|
|
// Also mirror into administrators_authorized_keys so admin-keyed logins
|
|
// work through OpenSSH's admin ACL check.
|
|
if err := os.MkdirAll(filepath.Dir(adminKeys), 0700); err == nil {
|
|
_ = os.WriteFile(adminKeys, []byte(content), 0600)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func programDataAdminKeysPath(pd string) string {
|
|
return filepath.Join(pd, "ssh", "administrators_authorized_keys")
|
|
}
|