Zum Inhalt springen

Android Setup & Backend-Verifizierung

GitHub

Bei Android verwendet dieses Plugin Google Play Integrity Standard API:

  • prepareIntegrityToken Während prepare()
  • requestStandardIntegrityToken Für createAttestation() und createAssertion()

Anforderungen

Anforderungen
  • Android-Anwendung, die über das Google Play-Ökosystem verteilt wird
  • Google Play-Dienste sind auf dem Gerät verfügbar
  • Play Integrity API ist für Ihre App aktiviert
  • Google Cloud-Projekt-ID ist konfiguriert

Google-Einrichtung

Einrichten
  1. Aktivieren Play Integrity API in Ihrem Google Cloud-Projekt.
  2. Öffnen Sie das Play Console und konfigurieren Sie den Zugriff auf Play Integrity für Ihre App.
  3. Bereitstellen cloudProjectNumber den Plugin-Parameter.

Capacitor Konfiguration

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

Client-Flow cloudProjectNumber Client flow

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 Integrity-Token und muss serverseitig entschlüsselt werden.

Registrierung (createAttestation)createAttestation)

Hintergrund erstellt einen einmaligen
  1. Die App ruft an challenge.
  2. Der Hintergrund ruft Google an createAttestation({ keyId, challenge }).
  3. __CAPGO_KEEP_0__. decodeIntegrityToken API.
  4. Abschnitt mit dem Titel “Backend workflow (Android)”
    • requestDetails.requestHash === base64url(SHA256(challenge))
    • appIntegrity.packageName Gleicht deinem Android-Anwendungs-ID
    • appIntegrity.certificateSha256Digest enthält deinen Release-Zertifikats-Digest
    • Integritätsurteile entsprechen deiner Sicherheitspolitik

Anfrage schützen (createAssertion)createAssertion)

Abschnitt: Anfrage schützen (createAssertion)
  1. Hintergrund erstellt einen einmaligen payload.
  2. App ruft createAssertion({ keyId, payload }).
  3. Hintergrund entschlüsselt Token und überprüft requestHash === base64url(SHA256(payload)).
  4. Erzwingen Sie die Vorbeugung von Wiederholungen (eine Verwendung + TTL) und die Integritätsurteile-Politik.
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"
}

Wenn Sie Android Setup & Backend-Verifizierung verwenden Android Setup & Backend-Verifizierung um Sicherheit und Compliance zu planen, verbinden Sie es mit Verwendung von @capgo/capacitor-app-attest für die native Fähigkeit in @capgo/capacitor-app-attest, Verschlüsselung für die Implementierungsdetails in Verschlüsselung, Zuverlässigkeit für die Implementierungsdetails in Zuverlässigkeit, Capgo Sicherheits-Scanner für den Produktworkflow in Capgo Sicherheits-Scanner, und Capgo Sicherheit für den Produktworkflow in Capgo Sicherheit.