Skip to content

Desktop: remove prod Firebase credentials from git, inject at CI#5540

Open
beastoin wants to merge 3 commits intomainfrom
fix/desktop-remove-prod-firebase-plist
Open

Desktop: remove prod Firebase credentials from git, inject at CI#5540
beastoin wants to merge 3 commits intomainfrom
fix/desktop-remove-prod-firebase-plist

Conversation

@beastoin
Copy link
Collaborator

Summary

  • Replace prod GoogleService-Info.plist in git with dev (based-hardware-dev) values
  • Codemagic, release.sh, and build.sh now decode prod plist from MACOS_GOOGLE_SERVICE_INFO_PLIST base64 env var
  • Matches Flutter pattern: dev values in git, prod injected at CI

Changes

File Change
GoogleService-Info.plist Prod values → dev values (API_KEY, PROJECT_ID, STORAGE_BUCKET, GCM_SENDER_ID, GOOGLE_APP_ID, CLIENT_ID)
codemagic.yaml Line 2108: decode MACOS_GOOGLE_SERVICE_INFO_PLIST base64 secret, fallback to dev plist
release.sh Line 428: same injection pattern
build.sh Line 88: same injection pattern

Required CI setup (mon)

Before merging, add MACOS_GOOGLE_SERVICE_INFO_PLIST to the desktop_secrets group in Codemagic:

cat Desktop/Sources/GoogleService-Info.plist | base64  # (use the PROD plist, not the dev one in git)

How it works

  • CI release builds: Codemagic decodes the base64 secret → writes prod plist to app bundle
  • Local dev builds (run.sh/dev.sh): Already use GoogleService-Info-Dev.plist → unaffected
  • Local prod builds (build.sh): Uses dev plist from git with WARNING log → functional but against dev Firebase

Security impact

  • Removes prod Firebase API key, CLIENT_ID, PROJECT_ID from public git history
  • After merge, the old prod API key (AIzaSyD9dzBdglc7IO9pPDIOvqnCoTis_xKkkC8) can be rotated
  • Note: key will remain in git history — consider BFG repo cleaner if full purge needed

Test plan

  • mon: Add MACOS_GOOGLE_SERVICE_INFO_PLIST to Codemagic desktop_secrets
  • Codemagic release build injects prod plist correctly
  • Local ./run.sh still works (uses dev plist)
  • Local ./build.sh warns about dev plist

by AI for @beastoin

beastoin and others added 3 commits March 10, 2026 09:43
Prod GoogleService-Info.plist (based-hardware) was committed to the
public repo. Replace with dev values (based-hardware-dev) to match
Flutter's pattern. Prod values will be injected at CI via secret.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Decode MACOS_GOOGLE_SERVICE_INFO_PLIST base64 secret at build time
instead of copying prod plist from git. Falls back to dev plist in
git with a warning if the secret is not set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both scripts now check MACOS_GOOGLE_SERVICE_INFO_PLIST env var and
decode the base64 prod plist. Falls back to dev plist from git with
a warning if the env var is not set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR removes production Firebase credentials from the git-tracked GoogleService-Info.plist and replaces them with dev (based-hardware-dev) values, mirroring the existing Flutter pattern. codemagic.yaml, build.sh, and release.sh now decode the production plist from a MACOS_GOOGLE_SERVICE_INFO_PLIST base64 environment variable at CI time, falling back to the committed dev plist for local builds.

Key changes:

  • GoogleService-Info.plist — prod API_KEY, PROJECT_ID, STORAGE_BUCKET, GCM_SENDER_ID, and GOOGLE_APP_ID swapped for dev equivalents; CLIENT_ID, REVERSED_CLIENT_ID, and ANDROID_CLIENT_ID replaced with placeholder strings rather than real dev OAuth values.
  • codemagic.yaml, build.sh, release.sh — identical injection block added: decode base64 secret → write prod plist; else fall back to dev plist with a WARNING log.
  • The REVERSED_CLIENT_ID placeholder (com.googleusercontent.apps.1031333818730-placeholder) is non-functional for OAuth redirects, making Google Sign-In silently broken in any fallback build, despite the description claiming the path is "functional but against dev Firebase."
  • The decode-then-redirect pattern (echo … | base64 --decode > file) can leave a truncated/empty plist in the bundle if the decode fails mid-stream; using a temp file with an atomic move would be safer.

