auth0 / jwks-rsa-java

MIT License
195 stars 73 forks source link

Readme.md improvement #178

Closed msailes closed 1 year ago

msailes commented 1 year ago

Checklist

Description

In the readme.md the example shows a JwkProvider with both caching and rate limiting.

Screenshot 2023-06-19 at 11 43 41

I don't think this is valid given the current builder.

https://github.com/auth0/jwks-rsa-java/blob/7eb15a274338dfed57bef063fe36291da5d9fae0/src/main/java/com/auth0/jwk/JwkProviderBuilder.java#L174C5-L183

Reproduction

n/a

Additional context

n/a

jwks-rsa version

current

Java version

n/a

jimmyjames commented 1 year ago

👋 hi @msailes, yes that code is valid, though I can see why it would be confusing when reading the code. The various provider implementations can be chained, notice that each provider's constructor accepts a provider as a parameter:

public RateLimitedJwkProvider(JwkProvider provider, Bucket bucket) {
      this.provider = provider;
      this.bucket = bucket;
}

If you were to debug the code in the README example, and put a breakpoint on the get() method of both the GuavaCachedJwkProvider and the RateLimitJwkProvider, you'd see it first uses the cached provider to retrieve via the cache, and if not found then the rate limit provider get() will be invoked.

Hope that helps!

msailes commented 1 year ago

Thank you