Sha256: 9286c26dde7f7c7f6239054820aa3e721dcf520eead9a52087d09b8d6559c06d

Contents?: true

Size: 1.46 KB

Versions: 47

Compression:

Stored size: 1.46 KB

Contents

signature
=========

[![Build Status](https://secure.travis-ci.org/mloughran/signature.png?branch=master)](http://travis-ci.org/mloughran/signature)

Examples
--------

Client example

```ruby
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:

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

```
Server example (sinatra)

```ruby
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

Please see the travis status for a list of rubies tested against

Copyright
---------

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

Version data entries

47 entries across 47 versions & 3 rubygems

Version Path
scout-5.9.13 vendor/signature/README.md
scout-5.9.12 vendor/signature/README.md
scout-5.9.11 vendor/signature/README.md
scout-5.9.10.pre vendor/signature/README.md
scout-5.9.8 vendor/signature/README.md
scout-5.9.7.2.pre vendor/signature/README.md
scout-5.9.8.pre vendor/signature/README.md
scout-5.9.7.1 vendor/signature/README.md
scout-5.9.7.pre vendor/signature/README.md
scout-5.9.5 vendor/signature/README.md
scout-5.9.4 vendor/signature/README.md
scout-5.9.4.pre vendor/signature/README.md
signature-acd-0.1.14 README.md
signature-acd-0.1.13 README.md
signature-acd-0.1.12 README.md
signature-acd-0.1.11 README.md
signature-acd-0.1.10 README.md
signature-acd-0.1.9 README.md
scout-5.9.3 vendor/signature/README.md
scout-5.9.2 vendor/signature/README.md