Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.
Gen1 DocsLegacy

Page updated Jun 24, 2025

WebAuthn認証器の管理

Amplify Authはパスキーをカメラルートンの認証情報メカニズムとして使用しています。以下のAPIにより、ユーザーはCognitoアカウントに関連付けられたパスキーを登録、追跡、削除できます。

Amplifyでのパスキーの使用詳細を学習

WebAuthn認証器の関連付け

ユーザーがパスキーを登録するには認証されている必要があることに注意してください。これはユーザーがサインアップ中にパスキーを作成できないことも意味します。したがって、WebAuthnを使用するにはアカウントに関連付けられた少なくとも1つの他の第一要因認証メカニズムが必要です。

以下のAPIを使用してパスキーを関連付けることができます:

import { associateWebAuthnCredential} from 'aws-amplify/auth';
await associateWebAuthnCredential();

ユーザーはローカル認証器を使用してパスキーを登録するように促されます。その後、AmplifyはそのパスキーをCognitoに関連付けます。

WebAuthn認証器の一覧表示

以下のAPIを使用して登録済みのパスキーを一覧表示できます:

import { listWebAuthnCredentials } from 'aws-amplify/auth';
const result = await listWebAuthnCredentials();
for (const credential of result.credentials) {
console.log(`Credential ID: ${credential.credentialId}`);
console.log(`Friendly Name: ${credential.friendlyCredentialName}`);
console.log(`Relying Party ID: ${credential.relyingPartyId}`);
console.log(`Created At: ${credential.createdAt}`);
}

WebAuthn認証器の削除

以下のAPIでパスキーを削除できます:

import { deleteWebAuthnCredential } from 'aws-amplify/auth';
const id = "credential-id-to-delete";
await deleteWebAuthnCredential({
credentialId: id
});

実用的な例

以下はリストAPIと削除APIを一緒に使用するコード例です。この例では、ユーザーは3つのパスキーが登録されています。ユーザーはpageSizeを2として使用しながらすべてのパスキーを一覧表示し、リスト内の最初のパスキーを削除したいと考えています。

import {
listWebAuthnCredentials,
deleteWebAuthnCredential
} from 'aws-amplify/auth';
let passkeys = [];
const result = await listWebAuthnCredentials({ pageSize: 2 });
passkeys.push(...result.credentials);
const nextPage = await listWebAuthnCredentials({
pageSize: 2,
nextToken: result.nextToken,
});
passkeys.push(...nextPage.credentials);
const id = passkeys[0].credentialId;
await deleteWebAuthnCredential({
credentialId: id
});