-
Notifications
You must be signed in to change notification settings - Fork 271
Refresh OAuth2 tokens automatically #8355
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: master
Are you sure you want to change the base?
Refresh OAuth2 tokens automatically #8355
Conversation
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 introduces OAuth2 token refreshing, both manually via a new oidc_child command and automatically through a new configuration option. The changes span configuration, database schema, the oidc_child tool, and the idp provider. While the overall implementation is solid, I've identified several issues, including copy-paste errors in logging that could be misleading, a critical bug in parsing input that may cause token refresh to fail, and a minor bug where a function's return value is not checked.
| sep = strchr(str, '\n'); | ||
| if (sep != NULL) { | ||
| *sep = '\0'; | ||
| } |
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.
There's a bug here when reading the refresh token from stdin if a client secret is also provided. The str variable points to the client secret at this point, so strchr(str, '\n') will always be NULL. This means a newline at the end of the refresh token will not be stripped, which can break the subsequent POST request. You should search for the newline in *token instead.
sep = strchr(*token, '\n');
if (sep != NULL) {
*sep = '\0';
}c5c8af9 to
d3ff2c7
Compare
d3ff2c7 to
e58ab81
Compare
e58ab81 to
dbc3520
Compare
This adds token refreshing functionality.
List of changes:
--refresh-access-tokentooidc_child:If set, a refresh token is read from standard input, that is then used to acquire a new set of tokens (access, id, refresh) via
refresh_tokengrant type.idp_auto_refresh:If set to
true(defaultfalse), tokens are automatically refreshed, after reaching half their lifetime.