Module: JOSE
- Defined in:
- lib/jose.rb,
lib/jose/jwa.rb,
lib/jose/jwe.rb,
lib/jose/jwk.rb,
lib/jose/jws.rb,
lib/jose/jwt.rb,
lib/jose/version.rb
Overview
JOSE stands for JSON Object Signing and Encryption which is a is a set of standards established by the JOSE Working Group.
JOSE is split into 5 main components:
- JOSE::JWA - JSON Web Algorithms (JWA) RFC 7518
- JOSE::JWE - JSON Web Encryption (JWE) RFC 7516
- JOSE::JWK - JSON Web Key (JWK) RFC 7517
- JOSE::JWS - JSON Web Signature (JWS) RFC 7515
- JOSE::JWT - JSON Web Token (JWT) RFC 7519
Additional specifications and drafts implemented:
- JSON Web Key (JWK) Thumbprint RFC 7638
- JWS Unencoded Payload Option draft-ietf-jose-jws-signing-input-options-04
Defined Under Namespace
Modules: JWA Classes: EncryptedBinary, EncryptedMap, JWE, JWK, JWS, JWT, Map, SignedBinary, SignedMap
Constant Summary collapse
- VERSION =
"1.2.0"
Class Method Summary collapse
-
.crypto_fallback ⇒ Boolean
Gets the current Cryptographic Algorithm Fallback state, defaults to
false
. -
.crypto_fallback=(boolean) ⇒ Boolean
Sets the current Cryptographic Algorithm Fallback state.
-
.curve25519_module ⇒ Module
Gets the current Curve25519 module used by JOSE::JWA::Curve25519, see JOSE.curve25519_module= for default.
-
.curve25519_module=(mod) ⇒ Module
Sets the current Curve25519 module used by JOSE::JWA::Curve25519.
-
.curve448_module ⇒ Module
Gets the current Curve448 module used by JOSE::JWA::Curve448, see JOSE.curve25519_module= for default.
-
.curve448_module=(mod) ⇒ Module
Sets the current Curve448 module used by JOSE::JWA::Curve448.
-
.decode(binary) ⇒ Object
Decode JSON binary to a term.
-
.encode(term) ⇒ Object
Encode a term to JSON binary and sorts
Hash
and JOSE::Map keys. -
.unsecured_signing ⇒ Boolean
Gets the current Unsecured Signing state, defaults to
false
. -
.unsecured_signing=(boolean) ⇒ Boolean
Sets the current Unsecured Signing state.
-
.urlsafe_decode64(binary) ⇒ String
Returns the Base64Url decoded version of
binary
without padding. -
.urlsafe_encode64(binary) ⇒ String
Returns the Base64Url encoded version of
binary
without padding. -
.xchacha20poly1305_module ⇒ Module
Gets the current XChaCha20-Poly1305 module used by JOSE::JWA::XChaCha20Poly1305, see JOSE.xchacha20poly1305_module= for default.
-
.xchacha20poly1305_module=(mod) ⇒ Module
Sets the current XChaCha20Poly1305 module used by JOSE::JWA::XChaCha20Poly1305.
Class Method Details
.crypto_fallback ⇒ Boolean
Gets the current Cryptographic Algorithm Fallback state, defaults to false
.
39 40 41 |
# File 'lib/jose.rb', line 39 def self.crypto_fallback return @__crypto_fallback__ end |
.crypto_fallback=(boolean) ⇒ Boolean
Sets the current Cryptographic Algorithm Fallback state.
46 47 48 49 50 51 52 53 |
# File 'lib/jose.rb', line 46 def self.crypto_fallback=(boolean) boolean = !!boolean MUTEX.synchronize { @__crypto_fallback__ = boolean __config_change__ } return boolean end |
.curve25519_module ⇒ Module
Gets the current Curve25519 module used by JOSE::JWA::Curve25519, see curve25519_module= for default.
57 58 59 |
# File 'lib/jose.rb', line 57 def self.curve25519_module return JOSE::JWA::Curve25519.__implementation__ end |
.curve25519_module=(mod) ⇒ Module
Sets the current Curve25519 module used by JOSE::JWA::Curve25519.
Currently supported Curve25519 modules (first found is used as default):
RbNaCl
- JOSE::JWA::Curve25519_Ruby - only supported when crypto_fallback is
true
Additional modules that implement the functions specified in JOSE::JWA::Curve25519 may also be used.
71 72 73 |
# File 'lib/jose.rb', line 71 def self.curve25519_module=(mod) JOSE::JWA::Curve25519.__implementation__ = mod end |
.curve448_module ⇒ Module
Gets the current Curve448 module used by JOSE::JWA::Curve448, see curve25519_module= for default.
77 78 79 |
# File 'lib/jose.rb', line 77 def self.curve448_module return JOSE::JWA::Curve448.__implementation__ end |
.curve448_module=(mod) ⇒ Module
Sets the current Curve448 module used by JOSE::JWA::Curve448.
Currently supported Curve448 modules (first found is used as default):
- JOSE::JWA::Curve448_Ruby - only supported when crypto_fallback is
true
Additional modules that implement the functions specified in JOSE::JWA::Curve448 may also be used.
90 91 92 |
# File 'lib/jose.rb', line 90 def self.curve448_module=(mod) JOSE::JWA::Curve448.__implementation__ = mod end |
.decode(binary) ⇒ Object
Decode JSON binary to a term.
97 98 99 |
# File 'lib/jose.rb', line 97 def self.decode(binary) return JSON.load(binary) end |
.encode(term) ⇒ Object
Encode a term to JSON binary and sorts Hash
and JOSE::Map keys.
104 105 106 |
# File 'lib/jose.rb', line 104 def self.encode(term) return JSON.dump(sort_maps(term)) end |
.unsecured_signing ⇒ Boolean
Gets the current Unsecured Signing state, defaults to false
.
110 111 112 |
# File 'lib/jose.rb', line 110 def self.unsecured_signing return @__unsecured_signing__ end |
.unsecured_signing=(boolean) ⇒ Boolean
Sets the current Unsecured Signing state.
Enables/disables the "none"
algorithm used for signing and verifying.
See Critical vulnerabilities in JSON Web Token libraries for more information.
121 122 123 124 125 126 127 128 |
# File 'lib/jose.rb', line 121 def self.unsecured_signing=(boolean) boolean = !!boolean MUTEX.synchronize { @__unsecured_signing__ = boolean __config_change__ } return boolean end |
.urlsafe_decode64(binary) ⇒ String
Returns the Base64Url decoded version of binary
without padding.
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/jose.rb', line 133 def self.urlsafe_decode64(binary) binary = binary.tr('-_', '+/') case binary.bytesize % 4 when 2 binary += '==' when 3 binary += '=' end return Base64.decode64(binary) end |
.urlsafe_encode64(binary) ⇒ String
Returns the Base64Url encoded version of binary
without padding.
147 148 149 |
# File 'lib/jose.rb', line 147 def self.urlsafe_encode64(binary) return Base64.strict_encode64(binary).tr('+/', '-_').delete('=') end |
.xchacha20poly1305_module ⇒ Module
Gets the current XChaCha20-Poly1305 module used by JOSE::JWA::XChaCha20Poly1305, see xchacha20poly1305_module= for default.
153 154 155 |
# File 'lib/jose.rb', line 153 def self.xchacha20poly1305_module return JOSE::JWA::XChaCha20Poly1305.__implementation__ end |
.xchacha20poly1305_module=(mod) ⇒ Module
Sets the current XChaCha20Poly1305 module used by JOSE::JWA::XChaCha20Poly1305.
Currently supported XChaCha20Poly1305 modules (first found is used as default):
Additional modules that implement the functions specified in JOSE::JWA::XChaCha20Poly1305 may also be used.
166 167 168 |
# File 'lib/jose.rb', line 166 def self.xchacha20poly1305_module=(mod) JOSE::JWA::XChaCha20Poly1305.__implementation__ = mod end |