Skip to content

Commit

Permalink
Added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mloughran committed May 7, 2010
1 parent 1476180 commit 51b03ce
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
signature
---------

Examples
========

Client example

params = {:some => 'parameters'}
token = Signature::Token.new(key, secret)
request = Signature::Request.new('POST', '/api/thing, params)
auth_hash = request.sign(token)

HTTParty.post('http://myservice/api/thing', {
:query => params.merge(auth_hash)
})

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 = Authentication::Request.new('POST', env["REQUEST_PATH"], params)
token = request.authenticate do |key|
Signature::Token.new(key, lookup_secret(key))
end

# Do whatever you need to do
end

Copyright
=========

Copyright (c) 2010 Martyn Loughran. See LICENSE for details.
17 changes: 0 additions & 17 deletions README.rdoc

This file was deleted.

0 comments on commit 51b03ce

Please sign in to comment.