-
Notifications
You must be signed in to change notification settings - Fork 19
Add the access token to the user session. #191
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: develop
Are you sure you want to change the base?
Conversation
…ke API calls elsewhere in the app without requiring additional client authentication flows.
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant OAuth as AbstractOAuth::setToken
participant Sess as Session Manager
App->>OAuth: setToken(token)
OAuth->>OAuth: Assign token to class property
OAuth->>Sess: Initialize session (if not already) and store token ('oauth_token')
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ 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:
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 (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/Libraries/Basic/AbstractOAuth.php (2)
31-33
: Good addition for maintaining token availability across requestsThis change successfully implements the PR objective of adding the access token to the user session, making it available for API calls throughout the application without requiring re-authentication.
A few considerations:
- The comment acknowledges that the session might not be initialized yet. Consider adding error handling to gracefully manage cases where session initialization fails.
- For security, you might want to consider token lifetime management since storing tokens in sessions can present security risks if sessions are long-lived.
Consider adding error handling for session availability:
protected function setToken(string $token): void { $this->token = $token; - $session = session(); // session helper is required already by CI Shield, but might not be initialized yet - $session->set('oauth_token', $token); + try { + $session = session(); // session helper is required already by CI Shield, but might not be initialized yet + $session->set('oauth_token', $token); + } catch (\Exception $e) { + // Log error or handle gracefully + log_message('error', 'Failed to store OAuth token in session: ' . $e->getMessage()); + } }
28-34
: Documentation needed for this featureIn the PR description, you mentioned wanting to document this feature. Since this token is now available in the session, users of your library should be informed about:
- The session key used (
'oauth_token'
)- How to retrieve and use this token for API calls
- Security considerations when using the stored token
Consider adding this information to the class documentation or to a dedicated documentation file.
Would you like me to suggest documentation text that explains how to use this new session-stored token?
Add the access token to the user session so that it can be used to make API calls to the same provider elsewhere in the app without requiring additional client authentication flows.
I spent a lot of time looking for the right place to add this. Please suggest if there is a better place.
I also wanted to add a note to the docs highlighting this feature, but couldn't find a smart place for it. Thoughts?
Summary by CodeRabbit