Module: JWT

Extended by:
Configuration
Defined in:
lib/jwt.rb,
lib/jwt/jwa.rb,
lib/jwt/jwk.rb,
lib/jwt/json.rb,
lib/jwt/error.rb,
lib/jwt/base64.rb,
lib/jwt/claims.rb,
lib/jwt/decode.rb,
lib/jwt/encode.rb,
lib/jwt/jwa/ps.rb,
lib/jwt/jwk/ec.rb,
lib/jwt/jwa/rsa.rb,
lib/jwt/jwk/rsa.rb,
lib/jwt/jwk/set.rb,
lib/jwt/version.rb,
lib/jwt/jwa/hmac.rb,
lib/jwt/jwa/none.rb,
lib/jwt/jwk/hmac.rb,
lib/jwt/jwa/ecdsa.rb,
lib/jwt/jwa/eddsa.rb,
lib/jwt/jwa/wrapper.rb,
lib/jwt/deprecations.rb,
lib/jwt/jwk/key_base.rb,
lib/jwt/claims/issuer.rb,
lib/jwt/claims/jwt_id.rb,
lib/jwt/configuration.rb,
lib/jwt/claims/numeric.rb,
lib/jwt/claims/subject.rb,
lib/jwt/jwk/key_finder.rb,
lib/jwt/jwk/okp_rbnacl.rb,
lib/jwt/jwk/thumbprint.rb,
lib/jwt/x5c_key_finder.rb,
lib/jwt/claims/audience.rb,
lib/jwt/claims/required.rb,
lib/jwt/jwa/hmac_rbnacl.rb,
lib/jwt/jwa/unsupported.rb,
lib/jwt/claims/issued_at.rb,
lib/jwt/claims/expiration.rb,
lib/jwt/claims/not_before.rb,
lib/jwt/jwa/hmac_rbnacl_fixed.rb,
lib/jwt/jwa/signing_algorithm.rb,
lib/jwt/jwk/kid_as_key_digest.rb,
lib/jwt/configuration/container.rb,
lib/jwt/configuration/jwk_configuration.rb,
lib/jwt/configuration/decode_configuration.rb

Overview

Moments version builder module

Defined Under Namespace

Modules: Claims, Configuration, Deprecations, JWA, JWK, VERSION Classes: Base64, Base64DecodeError, Decode, DecodeError, Encode, EncodeError, ExpiredSignature, ImmatureSignature, IncorrectAlgorithm, InvalidAudError, InvalidIatError, InvalidIssuerError, InvalidJtiError, InvalidPayload, InvalidSubError, JSON, JWKError, MissingRequiredClaim, RequiredDependencyError, UnsupportedEcdsaCurve, VerificationError, X5cKeyFinder

Class Method Summary collapse

Methods included from Configuration

configuration, configure

Class Method Details

.decode(jwt, key = nil, verify = true, options = {}, &keyfinder) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



30
31
32
33
34
# File 'lib/jwt.rb', line 30

def decode(jwt, key = nil, verify = true, options = {}, &keyfinder) # rubocop:disable Style/OptionalBooleanParameter
  Deprecations.context do
    Decode.new(jwt, key, verify, configuration.decode.to_h.merge(options), &keyfinder).decode_segments
  end
end

.encode(payload, key, algorithm = 'HS256', header_fields = {}) ⇒ Object



23
24
25
26
27
28
# File 'lib/jwt.rb', line 23

def encode(payload, key, algorithm = 'HS256', header_fields = {})
  Encode.new(payload: payload,
             key: key,
             algorithm: algorithm,
             headers: header_fields).segments
end

.gem_versionObject



5
6
7
# File 'lib/jwt/version.rb', line 5

def self.gem_version
  Gem::Version.new VERSION::STRING
end

.openssl_3?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/jwt/version.rb', line 24

def self.openssl_3?
  return false if OpenSSL::OPENSSL_VERSION.include?('LibreSSL')

  true if 3 * 0x10000000 <= OpenSSL::OPENSSL_VERSION_NUMBER
end

.openssl_3_hmac_empty_key_regression?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/jwt/version.rb', line 38

def self.openssl_3_hmac_empty_key_regression?
  openssl_3? && openssl_version <= ::Gem::Version.new('3.0.0')
end

.openssl_versionObject



42
43
44
# File 'lib/jwt/version.rb', line 42

def self.openssl_version
  @openssl_version ||= ::Gem::Version.new(OpenSSL::VERSION)
end

.rbnacl?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/jwt/version.rb', line 30

def self.rbnacl?
  defined?(::RbNaCl)
end

.rbnacl_6_or_greater?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/jwt/version.rb', line 34

def self.rbnacl_6_or_greater?
  rbnacl? && ::Gem::Version.new(::RbNaCl::VERSION) >= ::Gem::Version.new('6.0.0')
end