DPoP(持有证明)
了解 DPoP,这是一种通过密码学方式将访问令牌绑定到客户端的机制,可增强令牌安全性并防止令牌被窃取。
DPoP(持有证明) 是 CoddyKit 上的免费 OAuth2 & OpenID Connect Deep Dive 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 OAuth2 & OpenID Connect Deep Dive 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 OAuth2 & OpenID Connect Deep Dive 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
What is DPoP?
Welcome! Today we'll explore DPoP, which stands for Demonstrating Proof-of-Possession. It's a crucial security enhancement for OAuth2 and OpenID Connect.
DPoP helps prevent a major security risk: stolen access tokens. It ensures that only the legitimate client (the app) can use an access token.
The Token Theft Problem
Imagine an attacker steals an access token. Without DPoP, they could use this token to access your protected resources, impersonating the legitimate client.
This 'token exfiltration' is a significant vulnerability. Standard bearer tokens don't inherently prevent this because anyone who 'bears' (possesses) the token can use it.
How DPoP Solves It
DPoP cryptographically binds an access token to a specific client's private key. Think of it like a digital signature that only the rightful client can produce.
Here's the core idea:
- The client generates a unique key pair.
- The public key is linked to the access token.
- The client 'proves possession' of the private key with every request.
Client's Secret Key Pair
The process starts with the client application generating an asymmetric cryptographic key pair. This means it creates both a private key and a public key.
- The private key is kept secret by the client.
- The public key can be shared without compromising security.
This key pair is unique to the client session or instance.
Requesting a DPoP Token
When the client requests an access token from the Authorization Server, it includes a special header called DPoP in the request.
This DPoP header contains a JSON Web Token (JWT) signed by the client's private key. This JWT includes a hash of the client's public key.
The DPoP JWT & jkt Claim
The JWT in the DPoP header is the 'proof of possession'. It contains several claims:
jkt: The JSON Web Key Thumbprint of the client's public key.htm: The HTTP method of the request (e.g., GET, POST).htu: The HTTP URL of the request.iat: Issued At time, preventing replay.
The Authorization Server validates this JWT and binds the jkt to the issued access token.
Using a DPoP-Bound Token
Once the client receives a DPoP-bound access token, it uses it to access protected resources on the Resource Server.
With every request to the Resource Server, the client must again send a new DPoP header containing a fresh JWT, signed by its private key, matching the current request's htm and htu.
Resource Server Validation
The Resource Server performs critical checks:
- It verifies the signature of the DPoP JWT using the public key derived from its
jktclaim. - It ensures the
jktin the DPoP JWT matches thejktstored within the access token itself. - It checks that the
htmandhtuclaims in the DPoP JWT match the actual HTTP request.
If any check fails, access is denied. This ensures only the client possessing the private key can use the token.
DPoP vs. Mutual TLS (mTLS)
You might wonder about Mutual TLS (mTLS). Both DPoP and mTLS bind tokens to a client, but they operate at different layers:
- mTLS: Binds at the TLS (transport) layer using client certificates.
- DPoP: Binds at the application layer using cryptographic proofs in HTTP headers.
DPoP is often more flexible and easier to implement for a wider range of client types (especially public clients like mobile apps) compared to mTLS.
Test Your DPoP Knowledge
Which of the following are key benefits of using DPoP in OAuth2/OIDC implementations?
DPoP: A Stronger Bind
Congratulations! You've learned about DPoP, a powerful security mechanism.
DPoP enhances OAuth2 and OIDC by cryptographically binding access tokens to the client's private key, effectively preventing token exfiltration and making stolen tokens unusable by attackers.
This 'proof of possession' significantly strengthens the security posture of your applications by ensuring only the legitimate client can use its access tokens.
常见问题解答
「DPoP(持有证明)」课时是免费的吗?
是的 — 「DPoP(持有证明)」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 OAuth2 & OpenID Connect Deep Dive 课程的其余内容,请升级到 CoddyKit PRO。 OAuth2 & OpenID Connect Deep Dive 课程共包含 4 节课。
「DPoP(持有证明)」这节课中我会学到什么?
了解 DPoP,这是一种通过密码学方式将访问令牌绑定到客户端的机制,可增强令牌安全性并防止令牌被窃取。 你通过在浏览器中直接运行的动手代码来练习 OAuth2 & OpenID Connect Deep Dive,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 OAuth2 & OpenID Connect Deep Dive 需要有经验吗?
无需任何先前经验。CoddyKit 上的 OAuth2 & OpenID Connect Deep Dive 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。
「DPoP(持有证明)」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 OAuth2 & OpenID Connect Deep Dive 课中编写并运行代码吗?
能。每节 OAuth2 & OpenID Connect Deep Dive 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- FAPI 与金融级 API
- DPoP(持有证明)
- 持续访问评估协议(CAEP)
- 推送授权请求(PAR)