Skip to content

Refresh OAuth2 tokens automatically#8355

Open
eisenmann-b1 wants to merge 9 commits intoSSSD:masterfrom
eisenmann-b1:oauth2-cache-and-refresh-tokens
Open

Refresh OAuth2 tokens automatically#8355
eisenmann-b1 wants to merge 9 commits intoSSSD:masterfrom
eisenmann-b1:oauth2-cache-and-refresh-tokens

Conversation

@eisenmann-b1
Copy link
Contributor

@eisenmann-b1 eisenmann-b1 commented Jan 15, 2026

This adds token refreshing functionality.

List of changes:

  • Tokens are saved as user attrs in the cache.
    Getting the tokens from cache currently requires the use of 3rd party tools, like ldbsearch.
    If support for the systemd-userdb varlink interface is added In the future, the tokens could be exposed there as privileged user attributes.
  • Add flag --refresh-access-token to oidc_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_token grant type.
  • Add option idp_auto_refresh:
    If set to true (default false), tokens are automatically refreshed after reaching half their lifetime.

A refresh is scheduled after successful authentication.
The event is stored in a hash table with user UUID as key, so there will be at most one refresh scheduled per user.

For now, refreshes are not scheduled from cache, i.e. restarting sssd will stop refreshes.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@eisenmann-b1 eisenmann-b1 force-pushed the oauth2-cache-and-refresh-tokens branch 2 times, most recently from c5c8af9 to d3ff2c7 Compare January 15, 2026 09:36
@eisenmann-b1 eisenmann-b1 force-pushed the oauth2-cache-and-refresh-tokens branch 2 times, most recently from e58ab81 to dbc3520 Compare January 21, 2026 16:25
@eisenmann-b1 eisenmann-b1 force-pushed the oauth2-cache-and-refresh-tokens branch 5 times, most recently from 0f6575c to 1e9233f Compare February 4, 2026 08:42
@eisenmann-b1 eisenmann-b1 force-pushed the oauth2-cache-and-refresh-tokens branch 2 times, most recently from 80f541f to c7cc462 Compare February 12, 2026 10:18
@eisenmann-b1 eisenmann-b1 marked this pull request as ready for review February 12, 2026 11:14
@alexey-tikhonov alexey-tikhonov self-requested a review February 12, 2026 13:38
@alexey-tikhonov alexey-tikhonov self-assigned this Feb 12, 2026
@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Feb 12, 2026
@eisenmann-b1 eisenmann-b1 force-pushed the oauth2-cache-and-refresh-tokens branch from c7cc462 to 1f8a5f4 Compare February 12, 2026 14:01
@spoore1
Copy link
Contributor

spoore1 commented Feb 12, 2026

Hi @eisenmann-b1 ,

While @sumit-bose and @alexey-tikhonov are reviewing the code, I'd like to get an idea of how urgent this PR is. Can you let us know when you are looking to get this merged? And for what target distro you'd like to be able to start using it?

This will help us plan for testing this PR as well as potentially expanding existing tests to cover this.

Thanks,
Scott

@eisenmann-b1
Copy link
Contributor Author

Hi @spoore1,

Can you let us know when you are looking to get this merged?

Well, I just hope it makes it into 2.13 :)

And for what target distro you'd like to be able to start using it?

I am currently using Ubuntu 24.04 for testing it, but I don't think anything in here is platform-specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants