-
Notifications
You must be signed in to change notification settings - Fork 705
feat: add thread-safe SetExpectedState
for cross-request OAuth flows
#500
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
feat: add thread-safe SetExpectedState
for cross-request OAuth flows
#500
Conversation
Enables OAuth state management when initialization and callback steps are handled by different OAuthHandler instances, such as in web servers where separate HTTP request handlers process the auth flow stages. - Add SetExpectedState method for explicit state configuration - Add mutex protection for thread-safe expectedState access - Add comprehensive test for cross-request scenario validation
WalkthroughThread-safe synchronization was added to the Changes
Estimated code review effort2 (~15 minutes) 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧠 Learnings (1)client/transport/oauth_test.go (1)Learnt from: octo 🧰 Additional context used🧠 Learnings (1)client/transport/oauth_test.go (1)Learnt from: octo 🔇 Additional comments (7)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Description
This PR adds the
SetExpectedState
method to theOAuthHandler
, which enables OAuth state management when initialization and callback steps are handled by differentOAuthHandler
instances, such as in web servers where separate HTTP request handlers process the auth flow stages.It also protects the expectedState with a mutex to ensure thread-safe access and modification, and adds a test for the new method.
Type of Change
Checklist
Additional Information
I'm using this code inside an MCP client already, so it has some real-world usage, if that helps with justification!
Summary by CodeRabbit
Bug Fixes
Tests