Sha256: ab843a13bf9414e28e357d8f6010b71972286a5a2dd65325d80ffd9d75c53b22

Contents?: true

Size: 1.3 KB

Versions: 44

Compression:

Stored size: 1.3 KB

Contents

signature
=========

Examples
--------

Client example

    params = {:some => 'parameters'}
    token = Signature::Token.new('my_key', 'my_secret')
    request = Signature::Request.new('POST', '/api/thing', params)
    auth_hash = request.sign(token)
    query_params = params.merge(auth_hash)
    
    HTTParty.post('http://myservice/api/thing', {
      :query => query_params
    })

`query_params` looks like:

    {
      :some => "parameters",
      :auth_timestamp => 1273231888,
      :auth_signature => "28b6bb0f242f71064916fad6ae463fe91f5adc302222dfc02c348ae1941eaf80",
      :auth_version => "1.0",
      :auth_key => "my_key"
    }

Server example (sinatra)

    error Signature::AuthenticationError do |controller|
      error = controller.env["sinatra.error"]
      halt 401, "401 UNAUTHORIZED: #{error.message}\n"
    end

    post '/api/thing' do
      request = Signature::Request.new('POST', env["REQUEST_PATH"], params)
      # This will raise a Signature::AuthenticationError if request does not authenticate
      token = request.authenticate do |key|
        Signature::Token.new(key, lookup_secret(key))
      end

      # Do whatever you need to do
    end

Developing
----------

    bundle
    bundle exec rspec spec/*_spec.rb

Copyright
---------

Copyright (c) 2010 Martyn Loughran. See LICENSE for details.

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
scout-5.7.1 vendor/signature/README.md
scout-5.7.0 vendor/signature/README.md
scout-5.7.0.pre vendor/signature/README.md
scout-5.6.11 vendor/signature/README.md
scout-5.6.10 vendor/signature/README.md
scout-5.6.9 vendor/signature/README.md
scout-5.6.8 vendor/signature/README.md
scout-5.6.8.pre vendor/signature/README.md
scout-5.6.7 vendor/signature/README.md
scout-5.6.7.pre vendor/signature/README.md
scout-5.6.6 vendor/signature/README.md
scout-5.6.6.pre vendor/signature/README.md
scout-5.6.5 vendor/signature/README.md
scout-5.6.5.pre vendor/signature/README.md
scout-5.6.4 vendor/signature/README.md
scout-5.6.3.pre vendor/signature/README.md
scout-5.6.2 vendor/signature/README.md
scout-5.6.2.pre vendor/signature/README.md
scout-5.6.1 vendor/signature/README.md
scout-5.6.0 vendor/signature/README.md