dpop-adoption
Skill này làm gì
Skill này giúp nhà phát triển bảo vệ refresh token OAuth để token bị đánh cắp không thể bị người khác sử dụng. Skill dành cho các nhóm muốn bảo mật token mạnh hơn khi đăng nhập Google.
Khi nào nên dùng
- ✓Khi bạn muốn gắn refresh token OAuth của Google vào một khóa bằng DPoP.
- ✓Khi bạn cần tạo JWT chứng minh cho các yêu cầu token gửi tới endpoint token của Google.
- ✓Khi một yêu cầu token trả về thử thách use_dpop_nonce và cần thử lại.
Liên kết skill
https://github.com/google/skills/blob/main/skills/identity/dpop-adoption/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm DPoP vào chức năng đăng nhập Google của ứng dụng web, để refresh token được gắn với một khóa không thể xuất ra ngoài.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill giải thích cách tạo cặp khóa P-256 không thể trích xuất, ký các chứng minh DPoP cho mỗi yêu cầu token, và thử lại khi Google yêu cầu nonce. Skill dùng các API WebCrypto chuẩn của trình duyệt.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
DPoP Adoption & Identity Security Architecture
Demonstrating Proof-of-Possession (DPoP, RFC 9449) secures OAuth 2.0 refresh
tokens against interception and replay attacks by cryptographically binding them
to a private key held exclusively by the client. In Google's OAuth 2.0 platform,
DPoP binds the refresh token at the token endpoint, while access tokens issued
for Google APIs are standard Bearer tokens (token_type: "Bearer").
1. Core Cryptographic & Architectural Invariants
When implementing DPoP helpers or upgrading HTTP clients, you MUST adhere to the following strict security invariants:
A. Universal WebCrypto & Runtime Compatibility
- In modern ES6 JavaScript (
"type": "module"for Node 18+ and browsers), ALWAYS accessglobalThis.cryptodirectly after verifying the environment context. - NEVER import legacy CommonJS modules via
require('node:crypto')or reference browser-scopedwindow.crypto, as these cause module initialization crashes across hybrid runtimes.
B. Hardware-Backed Non-Extractable Key Persistence
- Generate an Elliptic Curve key pair on the SECP256R1 (
P-256) curve:{ name: 'ECDSA', namedCurve: 'P-256' }. - CRITICAL SECURITY GUARDRAIL: The private key MUST be configured as
non-extractable (
extractable: false). This guarantees the private key can never leave the hardware cryptographic boundary (Secure Enclave, Android KeyStore, or JS sandbox memory), thwarting XSS and dependency token theft attacks. - The public key MUST remain exportable (
extractable: true) to allow emitting JSON Web Keys (JWKs).
C. Public JWK Formatting Standards
- When exporting public keys to attach to DPoP Proof JWT headers, construct a
clean JWK dictionary containing strictly:
"kty": "EC""crv": "P-256""x": Base64URL-encoded x-coordinate without trailing equal sign padding (=)."y": Base64URL-encoded y-coordinate without trailing equal sign padding (=).
- NEVER expose private key parameters (
"d") or superfluous metadata.
D. IEEE P1363 vs. ASN.1 DER Signature Disambiguation
- DPoP Proof JWTs require raw concatenated coordinate signatures ($R \parallel S$, exactly 64 bytes for P-256) per IEEE P1363 and RFC 7518.
- WebCrypto Native Rule: In standard WebCrypto (
crypto.subtle.sign), ECDSA signatures are ALREADY emitted natively in raw IEEE P1363 format (concatenated 32-byterandsbuffers, 64 bytes total). DO NOT attempt DER-to-Raw conversion oncrypto.subtle.signoutputs, as parsing a 64-byte raw buffer as ASN.1 DER causes an immediate runtime exception (Invalid DER sequence). Directly base64url-encode the raw ArrayBuffer. - Legacy API Fallback: If and only if implementing in legacy Java/Android
(
java.security.Signature) or Node CommonJS (crypto.createSign), convert ASN.1 DER output to raw 64-byte IEEE P1363 format before base64url encoding.
E. SPA & Backend-for-Frontend (BFF) Architecture
- Secretless SPAs Limitation: Pure client-side single-page applications
(SPAs) without a backend cannot use DPoP directly with Google APIs due to
client_secretrequirements on server endpoints and browser CORS limitations on theDPoP-Nonceresponse header. - BFF Pattern: To secure SPAs with DPoP, route authorization and token
refresh requests through a Backend-for-Frontend (BFF) server-side client.
The BFF sets
access_type=offline, binds refresh tokens server-side using DPoP, and maintains secure session cookies with the frontend.
2. Implementation Rules & Mandatory Public API
When creating new modules, your module MUST explicitly export all functions below to integrate cleanly with CI/CD verification harnesses and automated probers. When inspecting or refactoring existing codebases, ensure equivalent cryptographic and RFC 9449 logic is present. Obey strict claim derivation logic in all cases:
A. DPoP Proof JWT Claim Derivation Rules (createDPoPProof)
When generating the DPoP Proof JWT in createDPoPProof:
1. JOSE Header (typ, alg, jwk):
// Header
{
"typ": "dpop+jwt",
"alg": "ES256",
"jwk": await exportPublicJWK(publicKey)
}
2. Payload Claims:
"htm": Uppercase HTTP Method ("POST"for token requests)."htu": Target URI stripped of query parameters and hash fragments using `sanitizeH
Câu hỏi thường gặp
Khóa riêng có thể bị sao chép ra ngoài không?
Không. Khóa được đặt là không thể xuất, nên không thể rời khỏi hệ thống mật mã.
Access token của Google API có thay đổi không?
Không. Access token vẫn là Bearer token chuẩn, còn DPoP chỉ gắn refresh token.
Skill hỗ trợ những môi trường nào?
Trình duyệt, WebCrypto và cấu hình module ES của Node.js.
Chi tiết
Mô tả gốc của tác giả
Implement and debug OAuth 2.0 DPoP (RFC 9449) refresh token sender-constraining for WebCrypto, Node.js ES6, and browser runtimes integrating with Google's OAuth platform. Use when configuring non-extractable asymmetric key pairs (P-256), generating DPoP Proof JWTs for authorization code exchange and token refresh, or handling 400 use_dpop_nonce challenge retry loops at oauth2.googleapis.com/token. Don't use for unconstrained OAuth 2.0 flows (where refresh tokens are not bound to a client key pair), or for Google Cloud IAM / service account authentication.
repo: google/skills
Độ phổ biến
- Sao GitHub
- 22k
- Vị trí xếp hạng
- #10354
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
finding-google-skills
22kGiúp agent của bạn tìm hướng dẫn Google phù hợp cho việc thiết lập, như hosting, cơ sở dữ liệu, lưu trữ, đăng nhập hoặc phục vụ mô hình AI.
gcloud
22kGiúp agent của bạn viết và kiểm tra các lệnh gcloud của Google Cloud, tra cứu cú pháp chính xác trước khi chạy bất cứ thứ gì để không đoán các flag.
google-cloud-recipe-auth
22kHướng dẫn agent của bạn qua quản lý danh tính và quyền truy cập của Google Cloud, gồm cách con người và dịch vụ đăng nhập và những quyền họ nhận được.
google-cloud-recipe-onboarding
22kHướng dẫn một lập trình viên mới qua các bước đầu tiên trên Google Cloud, gồm chọn dự án, liên kết thanh toán và triển khai tài nguyên đầu tiên.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.