implementing-hardware-security-key-authentication
它能做什么
这个工具可以帮你用实体安全密钥(比如 YubiKey)或设备自带的功能(比如指纹),搭建更安全的登录系统。它可以替代密码,也可以作为密码的补充,让黑客更难入侵。
适用场景
- ✓你想用额外的安全手段保护重要账号时。
- ✓你在开发需要更安全登录方式的网站或应用时。
- ✓你想让用户只用安全密钥就能无密码登录时。
技能链接
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-hardware-security-key-authentication/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“用安全密钥为我的网站设置安全登录。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会配置服务器与安全密钥通信。它负责管理新密钥的注册,以及登录时的验证,确保只有密钥的主人才能访问。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Implementing Hardware Security Key Authentication
When to Use
- Deploying phishing-resistant multi-factor authentication (MFA) using FIDO2 hardware security keys for high-value accounts (administrators, developers, privileged users)
- Building a WebAuthn relying party server that supports both roaming authenticators (USB/NFC security keys) and platform authenticators (Windows Hello, Touch ID, Android biometrics)
- Migrating an existing password-based authentication system to support passkeys (discoverable credentials) as a primary or secondary authentication factor
- Enrolling YubiKey devices for an organization's workforce, including PIN setup, credential registration, and backup key provisioning
- Implementing passwordless authentication flows that comply with NIST SP 800-63B AAL3 (authenticator assurance level 3) requirements
Do not use without HTTPS in production (WebAuthn requires a secure origin), for systems where users cannot physically access a USB/NFC port, or as the sole authentication factor without a recovery mechanism for lost keys.
Prerequisites
- Python 3.10+ with
fido2(python-fido2 >= 2.0.0),flask, andcryptographylibraries installed - HTTPS-enabled web server (WebAuthn API requires secure context; localhost is exempt for development)
- FIDO2-compatible hardware security key (YubiKey 5 Series, SoloKeys, Titan Security Key) or platform authenticator
- Modern web browser supporting the WebAuthn API (Chrome 67+, Firefox 60+, Safari 14+, Edge 79+)
- Understanding of public key cryptography, challenge-response protocols, and HTTP session management
Workflow
Step 1: Relying Party Server Configuration
Configure the WebAuthn relying party (RP) identity and server:
- Define RP identity: Create a
PublicKeyCredentialRpEntitywith the relying party name (display name shown to users) and RP ID (the effective domain of the application). The RP ID must be a registrable domain suffix of the origin -- for example,example.comis valid forhttps://auth.example.combutother.comis not. - Initialize Fido2Server: Instantiate the
Fido2Serverclass from the python-fido2 library with the RP entity. The server handles challenge generation, attestation verification, and assertion validation. - Configure attestation preference: Set the attestation conveyance preference to control whether the server requests proof of the authenticator's identity:
none: No attestation requested (simplest, recommended for most deployments)indirect: Attestation may be provided but CA may anonymize itdirect: Full attestation chain from the authenticator's manufacturerenterprise: Device-identifying attestation for managed environments
- Session management: Configure server-side sessions to store WebAuthn state between the begin and complete phases of registration/authentication ceremonies. Use secure, httponly cookies with SameSite=Strict.
- Credential storage: Design the database schema to store credential records:
credential_id(binary),public_key(COSE key),sign_count(uint32 for clone detection),user_id,created_at,last_used,display_name, andtransports(USB, NFC, BLE, internal).
Step 2: Registration Ceremony (Credential Creation)
Implement the WebAuthn registration flow to create new credentials:
- Begin registration: Call
server.register_begin()with the user entity (PublicKeyCredentialUserEntitycontaining user ID, username, and display name), the list of existing credentials for the user (to prevent duplicate registration), and options foruser_verificationandauthenticator_attachment. - Authenticator selection criteria:
authenticator_attachment: cross-platformrestricts to roaming authenticators (USB/NFC keys)authenticator_attachment: platformrestricts to built-in authenticators (Touch ID, Windows Hello)- Omitting this field allows both types
resident_key: requiredforces creation of a discoverable credential (passkey) stored on the authenticatoruser_verification: requiredenforces PIN or biometric verification on the authenticator
- Client-side ceremony: The browser calls
navigator.credentials.create()with the options from the server. The authenticator generates a new key pair, stores the private key in its secure element, and returns the public key, credential ID, attestation object, and client data JSON.
…
常见问题
我一定需要实体安全密钥吗?
不一定。你可以使用实体密钥(比如 YubiKey),也可以使用电脑或手机自带的功能,比如 Windows Hello 或 Touch ID。
“抗钓鱼”是什么意思?
意思是这个系统很难被虚假邮件或假网站骗走。它依赖实体设备或生物特征,而黑客通常没有这些东西。
我可以在任何网站上使用吗?
它最适合你自己开发或管理的网站和应用。对于你只是使用的网站,如果对方提供了这个选项,你也可以开启。
详情
作者的原始描述
Builds a FIDO2/WebAuthn relying party server with the python-fido2 library, covering registration and authentication ceremonies, YubiKey enrollment, resident key (discoverable credential/passkey) workflows, and user verification policies. Use when implementing phishing-resistant MFA with hardware security keys, building a WebAuthn relying party, enrolling YubiKeys for a workforce, or migrating pas
热度
- GitHub 星标
- 35k
- 排名
- #8051
- 许可证
- Apache-2.0
- 更新时间
- 2026/8/31
评论
- …
同一仓库的更多技能
abusing-dpapi-for-credential-access
35k为你的 AI 智能体提供针对特定任务的现成指令,让它完成得更好、更快。
abusing-shadow-credentials-for-privesc
35k教你的 AI 智能体写出清晰、结构良好的文本。
achieving-cmmc-level-2-compliance
35k帮助你的智能体搭建符合 CMMC Level 2 合规要求的环境。它会落实安全要求,并管理必要的文档。
acquiring-disk-image-with-dd-and-dcfldd
35k帮助你的智能体创建硬盘的精确副本。这能确保调查过程中信息不丢失、不被篡改。