class
JOSE::JWKS
- JOSE::JWKS
- Reference
- Object
Overview
Represents a JSON Web Key Set (JWKS, RFC 7517 §5).
A JWKS is an ordered collection of JWK objects serialised as
{"keys": [...]}. It is the standard container for publishing public
keys (e.g. OIDC /.well-known/jwks.json) and for managing key rotation.
Included Modules
- Enumerable(JOSE::JWK)
Defined in:
jose/jwks.crConstructors
-
.from_binary(json : String) : JWKS
Parses json and returns the resulting
JWKS. -
.from_map(map : Hash(String, JSON::Any)) : JWKS
Constructs a
JWKSfrom a parsed JSON map. - .new(keys : Array(JWK))
Instance Method Summary
-
#[](kid : String) : JWK
Returns the
JWKwhosekidequals kid, or raisesKeyError. -
#[]?(kid : String) : JWK | Nil
Returns the
JWKwhosekidequals kid, ornil. -
#add(jwk : JWK) : JWKS
Returns a new
JWKSwith jwk appended. -
#each(& : JWK -> _)
Yields each
JWKin order. -
#filter(&block : JWK -> Bool) : JWKS
Returns a new
JWKScontaining only keys for which the block returnstrue. - #keys : Array(JWK)
-
#merge(other : JWKS) : JWKS
Returns a new
JWKSthat is the concatenation of this set and other. -
#remove(kid : String) : JWKS
Returns a new
JWKSwith the key whosekidequals kid removed. -
#size : Int32
Returns the number of keys in the set.
-
#to_binary : String
Serialises this key set to a compact JSON string.
-
#to_map : Hash(String, JSON::Any)
Returns a JSON map of the form
{"keys" => [...]}. -
#to_public : JWKS
Returns a new
JWKScontaining only public key material for every key.
Constructor Detail
Parses json and returns the resulting JWKS.
Constructs a JWKS from a parsed JSON map.
Unknown kty values are silently ignored (RFC 7517 §5: "SHOULD ignore
JWKs … with 'kty' values that are not understood").
Instance Method Detail
Returns the JWK whose kid equals kid, or raises KeyError.
Returns a new JWKS containing only keys for which the block returns true.
Returns a new JWKS that is the concatenation of this set and other.
Returns a new JWKS with the key whose kid equals kid removed.
Returns an unchanged copy if no key matches.
Returns a new JWKS containing only public key material for every key.