Ktor backend sample¶
A Ktor backend for local and mobile end-to-end passkey flows.
Routes¶
POST /webauthn/registration/startPOST /webauthn/registration/finishPOST /webauthn/authentication/startPOST /webauthn/authentication/finishGET /healthGET /.well-known/assetlinks.jsonGET /.well-known/apple-app-site-associationGET /apple-app-site-associationGET /webauthn/cli/browser
Run¶
Environment variables:
PORT(default8080)WEBAUTHN_SAMPLE_ATTESTATION(STRICTdefault, setNONEto explicitly disable strict attestation verification for local bring-up)ANDROID_PACKAGE_NAME(defaultdev.webauthn.samples.composepasskey.android)ANDROID_SHA256(default placeholder; set for real-device app-link verification)IOS_APP_ID(canonical iOS app ID for AASAwebcredentials.apps, default placeholder)IOS_TEAM_ID(optional helper input, used to deriveIOS_APP_IDwhenIOS_APP_IDis unset)IOS_BUNDLE_ID(optional helper input, used to deriveIOS_APP_IDwhenIOS_APP_IDis unset)
IOS_APP_ID resolution:
- If
IOS_APP_IDis set, it is used as-is. - Else if both
IOS_TEAM_IDandIOS_BUNDLE_IDare set, backend derivesIOS_APP_ID=${IOS_TEAM_ID}.${IOS_BUNDLE_ID}. - Else backend uses placeholder
TEAMID.com.example.appand logs a warning.
ngrok helper¶
For physical-device flows with associated domains:
This helper updates root local.properties with WEBAUTHN_DEMO_ENDPOINT,
WEBAUTHN_DEMO_RP_ID, and the iOS/web WEBAUTHN_DEMO_ORIGIN, then starts the
backend with matching association values. The Android host derives its
android:apk-key-hash:... ceremony origin from the installed app's signing
certificate; ANDROID_SHA256 must describe that same certificate for the served
Digital Asset Links statement.