Sha256: cb2bdc07424a006b224c908b5e6e42cd4f86260f85f1f578b8c7e08406806e7a

Contents?: true

Size: 502 Bytes

Versions: 5

Compression:

Stored size: 502 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.new('sha1')
        Base64.encode64(OpenSSL::HMAC.digest(digest, @auth_token, data)).strip
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
twilio-ruby-3.12.2 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.12.1 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.12.0 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.11.6 lib/twilio-ruby/util/request_validator.rb
twilio-ruby-3.11.5 lib/twilio-ruby/util/request_validator.rb