-
Notifications
You must be signed in to change notification settings - Fork 2
fix: DPoP should only include the path #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @mkleene, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a compliance issue in the DPoP (Demonstrating Proof-of-Possession) token generation by ensuring that the 'htu' (HTTP URI) claim within the DPoP proof contains only the path component of the requested URI, rather than the full URL. This change enhances the security and correctness of DPoP-bound access tokens. Additionally, it refactors the DPoP proof factory instantiation for better performance and includes a new test to validate the fix. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors DPoP proof generation to improve efficiency by creating the DPoPProofFactory
only once. It also changes the DPoP proof to only include the URL path, which is validated by a new test. While the refactoring is a good improvement, I've found a critical bug in the new implementation where URLs with special characters in the path would cause an exception. I've also noted a minor formatting issue in the new test file. Addressing the critical issue is important for the robustness of this fix.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the DPoP proof generation to be more efficient by creating the DPoPProofFactory
only once. It also modifies the htu
claim in the DPoP proof to only include the request URI's path, and adds a unit test to confirm this behavior. While the refactoring is a good improvement, the change to the htu
claim may not be fully compliant with RFC 9449, which could lead to interoperability issues. I've added a specific comment regarding this potential standards compliance issue.
// package-private for testing | ||
static String getDPoPProof(URL url, String method, DPoPProofFactory dpopFactory, AccessToken t) { | ||
try { | ||
URI onlyPath = new URI(url.getPath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using just the path for the htu
(HTTP URI) claim in the DPoP proof might not be compliant with RFC 9449. Section 4.2 of the RFC specifies that the htu
claim MUST be an absolute URI for requests over TLS.
The
htu
value MUST be an absolute URI, as defined in Section 4.3 of [RFC3986], unless the HTTP request is to a resource at an origin that is not deployed with a TLS server certificate, in which case thehtu
value MUST be a relative URI...
This implementation unconditionally uses a relative URI (the path), which is only valid for non-TLS requests according to the standard. While this may be necessary for a specific server implementation, it could cause DPoP validation to fail with other servers that strictly adhere to the RFC when using TLS.
If this change is intentional to support a specific backend, it would be good to document this behavior. Otherwise, you might consider making this logic conditional on the URL's protocol (e.g., http
vs. https
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto this, add a comment that this describes why we diverge from the RFC here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment stating that we are diverging from the Spec
Our implementation of DPoP uses only the path component of the HTTPS request.
This was due to implementing DPoP for GRPC, which has a murkier relationship with HTTP than
connect does.
This will bring the Java SDK into line with the rest of the SDKs and the server but it might
be better to change the server so that we accept DPoP tokens that only specify paths so that
we are more in line with the spec.