웹사이트에 TOTP 기반 2FA를 구현하고 싶습니다. 원리와 방법을 알려주세요.
TOTP(Time-based One-Time Password) 원리와 구현:
원리:
구현 (Node.js):
// speakeasy 라이브러리 사용const speakeasy = require("speakeasy");// 시크릿 생성const secret = speakeasy.generateSecret({ name: "MyApp" });// secret.otpauth_url → QR 코드 생성// 검증const verified = speakeasy.totp.verify({ secret: secret.base32, encoding: "base32", token: userInput, window: 1 // ±30초 허용});
QR 코드는 qrcode 라이브러리로 생성하여 Google Authenticator에서 스캔하게 하면 됩니다.
댓글 2
TOTP(Time-based One-Time Password) 원리와 구현:
원리:
구현 (Node.js):
QR 코드는 qrcode 라이브러리로 생성하여 Google Authenticator에서 스캔하게 하면 됩니다.