Zum Inhalt springen

Android Setup & Backend-Verifizierung

Android-native-System verwendet

Abschnitt: Android-native-System verwendet

Bei Android wird dieses Plugin verwendet Google Play Integrity Standard API:

  • prepareIntegrityToken während prepare()
  • requestStandardIntegrityToken für createAttestation() und createAssertion()
  • Android-App wird über das Google Play-Ökosystem verteilt
  • Google Play-Dienste sind auf dem Gerät verfügbar
  • Play Integrity API ist für Ihre App aktiviert
  • Google Cloud-Projekt-Nummer konfiguriert
  1. Aktivieren Play Integrity API in Ihrem Google Cloud-Projekt. Öffnen Sie das Play Console und konfigurieren Sie den Zugriff auf Play Integrity für Ihre App.
  2. Bereitstellen
  3. dem Plugin. cloudProjectNumber __CAPGO_KEEP_0__-Konfiguration

Abschnitt mit dem Titel „Capacitor-Konfiguration“

Capacitor.config.ts
capacitor.config.ts
plugins: {
AppAttest: {
cloudProjectNumber: '123456789012',
},
}

Sie können auch einen Wert übergeben cloudProjectNumber in der Methodeoption pro Aufruf.

import { AppAttest } from '@capgo/capacitor-app-attest';
const { keyId } = await AppAttest.prepare({
cloudProjectNumber: '123456789012',
});
const attestation = await AppAttest.createAttestation({
keyId,
challenge: 'backend-registration-challenge',
});
const assertion = await AppAttest.createAssertion({
keyId,
payload: 'backend-request-payload',
});

token ist ein Play-Integritäts-Token und muss serverseitig entschlüsselt werden.

  1. Der Hintergrund erstellt einen einmaligen Token challenge.
  2. App-Anrufe createAttestation({ keyId, challenge }).
  3. Hintergrundanrufe bei Google decodeIntegrityToken API.
  4. Hintergrund verifiziert mindestens:
    • requestDetails.requestHash === base64url(SHA256(challenge))
    • appIntegrity.packageName entspricht Ihrer Android-Anwendung-Id
    • appIntegrity.certificateSha256Digest enthält Ihren Release-Signierungs-Zertifikats-Digest
    • Integritätsurteile entsprechen Ihrer Sicherheitspolitik
  1. Hintergrund erstellt eine einmalige payload.
  2. App-Anrufe createAssertion({ keyId, payload }).
  3. Hintergrund entschlüsselt Token und überprüft requestHash === base64url(SHA256(payload)).
  4. Verhindere Wiedergabeprävention (eine Verwendung + TTL) und Integritätsurteilsrichtlinie.
sequenceDiagram
participant App as Android App
participant Plugin as AppAttest plugin
participant PlaySDK as Play Integrity SDK
participant BE as Backend
participant Google as decodeIntegrityToken API
App->>Plugin: prepare(cloudProjectNumber)
Plugin->>PlaySDK: prepareIntegrityToken()
PlaySDK-->>Plugin: provider handle (keyId)
BE->>App: one-time challenge
App->>Plugin: createAttestation(keyId, challenge)
Plugin->>PlaySDK: requestStandardIntegrityToken(requestHash)
PlaySDK-->>Plugin: integrity token
Plugin-->>App: token + platform + format + keyId
App->>BE: token + challenge + keyId
BE->>Google: decodeIntegrityToken(token)
Google-->>BE: decoded payload
BE->>BE: verify requestHash + app identity + verdicts
BE->>App: one-time payload
App->>Plugin: createAssertion(keyId, payload)
Plugin->>PlaySDK: requestStandardIntegrityToken(requestHash)
PlaySDK-->>Plugin: integrity token
App->>BE: token + payload + keyId
BE->>Google: decodeIntegrityToken(token)
Google-->>BE: decoded payload
BE->>BE: verify requestHash + replay policy

Registrierung:

{
"platform": "android",
"format": "google-play-integrity-standard",
"keyId": "string",
"challenge": "string",
"token": "string"
}

Behauptung:

{
"platform": "android",
"format": "google-play-integrity-standard",
"keyId": "string",
"payload": "string",
"token": "string"
}