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.
This commit is contained in:
2026-11-18 14:47:51 +02:00
parent 7f02ec606c
commit e36b9de154
2 changed files with 13 additions and 8 deletions
+6 -3
View File
@@ -38,12 +38,15 @@
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<!-- End of the Skysparkle sign-in: the site sends the browser back with a one-time code --> <!-- End of the Skysparkle sign-in: the site sends the browser back with a one-time code.
<intent-filter> A verified App Link (app.skysparkle.cc/.well-known/assetlinks.json names this app's
signing key), so no other app can catch the code. A separate subdomain, because
Chrome keeps links to the site you are already on inside the browser -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="cc.skysparkle.sparkledns" android:host="connect" /> <data android:scheme="https" android:host="app.skysparkle.cc" android:path="/app/callback" />
</intent-filter> </intent-filter>
</activity> </activity>
@@ -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, // 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 // 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 // https://app.skysparkle.cc/app/callback?code=…&state=…, a verified App Link that only this app
// new key. Only this app knows the verifier, so a code caught by another app is useless. // (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 { object SkysparkleSignIn {
private const val CONNECT_URL = "https://skysparkle.cc/app/connect" private const val CONNECT_URL = "https://skysparkle.cc/app/connect"
private const val TOKEN_URL = "https://skysparkle.cc/api/app/token" private const val TOKEN_URL = "https://skysparkle.cc/api/app/token"
private const val SCHEME = "cc.skysparkle.sparkledns" private const val CALLBACK_HOST = "app.skysparkle.cc"
private const val HOST = "connect" private const val CALLBACK_PATH = "/app/callback"
// The browser step must be finished within this time (the site keeps codes for 5 minutes) // 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 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 // Not tied to a screen: rotating or leaving the screen must not cancel the exchange
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) 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 // Opens the account page. Verifier and state are kept on disk: the system may stop the app
// while the browser is in front. // while the browser is in front.