You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-32Lines changed: 57 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -569,45 +569,64 @@ end
569
569
570
570
### JSON Web Key (JWK)
571
571
572
-
JWK is a JSON structure representing a cryptographic key. Currently only supports RSA, EC and HMAC keys. The `jwks` option can be given as a lambda that evaluates every time a kid is resolved.
572
+
JWK is a JSON structure representing a cryptographic key. This gem currently supports RSA, EC and HMAC keys.
573
573
574
-
If the kid is not found from the given set the loader will be called a second time with the `kid_not_found` option set to `true`. The application can choose to implement some kind of JWK cache invalidation or other mechanism to handle such cases.
# The jwk loader would fetch the set of JWKs from a trusted source,
584
-
# to avoid malicious requests triggering cache invalidations there needs to be some kind of grace time or other logic for determining the validity of the invalidation.
585
-
# This example only allows cache invalidations every 5 minutes.
586
-
jwk_loader =->(options) do
587
-
if options[:kid_not_found] &&@cache_last_update<Time.now.to_i -300
588
-
logger.info("Invalidating JWK cache. #{options[:kid]} not found from previous cache")
The key id (kid) generation in the gem is a custom algorithm and not based on any standards. To use a standardized JWK thumbprint (RFC 7638) as the kid for JWKs a generator type can be specified in the global configuration or can be given to the JWK instance on initialization.
664
+
The key id (kid) generation in the gem is a custom algorithm and not based on any standards.
665
+
To use a standardized JWK thumbprint (RFC 7638) as the kid for JWKs a generator type can be specified in the global configuration
666
+
or can be given to the JWK instance on initialization.
expect{JWT.decode(token,nil,true,{algorithms: ['RS512'],jwks: jwk_loader})}.toraise_error(JWT::DecodeError,'Could not find public key for kid yet-another-new-kid')
370
380
end
371
381
end
372
382
@@ -386,6 +396,11 @@
386
396
# Export as OpenSSL key
387
397
_public_key=jwk.public_key
388
398
_private_key=jwk.keypairifjwk.private?
399
+
400
+
# You can also import and export entire JSON Web Key Sets
0 commit comments