Skip to content

feat(rest): implement OAuth2 token auto-refresh for REST catalog#646

Open
lishuxu wants to merge 2 commits intoapache:mainfrom
lishuxu:feature/oauth_2
Open

feat(rest): implement OAuth2 token auto-refresh for REST catalog#646
lishuxu wants to merge 2 commits intoapache:mainfrom
lishuxu:feature/oauth_2

Conversation

@lishuxu
Copy link
Copy Markdown
Contributor

@lishuxu lishuxu commented May 9, 2026

Replace the MakeOAuth2 stub with a full OAuth2AuthSession that
automatically refreshes tokens before expiration using the
client_credentials grant.

Key components:
- OAuth2AuthSession: manages token lifecycle with shared_mutex for concurrent read access and background refresh via scheduler
- TokenRefreshScheduler: process-global singleton with a single worker thread that fires delayed refresh callbacks
- ExpiresAtMillis: JWT exp claim parser for determining token expiry when expires_in is not provided in the token response
- Base64Decode/Base64UrlDecode added to TransformUtil as public utilities

shuxu.li added 2 commits May 9, 2026 09:46
    Replace the MakeOAuth2 stub with a full OAuth2AuthSession that
    automatically refreshes tokens before expiration using the
    client_credentials grant.

    Key components:
    - OAuth2AuthSession: manages token lifecycle with shared_mutex for
      concurrent read access and background refresh via scheduler
    - TokenRefreshScheduler: process-global singleton with a single worker
      thread that fires delayed refresh callbacks
    - ExpiresAtMillis: JWT exp claim parser for determining token expiry
      when expires_in is not provided in the token response
    - Base64Decode/Base64UrlDecode added to TransformUtil as public utilities
Replace the MakeOAuth2 stub with a full OAuth2AuthSession that
automatically refreshes tokens before expiration using the
client_credentials grant.

Key components:
- OAuth2AuthSession: manages token lifecycle with shared_mutex for concurrent read access and background refresh via scheduler
- TokenRefreshScheduler: process-global singleton with a single worker thread that fires delayed refresh callbacks
- ExpiresAtMillis: JWT exp claim parser for determining token expiry when expires_in is not provided in the token response
- Base64Decode/Base64UrlDecode added to TransformUtil as public utilities
'dependencies': [iceberg_rest_dep],
},
'polaris_oauth2_integration_test': {
'sources': files('polaris_oauth2_test.cc'),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you may have missed adding this file to the commit.


namespace {

// Shared base64 decode logic. The decode table maps ASCII char → 6-bit value.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
// Shared base64 decode logic. The decode table maps ASCII char 6-bit value.
// Shared base64 decode logic. The decode table maps ASCII char -> 6-bit value.

for (char c : input) {
uint8_t val = table[static_cast<uint8_t>(c)];
if (val == 0xFF) {
return {}; // Invalid character
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return Resultstd::string so that we know input is just empty or invalid?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants