Sha256: 0eeccdf6fc382ca641241fc8626bf7d8dfa927044f2060cbe5157ccc245bc92f

Contents?: true

Size: 510 Bytes

Versions: 19

Compression:

Stored size: 510 Bytes

Contents

module Twilio
  module Util
    class RequestValidator

      def initialize(auth_token)
        @auth_token = auth_token
      end

      def validate(url, params, signature)
        expected = build_signature_for url, params
        expected == signature
      end

      def build_signature_for(url, params)
        data = url + params.sort.join
        digest = OpenSSL::Digest::Digest.new('sha1')
        Base64.encode64(OpenSSL::HMAC.digest(digest, @auth_token, data)).strip
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
twilio-ruby-3.11.4 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.11.3 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.11.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.11.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.10.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.10.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.9.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.8.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.7.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.7.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.6.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.5.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.5.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.4.2 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.4.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.4.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.3.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.3.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.2.0 lib/twilio-ruby/util/request_validator.rb