Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Passkeys: Touch ID passkeys with a Developer ID provisioning profile

Victorcda7e4bf6225
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5b41192..9cf532a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,6 +13,8 @@ name: Release
# APPLE_APP_PASSWORD app-specific password for that Apple ID
# SPARKLE_PRIVATE_KEY EdDSA key that signs updates (generate_keys --account cra -x),
# required: installed copies only accept updates it signed
+# MACOS_PROVISIONING_PROFILE optional, base64 of the Developer ID provisioning profile
+# for dk.kildahl.cra: turns on passkeys (docs/release.md)
on:
push:
@@ -57,7 +59,12 @@ jobs:
env:
P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12 }}
P12_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
+ PROFILE_BASE64: ${{ secrets.MACOS_PROVISIONING_PROFILE }}
run: |
+ if [ -n "$PROFILE_BASE64" ]; then
+ echo "$PROFILE_BASE64" | base64 --decode > "$RUNNER_TEMP/Cra.provisionprofile"
+ echo "CRA_PROVISIONING_PROFILE=$RUNNER_TEMP/Cra.provisionprofile" >> "$GITHUB_ENV"
+ fi
KEYCHAIN="$RUNNER_TEMP/signing.keychain-db"
KEYCHAIN_PASSWORD="$(openssl rand -hex 16)"
echo "$P12_BASE64" | base64 --decode > "$RUNNER_TEMP/cert.p12"
diff --git a/docs/release.md b/docs/release.md
index 160707d..3dcc2f2 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -27,6 +27,7 @@ Everything is scripted; the only manual part is obtaining the certificate once.
| `APPLE_ID` | the Apple ID email |
| `APPLE_TEAM_ID` | the 10-character team id |
| `APPLE_APP_PASSWORD` | the app-specific password |
+ | `MACOS_PROVISIONING_PROFILE` | optional, for passkeys (see [Passkeys](#passkeys)) |
Until these exist the Release workflow still runs: it publishes an ad-hoc build as a
regular release (pre-releases are invisible to `releases/latest`) with the install
@@ -104,6 +105,34 @@ The entitlements are the hardened-runtime exceptions Chromium needs (JIT, unsign
executable memory, library validation off, dyld environment variables), plus camera,
microphone and location so sites can ask for them.
+## Passkeys
+
+Security keys and phones (the QR code in Chrome's "Passkeys & Security Keys" dialog)
+work in every build. Passkeys kept on the Mac need entitlements macOS only honours
+with a provisioning profile, the way Chrome, Arc and Dia ship:
+
+| Entitlement | Turns on |
+|---|---|
+| `keychain-access-groups` = `<team>.dk.kildahl.cra.webauthn` | Chromium's Touch ID passkeys, stored in Cra's keychain group. `scripts/cef-patches/webauthn-keychain-access-group.patch` derives the group from the app's `application-identifier` (Chromium's branding has no team ID). |
+| `com.apple.developer.web-browser.public-key-credential` | iCloud Keychain passkeys (Passwords app), through Chromium's own iCloud Keychain code. Managed: Apple must approve it. |
+
+One-time setup, as the Account Holder:
+
+1. Request the entitlement for `dk.kildahl.cra` at
+ https://developer.apple.com/contact/request/macos-browsers-passkeys/ (Account Holder
+ only). Apple reviews it and adds it as a managed capability, which then shows under
+ the App ID's Additional Capabilities. The Touch ID group needs no approval.
+2. Create a **Developer ID** provisioning profile for the explicit App ID
+ `dk.kildahl.cra` and download it. Once the entitlement is approved, regenerate it and
+ check that it is included: `security cms -D -i Cra.provisionprofile | grep -A1 public-key`.
+3. Locally: `CRA_PROVISIONING_PROFILE=Cra.provisionprofile` next to `CRA_SIGN_IDENTITY`.
+ In CI: the `MACOS_PROVISIONING_PROFILE` secret, `base64 -i Cra.provisionprofile | pbcopy`.
+
+`build.sh` embeds the profile as `Contents/embedded.provisionprofile` and adds to
+`Cra.entitlements` only what the profile grants (application and team identifier,
+the keychain group, iCloud Keychain once approved), because macOS refuses to launch an
+app that claims an entitlement its profile lacks. Ad-hoc builds never get them.
+
## Updates
Cra updates itself the way Arc does, with [Sparkle 2](https://sparkle-project.org)
diff --git a/scripts/build.sh b/scripts/build.sh
index 1e438e5..5193839 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -4,6 +4,8 @@
# scripts/build.sh debug debug build
# CRA_SIGN_IDENTITY="Developer ID Application: …" scripts/build.sh
# distributable build (see docs/release.md)
+# CRA_PROVISIONING_PROFILE=<path> (with CRA_SIGN_IDENTITY)
+# adds the passkey entitlements the profile grants
# CRA_INSTALL_DIR=<dir> scripts/build.sh
# also copies the app to <dir>/Cra.app
# Dev builds are version 0.0.0-dev and stay unregistered with LaunchServices, so
@@ -83,7 +85,34 @@ sign "$SPARKLE/Versions/B/Autoupdate"
sign "$SPARKLE/Versions/B/Updater.app"
sign "$SPARKLE"
for h in "$APP"/Contents/Frameworks/*.app; do sign "$h" "$ROOT/resources/CraHelper.entitlements"; done
-sign "$APP" "$ROOT/resources/Cra.entitlements"
+# Passkeys need entitlements only a provisioning profile can grant: the Touch ID
+# keychain group ("<app id>.webauthn", scripts/cef-patches) and, once Apple approves
+# it, iCloud Keychain (web-browser.public-key-credential). With
+# CRA_PROVISIONING_PROFILE=<Developer ID profile> the app embeds it and claims what
+# it allows; macOS refuses to launch an app that claims more. See docs/release.md.
+APP_ENTITLEMENTS="$ROOT/resources/Cra.entitlements"
+if [ -n "${CRA_PROVISIONING_PROFILE:-}" ] && [ "$IDENTITY" != "-" ]; then
+ PB=/usr/libexec/PlistBuddy
+ PROFILE="$STAGE/profile.plist"
+ security cms -D -i "$CRA_PROVISIONING_PROFILE" -o "$PROFILE"
+ APP_ID="$($PB -c "Print :Entitlements:com.apple.application-identifier" "$PROFILE")"
+ BUNDLE_ID="$($PB -c "Print :CFBundleIdentifier" "$APP/Contents/Info.plist")"
+ [ "${APP_ID#*.}" = "$BUNDLE_ID" ] || { echo "Provisioning profile is for $APP_ID, not $BUNDLE_ID" >&2; exit 1; }
+ cp "$CRA_PROVISIONING_PROFILE" "$APP/Contents/embedded.provisionprofile"
+ APP_ENTITLEMENTS="$STAGE/Cra.entitlements"
+ cp "$ROOT/resources/Cra.entitlements" "$APP_ENTITLEMENTS"
+ $PB -c "Add :com.apple.application-identifier string $APP_ID" \
+ -c "Add :com.apple.developer.team-identifier string ${APP_ID%%.*}" "$APP_ENTITLEMENTS"
+ if $PB -c "Print :Entitlements:keychain-access-groups" "$PROFILE" >/dev/null 2>&1; then
+ $PB -c "Add :keychain-access-groups array" -c "Add :keychain-access-groups:0 string $APP_ID.webauthn" "$APP_ENTITLEMENTS"
+ fi
+ if [ "$($PB -c "Print :Entitlements:com.apple.developer.web-browser.public-key-credential" "$PROFILE" 2>/dev/null)" = true ]; then
+ $PB -c "Add :com.apple.developer.web-browser.public-key-credential bool true" "$APP_ENTITLEMENTS"
+ else
+ echo "Note: the provisioning profile has no web-browser.public-key-credential; iCloud Keychain passkeys stay off" >&2
+ fi
+fi
+sign "$APP" "$APP_ENTITLEMENTS"
if [ "$IDENTITY" != "-" ]; then
codesign --verify --deep --strict --verbose=2 "$APP"
fi
diff --git a/scripts/cef-patches/webauthn-keychain-access-group.patch b/scripts/cef-patches/webauthn-keychain-access-group.patch
new file mode 100644
index 0000000..2aa6773
--- /dev/null
+++ b/scripts/cef-patches/webauthn-keychain-access-group.patch
@@ -0,0 +1,53 @@
+diff --git a/chrome/browser/webauthn/chrome_web_authentication_delegate.cc b/chrome/browser/webauthn/chrome_web_authentication_delegate.cc
+index 6fc50b6960..2d7a54a5ca 100644
+--- a/chrome/browser/webauthn/chrome_web_authentication_delegate.cc
++++ b/chrome/browser/webauthn/chrome_web_authentication_delegate.cc
+@@ -81,6 +81,11 @@
+ #endif
+
+ #if BUILDFLAG(IS_MAC)
++#include <Security/Security.h>
++
++#include "base/apple/scoped_cftyperef.h"
++#include "base/no_destructor.h"
++#include "base/strings/sys_string_conversions.h"
+ #include "device/fido/mac/credential_metadata.h"
+ #endif
+
+@@ -391,8 +396,25 @@ void ChromeWebAuthenticationDelegate::UpdateUserPasskeys(
+ ChromeWebAuthenticationDelegate::TouchIdAuthenticatorConfig
+ ChromeWebAuthenticationDelegate::TouchIdAuthenticatorConfigForProfile(
+ Profile* profile) {
+- constexpr char kKeychainAccessGroup[] =
+- MAC_TEAM_IDENTIFIER_STRING "." MAC_BUNDLE_IDENTIFIER_STRING ".webauthn";
++ // Cra: "<application-identifier>.webauthn" of the running app, so an embedder
++ // signed with its own team can keep passkeys in the keychain. Chromium's
++ // branding has no team ID; without the entitlement this falls back to it.
++ static const base::NoDestructor<std::string> kKeychainAccessGroup([] {
++ base::apple::ScopedCFTypeRef<SecTaskRef> task(
++ SecTaskCreateFromSelf(nullptr));
++ if (task) {
++ base::apple::ScopedCFTypeRef<CFTypeRef> app_id(
++ SecTaskCopyValueForEntitlement(
++ task.get(), CFSTR("com.apple.application-identifier"), nullptr));
++ if (app_id && CFGetTypeID(app_id.get()) == CFStringGetTypeID()) {
++ return base::SysCFStringRefToUTF8(
++ static_cast<CFStringRef>(app_id.get())) +
++ ".webauthn";
++ }
++ }
++ return std::string(MAC_TEAM_IDENTIFIER_STRING
++ "." MAC_BUNDLE_IDENTIFIER_STRING ".webauthn");
++ }());
+
+ std::string metadata_secret = profile->GetPrefs()->GetString(
+ webauthn::pref_names::kWebAuthnTouchIdMetadataSecretPrefName);
+@@ -405,7 +427,7 @@ ChromeWebAuthenticationDelegate::TouchIdAuthenticatorConfigForProfile(
+ }
+
+ return TouchIdAuthenticatorConfig{
+- .keychain_access_group = kKeychainAccessGroup,
++ .keychain_access_group = *kKeychainAccessGroup,
+ .metadata_secret = std::move(metadata_secret)};
+ }
+
diff --git a/scripts/fetch-cef.sh b/scripts/fetch-cef.sh
index 434fa9c..27dd310 100755
--- a/scripts/fetch-cef.sh
+++ b/scripts/fetch-cef.sh
@@ -13,7 +13,7 @@ CEF_VERSION="${CEF_VERSION:-156.0.14+g4fa4ab5+chromium-156.0.8078.48}"
ARCH="${CEF_ARCH:-macosarm64}"
NAME="cef_binary_${CEF_VERSION}_${ARCH}_minimal"
# Bump the suffix (codecs2, …) when the build changes but CEF_VERSION does not.
-CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs1}"
+CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs2}"
URL="${CEF_URL:-https://github.com/VictorKildahl/cra/releases/download/${CEF_RELEASE}/cef_binary_${ARCH}_minimal.tar.bz2}"
mkdir -p vendor