Skip to content

Conversation

@flaneur2020
Copy link
Member

@flaneur2020 flaneur2020 commented Feb 5, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

currently, we maintain a cache for the jwks keys, and use the cache to validate the jwt authentications.

however, the jwks endpoint may rotate at any time. if the client rotated with the latest jwt, we may get a key not found 401 error on jwt authentication until the next jwks refresh (by default, it's 30s).

this error can be auto-recovered after 30s, but we want to go a step further about this to make it not noticeable for users with retry.

this pr added a retry for refreshing the jwks endpoint after a key not found error. and to avoid flooding the jwks endpoint, it limited a retry_interval.

there's also a risk that the server rotates the jwks first, but the client still uses the older jwt. to mitigate this risk, this pr also buffered the earlier jwks keys in memory.

Tests

  • Unit Test

Type of change

  • New Feature (non-breaking change which adds functionality)

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Feb 5, 2025
@flaneur2020 flaneur2020 marked this pull request as ready for review February 5, 2025 11:21
@sundy-li sundy-li added this pull request to the merge queue Feb 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2025
@sundy-li sundy-li merged commit b98ad71 into databendlabs:main Feb 7, 2025
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants