Class: UrlSigner::Verifier

Inherits:
Base
  • Object
show all
Defined in:
lib/url_signer/verifier.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Base

#hash_method, #key, #url

Instance Method Summary collapse

Methods inherited from Base

#initialize, #signature

Constructor Details

This class inherits a constructor from UrlSigner::Base

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/url_signer/verifier.rb', line 6

def valid?
  return false unless signed?

  # extract signature from params
  remaining_params = params.dup
  provided_signature = remaining_params.delete('signature')

  # recompute the signature using the secret key
  recomputed_signature = compute_signature(url.host, url.path, remaining_params)

  safe_compare(provided_signature, recomputed_signature)
end