Aller au contenu

Configuration Android et vérification backend

GitHub

Sur Android, ce plugin utilise Norme d’intégrité Google Play API:

  • prepareIntegrityToken lors de prepare()
  • requestStandardIntegrityToken pour createAttestation() et createAssertion()
  • Application Android distribuée via l’écosystème Google Play
  • Services Google Play disponibles sur l’appareil
  • Play Integrity API activé pour votre application
  • Numéro de projet Google Cloud configuré
  1. Activer Play Integrity API dans votre projet Google Cloud.
  2. Ouvrez Play Console et configurez l’accès à Play Integrity pour votre application.
  3. Fournir cloudProjectNumber au plugin.
capacitor.config.ts
plugins: {
AppAttest: {
cloudProjectNumber: '123456789012',
},
}

Vous pouvez également passer cloudProjectNumber par appel dans les options de la méthode.

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 est un token Play Integrity et doit être décodé côté serveur.

  1. Le backend crée un jeton à usage unique challenge.
  2. L'app appelle createAttestation({ keyId, challenge }).
  3. Le backend appelle Google decodeIntegrityToken API.
  4. Le backend vérifie au minimum :
    • requestDetails.requestHash === base64url(SHA256(challenge))
    • appIntegrity.packageName est égal à l'ID de votre application Android
    • appIntegrity.certificateSha256Digest contains your release signing cert digest
    • integrity verdicts match your security policy
  1. Le backend crée un jeton à usage unique payload.
  2. L'app appelle createAssertion({ keyId, payload }).
  3. Le backend décode le token et vérifie requestHash === base64url(SHA256(payload)).
  4. Appliquez la prévention du replay (usage unique + TTL) et la politique de verdict d'intégrité.
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

Enregistrement :

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

Assertion :

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

Poursuivre depuis Configuration Android & Vérification côté serveur

Section intitulée « Poursuivre depuis Configuration Android & Vérification côté serveur »

Si vous utilisez Configuration Android & Vérification côté serveur pour planifier la sécurité et la conformité, connectez-l’à Utiliser @capgo/capacitor-app-attest pour la capacité native dans la page « Utiliser @capgo/capacitor-app-attest », Chiffrement pour les détails d'implémentation du chiffrement, Conformité pour les détails d'implémentation de la conformité, Scanner de sécurité Capgo pour le workflow produit dans Capgo Security Scanner, et Capgo et la sécurité pour le workflow produit dans Capgo Security.