From 62c5790bf1fc884c217790d88e454ec3229c49f7 Mon Sep 17 00:00:00 2001 From: ChornyiDev Date: Sat, 31 Oct 2026 14:10:41 +0200 Subject: [PATCH] Ship bundled OAuth defaults and one-command source installer with docs --- .github/workflows/release.yml | 9 ++-- AGENTS.md | 3 ++ Configs/Secrets.xcconfig.example | 26 +++++++---- README.md | 14 ++++-- docs/README.md | 1 + docs/building.md | 7 ++- docs/install-from-source.md | 68 +++++++++++++++++++++++++++++ scripts/CONTEXT.md | 3 ++ scripts/install-from-source.sh | 74 ++++++++++++++++++++++++++++++++ 9 files changed, 189 insertions(+), 16 deletions(-) create mode 100644 docs/install-from-source.md create mode 100755 scripts/install-from-source.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0828986..e5b524e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,9 +35,12 @@ jobs: GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} run: | - test -n "$GOOGLE_CLIENT_ID" || { echo "Release builds require Google OAuth secrets"; exit 1; } - printf 'FREEMOUNT_GOOGLE_CLIENT_ID = %s\nFREEMOUNT_GOOGLE_CLIENT_SECRET = %s\nDEVELOPMENT_TEAM =\n' \ - "$GOOGLE_CLIENT_ID" "$GOOGLE_CLIENT_SECRET" > Configs/Secrets.xcconfig + if [ -n "$GOOGLE_CLIENT_ID" ]; then + printf 'FREEMOUNT_GOOGLE_CLIENT_ID = %s\nFREEMOUNT_GOOGLE_CLIENT_SECRET = %s\nDEVELOPMENT_TEAM =\n' \ + "$GOOGLE_CLIENT_ID" "$GOOGLE_CLIENT_SECRET" > Configs/Secrets.xcconfig + else + cp Configs/Secrets.xcconfig.example Configs/Secrets.xcconfig + fi - name: Generate Xcode project run: xcodegen generate diff --git a/AGENTS.md b/AGENTS.md index c0ef00e..6187331 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -116,6 +116,9 @@ root/ ### Security & Keychain - Never write plaintext passwords, secret keys, or OAuth refresh tokens to plaintext config files. - Store sensitive values in macOS Keychain (`Security.framework`). +- The Google OAuth desktop client committed in `Configs/Secrets.xcconfig.example` +is a shipped project default, public by design for installed apps — not a user +secret. User tokens and passwords remain Keychain-only. - Obfuscate or stream config securely to `rclone` during mount creation. - Check `.gitignore` to ensure credentials, `serviceAccountKey.json`, `*.pem`, `*.key`, and `rclone.conf` are strictly excluded. diff --git a/Configs/Secrets.xcconfig.example b/Configs/Secrets.xcconfig.example index a479403..a84a4da 100644 --- a/Configs/Secrets.xcconfig.example +++ b/Configs/Secrets.xcconfig.example @@ -1,12 +1,22 @@ -// FreeMount Google OAuth Desktop Client Credentials +// FreeMount build defaults: project Google OAuth Desktop client + team. // -// INSTRUCTIONS: -// 1. Copy this file to "Configs/Secrets.xcconfig" -// 2. Set your Apple Developer Team ID (https://developer.apple.com/account -> Membership) -// and your Google Cloud Console Desktop OAuth client credentials below. -// 3. Secrets.xcconfig is ignored by git and will never be committed. +// This ships a DEFAULT Google Desktop OAuth client on purpose. Desktop-app +// client credentials are public by design (they are embedded in every +// distributed desktop binary); they are NOT user secrets — user tokens and +// passwords live only in the macOS Keychain. +// +// Google may show an "unverified app" consent warning when signing in with +// Drive/GCS using this shared client, or you can create your own Desktop +// client in Google Cloud Console and replace the two values below. +// SFTP, WebDAV, SMB and FTP/FTPS need no OAuth client at all. +// +// Steps: +// 1. Copy this file to "Configs/Secrets.xcconfig" (or run +// scripts/install-from-source.sh, which does everything). +// 2. Set DEVELOPMENT_TEAM to your own Apple ID team (the installer can +// auto-detect it). Secrets.xcconfig stays git-ignored. -FREEMOUNT_GOOGLE_CLIENT_ID = -FREEMOUNT_GOOGLE_CLIENT_SECRET = +FREEMOUNT_GOOGLE_CLIENT_ID = 319728381325-v71u1mjithqc6ovqvbb4mnc0hhbf0r65.apps.googleusercontent.com +FREEMOUNT_GOOGLE_CLIENT_SECRET = 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 DEVELOPMENT_TEAM = diff --git a/README.md b/README.md index 349f632..6d1277c 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,17 @@ The app starts an authenticated local `rclone rcd`, then registers File Provider ## Build -Requires macOS 14+, Xcode and XcodeGen. A free Apple ID is enough to build and run it locally. +Requires macOS 14+, Xcode and XcodeGen. A free Apple ID is enough to build and run it +locally. For a hands-off install use [`scripts/install-from-source.sh`](docs/install-from-source.md): ```bash -cp Configs/Secrets.xcconfig.example Configs/Secrets.xcconfig # add your Team ID and OAuth client +./scripts/install-from-source.sh +``` + +Manual path: + +```bash +cp Configs/Secrets.xcconfig.example Configs/Secrets.xcconfig # set your Team ID (OAuth defaults are bundled) xcodegen generate xcodebuild -project FreeMount.xcodeproj -scheme FreeMount -configuration Debug -allowProvisioningUpdates build swift test @@ -59,7 +66,8 @@ signed with an Apple Developer ID and notarized. The app relies on App Groups, shared Keychain access groups and a sandboxed File Provider extension — entitlements that require a signing identity, so ad-hoc or unsigned builds do not launch on other Macs. Building from source with your own free Apple ID is -the supported way to run it today. +the supported way to run it today — see +[docs/install-from-source.md](docs/install-from-source.md). ## Documentation diff --git a/docs/README.md b/docs/README.md index e9f0ca8..2704d15 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,7 @@ # Documentation - [building.md](building.md): requirements, signing, OAuth keys, build and test +- [install-from-source.md](install-from-source.md): end-user build-and-install path - [architecture.md](architecture.md): components, ownership, state, reliability - [security.md](security.md): Keychain, local daemon authentication - [adding-a-provider.md](adding-a-provider.md): contributor guide for new providers diff --git a/docs/building.md b/docs/building.md index e2b049b..8412058 100644 --- a/docs/building.md +++ b/docs/building.md @@ -19,9 +19,12 @@ Edit `Configs/Secrets.xcconfig` (git-ignored): | Key | Where to get it | |---|---| | `DEVELOPMENT_TEAM` | Your Team ID: Xcode → Settings → Accounts → select your team | -| `FREEMOUNT_GOOGLE_CLIENT_ID` / `FREEMOUNT_GOOGLE_CLIENT_SECRET` | Google Cloud Console → APIs & Services → Credentials → OAuth client of type **Desktop app** | +| `FREEMOUNT_GOOGLE_CLIENT_ID` / `FREEMOUNT_GOOGLE_CLIENT_SECRET` | Defaults are bundled; optionally your own Google Cloud Console **Desktop app** OAuth client | -Google Drive and GCS (Google Account sign-in) need your own OAuth client. SFTP, +The repository bundles a default Google Desktop OAuth client (public by +design for installed apps; replace it in your local copy if you want your own +quota or a verified consent screen). Google Drive and GCS sign-in work out of +the box with the bundled values. SFTP, WebDAV, SMB, FTP and GCS service-account connections do not. ## Build and test diff --git a/docs/install-from-source.md b/docs/install-from-source.md new file mode 100644 index 0000000..e62b387 --- /dev/null +++ b/docs/install-from-source.md @@ -0,0 +1,68 @@ +# Install FreeMount from source + +FreeMount is free and MIT licensed, but there is no public download: Apple +only allows apps with App Groups, shared Keychain groups and a File Provider +extension to run when they are signed with a developer identity, and the +project has no paid Apple Developer account. You provide that identity +yourself with a **free Apple ID** in Xcode. + +## One command + +Install [Xcode](https://apps.apple.com/app/xcode/id497799835) (full app, not +just Command Line Tools), open it once and sign in with your Apple ID +(Xcode → Settings → Accounts), then: + +```bash +git clone https://github.com/ChornyiDev/FreeMount.git +cd FreeMount +./scripts/install-from-source.sh +``` + +The installer detects your personal Team ID, configures the project, builds a +Release, signs it with your own Apple Development identity and installs +`/Applications/FreeMount.app`. Re-run the same command after `git pull` to +update. + +## What the installer does manually + +If you prefer to control each step: + +```bash +cp Configs/Secrets.xcconfig.example Configs/Secrets.xcconfig +# put your Team ID into DEVELOPMENT_TEAM (Xcode → Settings → Accounts shows it) +brew install xcodegen +xcodegen generate +xcodebuild -project FreeMount.xcodeproj -scheme FreeMount \ + -configuration Release -destination 'platform=macOS' \ + -allowProvisioningUpdates build +# drag the built FM.app from DerivedData's Release folder to /Applications +``` + +## Google Drive / Google Cloud Storage sign-in + +The repository ships default Google OAuth *desktop client* credentials. +Desktop client credentials are public by design; your tokens still go only to +your Keychain. Because the shared client is not verified by Google, the +consent screen may show an "unverified app" warning — it is expected and you +can proceed. To skip the warning (or for your own quota), create a free +"Desktop app" OAuth client in Google Cloud Console and replace the values in +`Configs/Secrets.xcconfig`. SFTP, WebDAV, SMB and FTP/FTPS need no OAuth at +all. + +## Does a source build keep working? + +Yes. Unlike iPhone development profiles, macOS does not re-check the weekly +provisioning window at launch: apps signed with your own Apple Development +identity run on your Mac for months (confirmed by the project author). +If a future macOS ever refuses to launch the app, re-running the installer +re-signs everything in one step. + +## Limitations of this distribution track + +- You are the builder: no notarized downloads, no auto-updates; updating is + `git pull` + re-run the script. +- Each user needs their own Apple ID with Xcode; work Macs with locked-down + Xcode policies may not allow personal team signing. +- The real product decision to change this is a paid Apple Developer ID plus + notarization; the release pipeline for that already exists in + `.github/workflows/release.yml`. diff --git a/scripts/CONTEXT.md b/scripts/CONTEXT.md index 63cefd1..f7eb15c 100644 --- a/scripts/CONTEXT.md +++ b/scripts/CONTEXT.md @@ -9,6 +9,9 @@ official v1.75.1 darwin arm64/amd64 archives and caches extracted binaries. `package-rclone-runtime.sh` embeds both binaries and the upstream MIT notice, then signs helpers with the Xcode identity. `install-rclone-runtime.sh` atomically installs the host architecture binary with ad-hoc development signing. +`install-from-source.sh` builds the full app with the user's personal team and +installs /Applications/FreeMount.app (the supported distribution path; see +docs/install-from-source.md). ## Current State Version v1.75.1; no custom patches, source compilation or Go bootstrap. diff --git a/scripts/install-from-source.sh b/scripts/install-from-source.sh new file mode 100755 index 0000000..d9f64e9 --- /dev/null +++ b/scripts/install-from-source.sh @@ -0,0 +1,74 @@ +#!/bin/zsh +# Build FreeMount from source with your own free Apple ID and install it into +# /Applications. No paid developer account required. +# +# ./scripts/install-from-source.sh [--team ] +# +# What it does: checks prerequisites, prepares Configs/Secrets.xcconfig +# (Google OAuth client defaults ship in the repo), detects or takes your +# personal team ID, builds Release, signs with your Apple Development +# identity and installs. Re-run the same command to update after `git pull`. + +set -euo pipefail +cd "${0:A:h:h}" + +team_override="" +while [[ $# -gt 0 ]]; do + case "$1" in + --team) team_override="$2"; shift 2 ;; + *) print -u2 "Unknown option: $1"; exit 2 ;; + esac +done + +xcode-select -p >/dev/null || { print -u2 "Xcode is required (xcode-select --install or install Xcode)."; exit 1; } +command -v xcodegen >/dev/null || { + command -v brew >/dev/null || { print -u2 "XcodeGen missing and Homebrew not found. Install one: brew install xcodegen"; exit 1; } + print "Installing XcodeGen…" + brew install xcodegen +} + +if [[ ! -f Configs/Secrets.xcconfig ]]; then + cp Configs/Secrets.xcconfig.example Configs/Secrets.xcconfig + print "Created Configs/Secrets.xcconfig from bundled defaults." +fi + +# Resolve personal/team identifier: explicit flag, then config file, then Keychain. +team="$team_override" +[[ -z "$team" ]] && team="$(awk -F'=' '/^DEVELOPMENT_TEAM/ {gsub(/[ \t]/,"",$2); print $2}' Configs/Secrets.xcconfig)" +if [[ -z "$team" ]]; then + teams=($(security find-identity -p codesigning -v \ + | sed -nE 's/.*"Apple Development: .*\(([A-Z0-9]{10})\)".*/\1/p' | sort -u)) + if (( ${#teams[@]} == 0 )); then + print -u2 "No 'Apple Development' certificate found. Open Xcode → Settings → Accounts and sign in with your Apple ID once, then re-run." + exit 1 + fi + (( ${#teams[@]} > 1 )) && print "Multiple development teams found; using ${teams[1]}. Pass --team to choose another." + team="${teams[1]}" + sed -i '' "s/^DEVELOPMENT_TEAM = .*/DEVELOPMENT_TEAM = $team/" Configs/Secrets.xcconfig + print "Auto-detected team $team and saved it to Configs/Secrets.xcconfig." +fi + +print "Generating Xcode project…" +xcodegen generate + +print "Building Release (first run may take a few minutes; Xcode provisions your personal team automatically)…" +xcodebuild -project FreeMount.xcodeproj -scheme FreeMount \ + -configuration Release -destination 'platform=macOS' \ + -derivedDataPath build/install-dd \ + DEVELOPMENT_TEAM="$team" \ + -allowProvisioningUpdates \ + build >/tmp/freemount-install-build.log 2>&1 || { + tail -20 /tmp/freemount-install-build.log + print -u2 "Build failed; full log: /tmp/freemount-install-build.log" + exit 1 + } + +APP="build/install-dd/Build/Products/Release/FM.app" +codesign --verify --deep --strict "$APP" || { print -u2 "Built bundle failed signature verification."; exit 1; } + +pkill -x FM 2>/dev/null || true +if [[ -d /Applications/FreeMount.app ]]; then rm -rf /Applications/FreeMount.app; fi +cp -R "$APP" /Applications/FreeMount.app + +print "Installed /Applications/FreeMount.app — launching." +open /Applications/FreeMount.app