Module: RackJwtVerifier::KeySource
- Defined in:
- lib/rack_jwt_verifier/key_source.rb
Overview
Where the verification key material comes from.
Every source answers #jwks? and #refresh!. A single-key source (Static, RemotePem) also answers #verification_key; a JWKS source answers #jwks_loader, in the shape ruby-jwt's :jwks decode option expects.
Defined Under Namespace
Classes: Remote, RemoteJwks, RemotePem, Secret, Static
Class Method Summary collapse
-
.parse_public_key(pem) ⇒ Object
Turns PEM text into an OpenSSL public key.
Class Method Details
.parse_public_key(pem) ⇒ Object
Turns PEM text into an OpenSSL public key. Accepts a bare public key (RSA, EC, Ed25519, ...) or an X.509 certificate, which is what many SSO providers serve at their ".pem" endpoints. An OpenSSL::PKey passes through.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rack_jwt_verifier/key_source.rb', line 23 def self.parse_public_key(pem) return pem if pem.is_a?(OpenSSL::PKey::PKey) text = pem.to_s if text.include?("-----BEGIN CERTIFICATE-----") OpenSSL::X509::Certificate.new(text).public_key else OpenSSL::PKey.read(text) end end |