-
Notifications
You must be signed in to change notification settings - Fork 16
[DAPS-1754] - bug web oauth state parameter #1755
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
base: devel
Are you sure you want to change the base?
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR replaces the hardcoded OAuth state parameter with a cryptographically secure, randomly generated hex string and updates the unit tests to verify the new behavior. Sequence diagram for OAuth consent URL generation with random state parametersequenceDiagram
participant Client
participant "api.js"
participant "window.crypto"
Client->>"api.js": getGlobusConsentURL(...)
"api.js"->>"window.crypto": generateState()
"window.crypto"-->>"api.js": random hex string
"api.js"->>Client: Calls _asyncGet with state=random hex string
Class diagram for updated getGlobusConsentURL and generateState functionsclassDiagram
class api {
+getGlobusConsentURL(a_cb, collection_id, requested_scopes, refresh_tokens, query_params, state)
+themeSave(a_theme, a_cb)
+generateState()
}
api : getGlobusConsentURL() uses generateState() for state parameter
api : generateState() returns random hex string
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- You should persist the generated state value (e.g. in sessionStorage or a closure) so you can verify it against the state returned in the OAuth callback for proper CSRF protection.
- Consider enhancing the test to call generateState multiple times and assert the outputs are unique to catch any randomness issues rather than only checking format.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You should persist the generated state value (e.g. in sessionStorage or a closure) so you can verify it against the state returned in the OAuth callback for proper CSRF protection.
- Consider enhancing the test to call generateState multiple times and assert the outputs are unique to catch any randomness issues rather than only checking format.
## Individual Comments
### Comment 1
<location> `web/test/api.test.js:71` </location>
<code_context>
+
+ // Check that state exists and matches the format generated by generateState
+ expect(options.data.state).to.be.a("string");
+ expect(options.data.state).to.match(/^[0-9a-f]{32}$/); // 16 bytes -> 32 hex chars
+
options.success({ consent_url: "http://example.com" });
</code_context>
<issue_to_address>
**suggestion (testing):** Suggest adding a test for explicitly passing a custom state value.
Please add a test to verify that getGlobusConsentURL correctly uses a custom state value when one is provided.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| // Check that state exists and matches the format generated by generateState | ||
| expect(options.data.state).to.be.a("string"); | ||
| expect(options.data.state).to.match(/^[0-9a-f]{32}$/); // 16 bytes -> 32 hex chars |
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.
suggestion (testing): Suggest adding a test for explicitly passing a custom state value.
Please add a test to verify that getGlobusConsentURL correctly uses a custom state value when one is provided.
c366e8f to
52ae762
Compare
Ticket
Description
How Has This Been Tested?
Artifacts (if appropriate):
Tasks
Summary by Sourcery
Generate a cryptographically secure random state parameter for OAuth consent URLs and update tests to validate its format.
Bug Fixes:
Enhancements:
Tests: