From e36b9de1546588b272f7a3d72fb2cbc85bdfd1f8 Mon Sep 17 00:00:00 2001 From: kalarina Date: Wed, 18 Nov 2026 14:47:51 +0200 Subject: [PATCH] Return from the Skysparkle sign-in through a verified App Link Replace the cc.skysparkle.sparkledns:// callback with https://app.skysparkle.cc/app/callback (autoVerify), so only the app signed with the release key can receive the one-time code. --- app/src/main/AndroidManifest.xml | 9 ++++++--- .../cc/skysparkle/sparkledns/SkysparkleSignIn.kt | 12 +++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b84a52d..634548c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,12 +38,15 @@ - - + + - + diff --git a/app/src/main/java/cc/skysparkle/sparkledns/SkysparkleSignIn.kt b/app/src/main/java/cc/skysparkle/sparkledns/SkysparkleSignIn.kt index f48619c..3e995c1 100644 --- a/app/src/main/java/cc/skysparkle/sparkledns/SkysparkleSignIn.kt +++ b/app/src/main/java/cc/skysparkle/sparkledns/SkysparkleSignIn.kt @@ -26,13 +26,14 @@ import java.security.SecureRandom // // OAuth for native apps (RFC 8252) with PKCE (RFC 7636): the account page opens in the browser, // so the password never passes through the app. After "Connect" the site sends the browser to -// cc.skysparkle.sparkledns://connect?code=…&state=…, and the app trades the one-time code for a -// new key. Only this app knows the verifier, so a code caught by another app is useless. +// https://app.skysparkle.cc/app/callback?code=…&state=…, a verified App Link that only this app +// (signed with our key) receives, and the app trades the one-time code for a new key. Only this +// app knows the verifier, so even a code that leaked somewhere else is useless. object SkysparkleSignIn { private const val CONNECT_URL = "https://skysparkle.cc/app/connect" private const val TOKEN_URL = "https://skysparkle.cc/api/app/token" - private const val SCHEME = "cc.skysparkle.sparkledns" - private const val HOST = "connect" + private const val CALLBACK_HOST = "app.skysparkle.cc" + private const val CALLBACK_PATH = "/app/callback" // The browser step must be finished within this time (the site keeps codes for 5 minutes) private const val PENDING_TTL_MS = 30 * 60_000L @@ -51,7 +52,8 @@ object SkysparkleSignIn { // Not tied to a screen: rotating or leaving the screen must not cancel the exchange private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) - fun isCallback(uri: Uri?): Boolean = uri?.scheme == SCHEME && uri.host == HOST + fun isCallback(uri: Uri?): Boolean = + uri?.scheme == "https" && uri.host == CALLBACK_HOST && uri.path == CALLBACK_PATH // Opens the account page. Verifier and state are kept on disk: the system may stop the app // while the browser is in front.