Vai al contenuto

Configurazione Android e verifica del backend

GitHub

Su Android, questo plugin utilizza Standard di integrità di Google Play API:

  • prepareIntegrityToken durante prepare()
  • requestStandardIntegrityToken per createAttestation() e createAssertion()
  • App Android distribuita tramite l'ecosistema Google Play
  • Google Play services disponibili sul dispositivo
  • Play Integrity API abilitato per la tua app
  • Numero del progetto Google Cloud configurato
  1. Abilita Play Integrity API nel tuo progetto Google Cloud.
  2. Apri Play Console e configura l'accesso a Play Integrity per la tua app.
  3. Fornisci cloudProjectNumber al plugin.
capacitor.config.ts
plugins: {
AppAttest: {
cloudProjectNumber: '123456789012',
},
}

Puoi anche passare cloudProjectNumber per chiamata nelle opzioni del metodo.

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 è un token Play Integrity e deve essere decodificato lato server.

  1. Il backend crea un challenge monouso challenge.
  2. L'app chiama createAttestation({ keyId, challenge }).
  3. Il backend chiama Google decodeIntegrityToken API.
  4. Il backend verifica almeno:
    • requestDetails.requestHash === base64url(SHA256(challenge))
    • appIntegrity.packageName corrisponde al tuo application id Android
    • appIntegrity.certificateSha256Digest contiene il digest del certificato di firma di release
    • i verdetti di integrità corrispondono alla tua policy di sicurezza
  1. Il backend crea un challenge monouso payload.
  2. L'app chiama createAssertion({ keyId, payload }).
  3. Il backend decodifica il token e verifica requestHash === base64url(SHA256(payload)).
  4. Applica la prevenzione del replay (uso singolo + TTL) e la policy sul verdetto di integrità.
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

Registrazione:

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

Asserzione:

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

Continua da Android Setup & Backend Verification

Sezione intitolata “Continua da Android Setup & Backend Verification”

Se stai usando Configurazione Android & Verifica del backend per pianificare sicurezza e compliance, collegalo a Utilizzo di @capgo/capacitor-app-attest per la funzionalità nativa in Utilizzo di @capgo/capacitor-app-attest, Crittografia per i dettagli di implementazione della crittografia, Conformità per i dettagli di implementazione in Compliance, Security Scanner di Capgo per il workflow di prodotto in Capgo Security Scanner, e Sicurezza Capgo per il workflow di prodotto in Capgo Security.