Module: JSON::JOSE

Extended by:
ActiveSupport::Concern
Included in:
JWE, JWT
Defined in:
lib/json/jose.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#secure_compare(a, b) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/json/jose.rb', line 35

def secure_compare(a, b)
  if ActiveSupport::SecurityUtils.respond_to?(:fixed_length_secure_compare)
    begin
      ActiveSupport::SecurityUtils.fixed_length_secure_compare(a, b)
    rescue ArgumentError
      false
    end
  else
    ActiveSupport::SecurityUtils.secure_compare(a, b)
  end
end

#with_jwk_support(key) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/json/jose.rb', line 24

def with_jwk_support(key)
  case key
  when JSON::JWK
    key.to_key
  when JSON::JWK::Set
    key[kid]&.to_key or raise JWK::Set::KidNotFound
  else
    key
  end
end