fleet/tools/mdm/apple/setupexperience
Scott Gress be7e0045a9
Use webview in MacOS setup experience (#33884)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** For #33111

# Details

This PR updates the setup experience for MacOS to use a web view pointed
at the device's "Setting up your device" page rather than using native
MacOS UI elements, bringing it more in line with Linux and Windows setup
experiences.

This covers only the new web UI for the setup experience progress, _not_
the UI for the new case of blocking the device when a piece of software
fails to install. I'll add that in a separate PR.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [X] Added/updated automated tests
Added tests for the updates to the token rotation code.

- [X] QA'd all new/changed functionality manually
A new tool is provided to allow testing this code against a virtual
machine if a separate host that you can wipe and run setup on is not
available. See
https://github.com/fleetdm/fleet/blob/sgress454/new-setup-experience/tools/mdm/apple/setupexperience/README.md
for details.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- New Features
  - macOS setup experience moved to a new web-based UI.
  - Automatic device token rotation during setup to keep sessions valid.
- Bug Fixes
- More reliable setup flow with improved dialog lifecycle and cleaner
handoff to web content.
- Dialog elements hidden/cleared appropriately when transitioning to the
browser.
- Documentation
- Added guide and tool to simulate the macOS setup experience on a VM,
with prerequisites and usage steps.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-08 17:51:26 +01:00
..
main.go Use webview in MacOS setup experience (#33884) 2025-10-08 17:51:26 +01:00
README.md Use webview in MacOS setup experience (#33884) 2025-10-08 17:51:26 +01:00

MacOS setup experience on a Virtual Machine

This is a quick and dirty tool that does some direct SQL queries to set up the necessary state, and therefore comes with some inherent brittleness.

To use:

  1. Start a local server with MDM enabled.
  2. Ensure that end-user validation is disabled in setup experience config.
  3. Ensure no bootstrap package is uploaded.
  4. Ensure no custom setup profile is uploaded.
  5. Add some software and/or scripts to the setup experience config.
  6. Enroll your macOS VM into a team.
  7. Get the UUID of the VM, either via a live query on Fleet (SELECT uuid FROM osquery_info), by inspecting the API response from the /fleet/device/:token endpoint on the My Device page, or querying the hosts table of the MySQL database directly.
  8. Run this tool with the appropriate flags to set up the necessary database records, e.g.:
go run main.go -server-private-key=$(cat ~/path/to/private/key) -host-uuid="your-enrolled-host-uuid"

If the setup dialog doesn't appear on the VM, or it remains on the initial setup screen, try running the tool again and waiting.

Note that the setup experience dialog may not auto-dismiss after completing. You can dismiss manually it by pressing Command-Shift-X. To test the dialog again, run this tool again and restart Orbit on the device.