Name: jwks-rsa-java
Owner: Auth0
Description: null
Created: 2016-08-03 17:50:23.0
Updated: 2018-05-04 20:25:57.0
Pushed: 2018-05-04 20:25:56.0
Homepage: null
Size: 104
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
endency>
<groupId>com.auth0</groupId>
<artifactId>jwks-rsa</artifactId>
<version>0.4.0</version>
pendency>
ile 'com.auth0:jwks-rsa:0.4.0'
The JSON Web Tokens you get from the Authorization Server include a key id header parameter (“kid”), used to uniquely identify the Key used to sign the token.
i.e.: Given the following JWT:
eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlJrSTVNakk1T1VZNU9EYzFOMFE0UXpNME9VWXpOa1ZHTVRKRE9VRXpRa0ZDT1RVM05qRTJSZyJ9.eyJpc3MiOiJodHRwczovL3NhbmRyaW5vLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1NjMyNTAxZjQ2OGYwZjE3NTZmNGNhYjAiLCJhdWQiOiJQN2JhQnRTc3JmQlhPY3A5bHlsMUZEZVh0ZmFKUzRyViIsImV4cCI6MTQ2ODk2NDkyNiwiaWF0IjoxNDY4OTI4OTI2fQ.NaNeRSDCNu522u4hcVhV65plQOiGPStgSzVW4vR0liZYQBlZ_3OKqCmHXsu28NwVHW7_KfVgOz4m3BK6eMDZk50dAKf9LQzHhiG8acZLzm5bNMU3iobSAJdRhweRht544ZJkzJ-scS1fyI4gaPS5aD3SaLRYWR0Xsb6N1HU86trnbn-XSYSspNqzIUeJjduEpPwC53V8E2r1WZXbqEHwM9_BGEeNTQ8X9NqCUvbQtnylgYR3mfJRL14JsCWNFmmamgNNHAI0uAJo84mu_03I25eVuCK0VYStLPd0XFEyMVFpk48Bg9KNWLMZ7OUGTB_uv_1u19wKYtqeTbt9m1YcPMQ
Decode it using any JWT library or tool like jwt.io and extract the kid
parameter from the Header claims.
yp": "JWT",
lg": "RS256",
id": "RkI5MjI5OUY5ODc1N0Q4QzM0OUYzNkVGMTJDOUEzQkFCOTU3NjE2Rg"
Use this kid
on any of the JwkProviders
enumerated below to obtain the signing key provided by the JWKS endpoint you've configured.
UrlJwkProvider
fetches the jwk from /.well-known/jwks.json
of the supplied domain issuer and returns a Jwk
if the kid
matches one of the registered keys.
rovider provider = new UrlJwkProvider("https://samples.auth0.com/");
jwk = provider.get("{kid of the signing key}"); //throws Exception when not found or can't get one
Also it can load jwks.json
file from any given Url (even to a local file in your filesystem).
rovider provider = new UrlJwkProvider(new URL("https://samples.auth0.com/"));
jwk = provider.get("{kid of the signing key}"); //throws Exception when not found or can't get one
GuavaCachedJwkProvider
cache the jwk in a LRU in memory cache, if the jwk is not found in the cache it will ask another provider for it and store it's result in the cache.
By default it stores 5 keys for 10 hours but these values can be changed
rovider http = new UrlJwkProvider("https://samples.auth0.com/");
rovider provider = new GuavaCachedJwkProvider(http);
jwk = provider.get("{kid of the signing key}"); //throws Exception when not found or can't get one
RateLimitJwkProvider
will limit the amounts of different signing keys to get in a given time frame.
By default the rate is limited to 10 different keys per minute but these values can be changed
rovider url = new UrlJwkProvider("https://samples.auth0.com/");
et bucket = new Bucket(10, 1, TimeUnit.MINUTES);
rovider provider = new RateLimitJwkProvider(url, bucket);
jwk = provider.get("{kid of the signing key}"); //throws Exception when not found or can't get one
To create a provider for domain https://samples.auth0.com
with cache and rate limit:
rovider provider = new JwkProviderBuilder("https://samples.auth0.com/")
.build();
jwk = provider.get("{kid of the signing key}"); //throws Exception when not found or can't get one
and specifying cache and rate limit attributes
rovider provider = new JwkProviderBuilder("https://samples.auth0.com/")
.cached(10, 24, TimeUnit.HOURS)
.rateLimited(10, 1, TimeUnit.MINUTES)
.build();
jwk = provider.get("{kid of the signing key}"); //throws Exception when not found or can't get one
Auth0 helps you to:
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
This project is licensed under the MIT license. See the LICENSE file for more info.