Confidence Score: 3/5

  • Safe to merge for the security goal (removing prod credentials), but the fallback plist contains non-functional OAuth placeholder values that contradict the stated behaviour.
  • The credential-removal intent is correct and the CI injection logic is sound. However, the placeholder CLIENT_ID/REVERSED_CLIENT_ID values mean Google Sign-In is silently broken for anyone building without the CI secret, and the PR description incorrectly claims this path is "functional". This needs clarification or correction before merge to avoid confusing contributors.
  • desktop/Desktop/Sources/GoogleService-Info.plist — placeholder OAuth credentials need either real dev values or an explicit acknowledgment that OAuth is disabled in this path.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/GoogleService-Info.plist Production Firebase credentials replaced with dev project values; however CLIENT_ID, REVERSED_CLIENT_ID, and ANDROID_CLIENT_ID are non-functional placeholders that will break Google Sign-In OAuth for any build using this fallback plist.
desktop/build.sh Adds base64-decode injection pattern for prod Firebase plist with dev fallback; minor robustness concern around decode-then-redirect sequence with no atomic write.
desktop/release.sh Same injection pattern as build.sh — consistent and correct for the release path; same atomic-write concern applies.
codemagic.yaml Adds the prod plist injection block at line 2108; mirrors the shell script pattern and correctly falls back to the dev plist when the secret is absent.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Build triggered] --> B{MACOS_GOOGLE_SERVICE_INFO_PLIST set?}
    B -- Yes --> C[base64 --decode env var]
    C --> D[Write prod GoogleService-Info.plist to app bundle]
    D --> E[Log: Injected prod plist from CI secret]
    B -- No --> F[cp Desktop/Sources/GoogleService-Info.plist to bundle]
    F --> G[Log: WARNING - using dev plist]
    G --> H[Dev project values used\nAPI_KEY, PROJECT_ID, STORAGE_BUCKET OK\nCLIENT_ID = placeholder → OAuth broken]
    E --> I[Prod Firebase config in bundle\nFully functional]
    H --> J[App runs against based-hardware-dev\nGoogle Sign-In non-functional]
    I --> K[Release build ships]
    J --> L[Local/fallback build ships]
Loading

Last reviewed commit: 8883abe

Comment on lines +6 to +10
<string>1031333818730-placeholder.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.208440318997-suqloh00q5r3ovgoqikvsrf9aqn1t54e</string>
<string>com.googleusercontent.apps.1031333818730-placeholder</string>
<key>ANDROID_CLIENT_ID</key>
<string>208440318997-1ek8tj5oa9ljmnh8tgehk27nqpivivbf.apps.googleusercontent.com</string>
<string>1031333818730-placeholder.apps.googleusercontent.com</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placeholder OAuth credentials break Google Sign-In in fallback builds

CLIENT_ID, REVERSED_CLIENT_ID, and ANDROID_CLIENT_ID are set to non-functional placeholder values (1031333818730-placeholder). The REVERSED_CLIENT_ID is registered as a custom URL scheme in Info.plist so that Google's OAuth flow can redirect back to the app — a placeholder value here won't match any registered OAuth client, so the redirect will silently fail and the Google Sign-In flow will never complete.

The PR description characterises the fallback path as "functional but against dev Firebase", but with placeholder OAuth credentials it is not functional for authentication at all. If real dev OAuth client IDs exist in GoogleService-Info-Dev.plist, those values should be copied here too (they are dev credentials and carry the same risk profile as the rest of this file). If the dev project genuinely has no OAuth client configured, the comment/description should be updated to reflect that Google Sign-In will be broken in local fallback builds.

Comment on lines +88 to +89
if [ -n "$MACOS_GOOGLE_SERVICE_INFO_PLIST" ]; then
echo "$MACOS_GOOGLE_SERVICE_INFO_PLIST" | base64 --decode > "$APP_BUNDLE/Contents/Resources/GoogleService-Info.plist"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validate decoded plist before writing

Both build.sh (line 88–89) and release.sh (line 428–429) decode the secret and write it directly to the app bundle in one step. If $MACOS_GOOGLE_SERVICE_INFO_PLIST is set but contains malformed base64 (e.g., truncated value, wrong encoding), base64 --decode will fail — but because the shell redirect (>) already opened and truncated the target file before the decode fails, set -e exits with an empty/corrupt plist already written to the bundle. A safer pattern is to decode into a temp file and move it only on success:

PLIST_TMP=$(mktemp)
echo "$MACOS_GOOGLE_SERVICE_INFO_PLIST" | base64 --decode > "$PLIST_TMP" \
  && mv "$PLIST_TMP" "$APP_BUNDLE/Contents/Resources/GoogleService-Info.plist" \
  || { echo "ERROR: Failed to decode MACOS_GOOGLE_SERVICE_INFO_PLIST"; rm -f "$PLIST_TMP"; exit 1; }

The same applies to the codemagic.yaml inline script (line 2109) and release.sh (line 429).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant