From ea51b49342a2ce7ca663e939ab4a9bc794ce52a9 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Mon, 22 Jun 2026 00:08:56 +0000 Subject: [PATCH] Serve assetlinks.json for Android App Links verification. Expose /.well-known/assetlinks.json from env-configured Play app signing fingerprints so mini.ladill.com passes Play Console deep link domain checks. Co-authored-by: Cursor --- .env.example | 5 +++ DEPLOY.md | 21 +++++++++- .../WellKnown/AssetLinksController.php | 27 ++++++++++++ config/android_app_links.php | 25 +++++++++++ routes/web.php | 3 ++ tests/Feature/AssetLinksTest.php | 41 +++++++++++++++++++ 6 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/WellKnown/AssetLinksController.php create mode 100644 config/android_app_links.php create mode 100644 tests/Feature/AssetLinksTest.php diff --git a/.env.example b/.env.example index ab817b3..ea8e01b 100644 --- a/.env.example +++ b/.env.example @@ -40,6 +40,11 @@ PAY_API_KEY_MINI= IDENTITY_API_URL=https://ladill.com/api IDENTITY_API_KEY_MINI= +# Android App Links — Play Console → Setup → App signing (SHA-256 certificate fingerprint). +# Comma-separate multiple fingerprints if needed (e.g. upload + app signing keys). +ANDROID_APP_PACKAGE=com.ladill.mini +ANDROID_APP_SHA256_FINGERPRINTS= + # Firebase Cloud Messaging — instant seller payment alerts on Android. FIREBASE_PROJECT_ID= FIREBASE_SERVICE_ACCOUNT_JSON= diff --git a/DEPLOY.md b/DEPLOY.md index 2f240fc..1936698 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -86,7 +86,26 @@ php artisan migrate --force php artisan config:cache route:cache view:cache ``` -## 7. Verify +## 7. Android App Links + +Add the **App signing certificate** SHA-256 fingerprint from Play Console +(Setup → App signing) to production `.env`: + +```env +ANDROID_APP_PACKAGE=com.ladill.mini +ANDROID_APP_SHA256_FINGERPRINTS=AA:BB:CC:... +``` + +After deploy, confirm: + +```bash +curl -sS https://mini.ladill.com/.well-known/assetlinks.json | jq . +``` + +Then re-check deep links in Play Console (App content → Deep links). Users may +need an app update after verification passes. + +## 8. Verify - SSO login at `mini.ladill.com` - Create a payment QR, download PNG diff --git a/app/Http/Controllers/WellKnown/AssetLinksController.php b/app/Http/Controllers/WellKnown/AssetLinksController.php new file mode 100644 index 0000000..aa62c76 --- /dev/null +++ b/app/Http/Controllers/WellKnown/AssetLinksController.php @@ -0,0 +1,27 @@ +json([ + [ + 'relation' => ['delegate_permission/common.handle_all_urls'], + 'target' => [ + 'namespace' => 'android_app', + 'package_name' => config('android_app_links.package_name'), + 'sha256_cert_fingerprints' => $fingerprints, + ], + ], + ], 200, [], JSON_UNESCAPED_SLASHES); + } +} diff --git a/config/android_app_links.php b/config/android_app_links.php new file mode 100644 index 0000000..7401ae4 --- /dev/null +++ b/config/android_app_links.php @@ -0,0 +1,25 @@ + env('ANDROID_APP_PACKAGE', 'com.ladill.mini'), + + 'sha256_cert_fingerprints' => array_values(array_filter(array_map( + static fn (string $fingerprint): string => strtoupper(trim($fingerprint)), + explode(',', (string) env('ANDROID_APP_SHA256_FINGERPRINTS', '')), + ))), + +]; diff --git a/routes/web.php b/routes/web.php index 53563d6..faefe59 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('well-known.assetlinks'); + Route::get('/', fn () => auth()->check() ? redirect()->route('mini.dashboard') : redirect()->route('sso.connect'))->name('mini.root'); diff --git a/tests/Feature/AssetLinksTest.php b/tests/Feature/AssetLinksTest.php new file mode 100644 index 0000000..6ec13e1 --- /dev/null +++ b/tests/Feature/AssetLinksTest.php @@ -0,0 +1,41 @@ + []]); + + $this->get('/.well-known/assetlinks.json')->assertNotFound(); + } + + public function test_assetlinks_returns_json_when_configured(): void + { + config([ + 'android_app_links.package_name' => 'com.ladill.mini', + 'android_app_links.sha256_cert_fingerprints' => [ + 'AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99', + ], + ]); + + $this->get('/.well-known/assetlinks.json') + ->assertOk() + ->assertHeader('Content-Type', 'application/json') + ->assertJson([ + [ + 'relation' => ['delegate_permission/common.handle_all_urls'], + 'target' => [ + 'namespace' => 'android_app', + 'package_name' => 'com.ladill.mini', + 'sha256_cert_fingerprints' => [ + 'AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99', + ], + ], + ], + ]); + } +}