Passkey
Passwordless authentication based on FIDO2
Passwordless authentication based on FIDO2
Passkey is a password-replacement authentication method based on FIDO2/WebAuthn, and a next-generation authentication standard jointly supported by Apple, Google, and Microsoft. Users can log in to websites using only device authentication such as a fingerprint, face recognition, or PIN. It enables convenient authentication that is resistant to phishing, even without a password.
The core innovation of Passkey is multi-device synchronization. Traditional FIDO2 security keys could only be used on the device they were registered to, but Passkeys are synchronized across multiple devices through iCloud Keychain, Google Password Manager, Windows Hello, and others. You can log in on a new device right away with a Passkey you registered before.
Technically, Passkey uses a private key/public key pair. The private key is stored in the secure area of the user's device (Secure Enclave, TPM) and is never sent to the server. Only the public key is stored on the server, so the private key is not leaked even if the server is hacked. A phishing site cannot use the credential of the original site.
Passkey can be adopted gradually. You can run it alongside existing password login and prioritize it once a user registers a Passkey. With browser autofill (Conditional UI), a Passkey is suggested automatically if one exists, making the user experience very natural.
// Passkey λ±λ‘ (Registration)
async function registerPasskey() {
// μλ²μμ λ±λ‘ μ΅μ
κ°μ Έμ€κΈ°
const optionsRes = await fetch('/api/passkey/register/options', {
method: 'POST',
credentials: 'include'
});
const options = await optionsRes.json();
// ArrayBuffer λ³ν
options.challenge = base64URLToBuffer(options.challenge);
options.user.id = base64URLToBuffer(options.user.id);
// Passkey μμ± (μ체μΈμ ν둬ννΈ)
const credential = await navigator.credentials.create({
publicKey: {
...options,
authenticatorSelection: {
residentKey: 'required', // Passkey (Discoverable Credential)
userVerification: 'required', // μ체μΈμ νμ
authenticatorAttachment: 'platform' // λ΄μ₯ μΈμ¦κΈ° μ°μ
}
}
});
// μλ²μ λ±λ‘
await fetch('/api/passkey/register/verify', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
id: credential.id,
rawId: bufferToBase64URL(credential.rawId),
response: {
clientDataJSON: bufferToBase64URL(credential.response.clientDataJSON),
attestationObject: bufferToBase64URL(credential.response.attestationObject)
},
type: credential.type
})
});
}
// Passkey μΈμ¦ - Conditional UI (μλμμ±)
async function authenticateWithConditionalUI() {
// Conditional UI μ§μ νμΈ
if (!window.PublicKeyCredential?.isConditionalMediationAvailable?.()) {
return fallbackToTraditionalLogin();
}
const optionsRes = await fetch('/api/passkey/authenticate/options');
const options = await optionsRes.json();
options.challenge = base64URLToBuffer(options.challenge);
// mediation: 'conditional'λ‘ μλμμ± UI νμ±ν
// μ¬μ©μκ° input νλ ν΄λ¦ μ Passkey μλμμ± νμ
const credential = await navigator.credentials.get({
publicKey: options,
mediation: 'conditional' // ν΅μ¬: μλμμ± ν΅ν©
});
// μλ² κ²μ¦
const verifyRes = await fetch('/api/passkey/authenticate/verify', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
id: credential.id,
response: {
clientDataJSON: bufferToBase64URL(credential.response.clientDataJSON),
authenticatorData: bufferToBase64URL(credential.response.authenticatorData),
signature: bufferToBase64URL(credential.response.signature),
userHandle: credential.response.userHandle
? bufferToBase64URL(credential.response.userHandle)
: null
}
})
});
return verifyRes.json();
}
// HTML: Conditional UIμ© input
// <input type="text" autocomplete="username webauthn" />
// autocomplete="webauthn"μ΄ Passkey μλμμ±μ νΈλ¦¬κ±°
// Passkey μ§μ μ¬λΆ νμΈ
async function isPasskeySupported(): Promise<boolean> {
if (!window.PublicKeyCredential) return false;
// Platform Authenticator (Touch ID, Windows Hello λ±) μ§μ μ¬λΆ
return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
}
In product planning:
"Password fatigue is severe and our drop-off rate is high. If we adopt Passkey, users can log in with a single Touch ID and we can also block phishing. It syncs automatically, just like Google and Apple accounts."
In a technical interview:
"What is the difference between Passkey and traditional security keys?" - "Traditional FIDO2 security keys are bound only to that device, but Passkeys are synced via the cloud. They are discoverable credentials, so users can authenticate without entering a user ID."
In UX design:
"How do we make it coexist with the existing password login?" - "Use Conditional UI. If you add autocomplete='webauthn' to the email input, users who have a Passkey get it suggested through autofill, and those who don't go through the existing login flow."
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free