-
Notifications
You must be signed in to change notification settings - Fork 363
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
backend: Add refresh token logic to OAuth providers #252
Conversation
# REFRESH_AVAILABILITY_HOURS = 36 | ||
AUTH_EXPIRY_SECONDS = 60 * 2 | ||
JWT_EXPIRY_SECONDS = 30 | ||
REFRESH_AVAILABILITY_SECONDS = 15 |
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.
iiuc, this may be too small of a value? if im right in thinking, i would suggest changing the actual authentication expiry of the current access_token
to a value that is higher? IE, access_token
validity==1hr && refresh_token
validity==6-24hrs etc
i assume since this is local deployment/backend, these can be set as per the environment requirements so it may be best to go with a boilerplate approach and add some definition around the struct for easy adoption
apologies if i am missing something 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.
The commented out timings here are intended for production, while the shorter times in seconds are just for testing on this branch to make sure things are expired or refreshed properly
- "refreshable": Token is valid and within the refresh availability window. | ||
- "expired": Token is expired or blacklisted. | ||
- "invalid": Token is invalid. | ||
""" |
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.
thoughts on adding something here to prevent replays of refresh tokens?
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.
this looks great so far, thank you! :) will keep an eye out for replay prevention of existing refresh_tokens
coming, let me know if you need any other support here and happy to do local branch testing for you when ready 👍
Thank you for contributing to the Cohere Toolkit!
PR title: "area: description"
PR message: Delete this entire checklist and replace with
Add tests and docs: Please include testing and documentation for your changes
Lint and test: Run
make lint
andmake run-tests
AI Description
This PR introduces changes related to authentication and authorization, including:
get_refresh_token_params()
method in the auth strategy class.get_auth_strategy
, to retrieve the authentication strategy based on the strategy name.JWTService
class now includes arefresh_jwt
method to refresh JWT tokens.validate_authorization
function has been updated to perform additional checks on the JWT token, including verifying its structure and checking if it's blacklisted or expired.package.json
andpackage-lock.json
./test-auth
) has been added to test authorization bearer validation.