Skip to content

Android セットアップ & バックエンド検証

GitHub

Androidでは、このプラグインは Google Play Integrity Standard API:

  • prepareIntegrityTokenprepare()
  • requestStandardIntegrityToken のために createAttestation()createAssertion()
  • Google Play エコシステムを通じて配布されるAndroidアプリ
  • デバイス上で利用可能なGoogle Play サービス
  • Play Integrity API がアプリに有効化されている
  • Google Cloud プロジェクト番号が設定されている
  1. 有効化 Play Integrity API Google Cloud プロジェクト内で
  2. Open Play Console and configure Play Integrity access for your app.
  3. Provide cloudProjectNumber をプラグインに提供します。

Capacitor 設定

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

また、オプションのメソッドで呼び出すごとに cloudProjectNumber クライアントフロー

クライアントフロー

クリップボードにコピー
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 はPlay Integrityトークンであり、サーバーサイドでデコードする必要があります。

バックエンドワークフロー(Android)

バックエンドワークフロー(Android)

createAttestation)

登録(createAttestation)
  1. バックエンドは1回限りの challenge.
  2. アプリは createAttestation({ keyId, challenge }).
  3. バックエンドはGoogle decodeIntegrityToken API.
  4. バックエンドは、少なくとも以下を検証する必要があります:
    • requestDetails.requestHash === base64url(SHA256(challenge))
    • appIntegrity.packageName はAndroidアプリケーションIDと等しくなければなりません。
    • appIntegrity.certificateSha256Digest はリリース署名証明書のハッシュと含まれている必要があります。
    • セキュリティポリシーと一致する整合性判定結果

Request protection (createAssertion)

セクション:Request protection (createAssertion)
  1. バックエンドが一時 payload.
  2. アプリが createAssertion({ keyId, payload }).
  3. バックエンドがトークンをデコードし、 requestHash === base64url(SHA256(payload)).
  4. 再生防止(シングルユース+TTL)と整合性判定ポリシーを強制する。
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

バックエンドの最小限のペイロード契約

セクション:バックエンドの最小限のペイロード契約

登録:

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

アサーション:

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

Android セットアップとバックエンド検証から続けて

「Android セットアップとバックエンド検証から続けて」セクション

Capacitor を使用している場合 Android セットアップとバックエンド検証 セキュリティとコンプライアンスを計画するには、Capacitor を Capacitor の @capgo/capacitor-app-attest を使用 Capacitor の @capgo/capacitor-app-attest のネイティブ機能 暗号化 暗号化の実装詳細について Compliance __CAPGO_KEEP_0__ セキュリティ スキャナー Capgo セキュリティ スキャナー製品ワークフローについて Capgo セキュリティ Capgo セキュリティ製品ワークフローについて for the product workflow in Capgo Security.