Module: OmniauthOpenidFederation::Jwe
- Defined in:
- lib/omniauth_openid_federation/jwe.rb
Overview
Compact-serialization JWE helpers for nested JWTs (sign then encrypt).
Constant Summary collapse
- PARTS_COUNT =
5
Class Method Summary collapse
- .decrypt(ciphertext, private_key) ⇒ Object
- .encrypt(plaintext, public_key, alg:, enc:) ⇒ Object
- .encrypted?(token) ⇒ Boolean
Class Method Details
.decrypt(ciphertext, private_key) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/omniauth_openid_federation/jwe.rb', line 18 def self.decrypt(ciphertext, private_key) ::JWE.decrypt(ciphertext.to_s, private_key) rescue ::JWE::DecodeError, ::JWE::InvalidData, ::JWE::BadCEK, ::JWE::NotImplementedError, ArgumentError => error raise OmniauthOpenidFederation::DecryptionError, "Failed to decrypt JWE: #{error.}", error.backtrace end |
.encrypt(plaintext, public_key, alg:, enc:) ⇒ Object
14 15 16 |
# File 'lib/omniauth_openid_federation/jwe.rb', line 14 def self.encrypt(plaintext, public_key, alg:, enc:) ::JWE.encrypt(plaintext.to_s, public_key, alg: alg.to_s, enc: enc.to_s) end |
.encrypted?(token) ⇒ Boolean
10 11 12 |
# File 'lib/omniauth_openid_federation/jwe.rb', line 10 def self.encrypted?(token) token.to_s.count(".") + 1 == PARTS_COUNT end |