Class: Inferno::DSL::JWKS
- Inherits:
-
Object
- Object
- Inferno::DSL::JWKS
- Defined in:
- lib/inferno/dsl/jwks.rb
Overview
The JWKS class provides methods to handle JSON Web Key Sets (JWKS) within Inferno.
This class allows users to fetch, parse, and manage JWKS, ensuring that the necessary keys for verifying tokens are available.
Class Method Summary collapse
-
.jwks(user_jwks: nil) ⇒ JWT::JWK::Set
Parses and returns a
JWT::JWK::Set
object from the provided JWKS string or from the file located at the JWKS path. -
.jwks_json ⇒ String
Returns a formatted JSON string of the JWKS public keys that are used for verification.
Class Method Details
.jwks(user_jwks: nil) ⇒ JWT::JWK::Set
Parses and returns a JWT::JWK::Set
object from the provided JWKS string
or from the file located at the JWKS path. If a user-provided JWKS string
is not available, it reads the JWKS from the file.
71 72 73 |
# File 'lib/inferno/dsl/jwks.rb', line 71 def jwks(user_jwks: nil) JWT::JWK::Set.new(JSON.parse(user_jwks.presence || default_jwks_json)) end |
.jwks_json ⇒ String
Returns a formatted JSON string of the JWKS public keys that are used for verification. This method filters out keys that do not have the ‘verify’ operation.
18 19 20 21 22 23 |
# File 'lib/inferno/dsl/jwks.rb', line 18 def jwks_json @jwks_json ||= JSON.pretty_generate( { keys: jwks.export[:keys].select { |key| key[:key_ops]&.include?('verify') } } ) end |