Skip to content
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

fix: Make JWKS cache shared between SDK instances #27

Merged
merged 1 commit into from
Dec 23, 2022

Conversation

agis
Copy link
Member

@agis agis commented Dec 22, 2022

After 1123911 the JWKs cache wasn't working as expected, since the
middleware constructed a new SDK instance on each request. So each
request was effectively bypassing the cache, since the cache was
essentially an instance variable which was re-initialized anew every
time.

With this change, the JWKs cache is made thread-safe and shared between
all instances of the SDK.

Fixes AUTH-76

@agis agis changed the title fix: Make JWKS cache work across SDK instances fix: Make JWKS cache shared between SDK instances Dec 22, 2022
@agis agis force-pushed the AUTH-76-jwks-threadsafe-cache branch from ca96fbb to a8d5756 Compare December 22, 2022 10:21
lib/clerk/jwks_cache.rb Outdated Show resolved Hide resolved
lib/clerk/jwks_cache.rb Show resolved Hide resolved
Copy link
Contributor

@yourtallness yourtallness left a comment

Choose a reason for hiding this comment

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

:shipit:

After 1123911 the JWKs cache wasn't working as expected, since the
middleware constructed a new SDK instance on each request. So each
request was effectively bypassing the cache, since the cache was
essentially an instance variable which was re-initialized anew every
time.

With this change, the JWKs cache is made thread-safe and shared between
all instances of the SDK.

Fixes AUTH-76
@agis agis force-pushed the AUTH-76-jwks-threadsafe-cache branch from a8d5756 to a875122 Compare December 22, 2022 12:36
@agis agis merged commit 04cf608 into main Dec 23, 2022
@agis agis deleted the AUTH-76-jwks-threadsafe-cache branch December 23, 2022 08:22
@linear
Copy link

linear bot commented Dec 23, 2022

AUTH-76 Ruby SDK middleware bypasses the JWKs cache

After this change, the auth middleware essentially does not leverage the JWKS cache, since a new SDK instance is constructed per request (and the cache is essentially an instance variable).

We have to find a way to leverage some form of JWKs caching while also keeping our middleware thread-safe.

The above issue was discovered after we saw excessive amounts of requests to the BAPI JWKs endpoint from Finary.

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.

4 participants