class JOSE::JWKS

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

Defined in:

jose/jwks.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_binary(json : String) : JWKS #

Parses json and returns the resulting JWKS.


[View source]
def self.from_map(map : Hash(String, JSON::Any)) : 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").


[View source]
def self.new(keys : Array(JWK)) #

[View source]

Instance Method Detail

def [](kid : String) : JWK #

Returns the JWK whose kid equals kid, or raises KeyError.


[View source]
def []?(kid : String) : JWK | Nil #

Returns the JWK whose kid equals kid, or nil.


[View source]
def add(jwk : JWK) : JWKS #

Returns a new JWKS with jwk appended.


[View source]
def each(& : JWK -> _) #

Yields each JWK in order.


[View source]
def filter(&block : JWK -> Bool) : JWKS #

Returns a new JWKS containing only keys for which the block returns true.


[View source]
def keys : Array(JWK) #

[View source]
def merge(other : JWKS) : JWKS #

Returns a new JWKS that is the concatenation of this set and other.


[View source]
def remove(kid : String) : JWKS #

Returns a new JWKS with the key whose kid equals kid removed. Returns an unchanged copy if no key matches.


[View source]
def size : Int32 #

Returns the number of keys in the set.


[View source]
def to_binary : String #

Serialises this key set to a compact JSON string.


[View source]
def to_map : Hash(String, JSON::Any) #

Returns a JSON map of the form {"keys" => [...]}.


[View source]
def to_public : JWKS #

Returns a new JWKS containing only public key material for every key.


[View source]