Home

Awesome

net-http-auth-hmac

HMAC

Signs a request with given token to be validated in the backend.

Usage

Sending a request

uri = URI.parse("http://google.com/")
http = Net::HTTP.new(uri.host, uri.port)

signer = Net::HTTP::Auth::HMAC.new('super_secret_secret')
request = Net::HTTP::Post.new('/somewhere')
request.body = 'super_secret_value=42'

signed_request = signer.sign_request(request)
http.request request

Receiving a request

signer = Net::HTTP::Auth::HMAC.new('super_secret_secret')
unsigned_request = signer.unsign_request(request)
request.body

Installation

gem install net-http-auth-hmac