Project

uri_signer

0.0
No commit activity in last 3 years
No release in over 3 years
Handle the generation of a URI signature for API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

UriSigner

  • Version
  • Climate
  • Build
  • Dependencies
  • Coverage
  • License

The KISSmetrics API provides an authentication realm of a digital signature of the request. This gem helps to put the pieces together and construct the URL with the signature.

This is used within the core KISSmetrics Ruby API Wrapper to help abstract the building of the requests.

Using this without a wrapper will require you to manually provide your client_secret.

Installation

Add this line to your application's Gemfile:

gem 'uri_signer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install uri_signer

Usage

At any point, you can use the reload_yard command to view the documentation of the provided code. The basic usage is:

http_method = 'get'
uri = "https://api.example.com/v1/endpoint.json?page=2&per_page=12&order=name:desc&select=id,name"
secret = "my_secret"

signer = UriSigner::Signer.new(http_method, uri, secret)
=> #<UriSigner::Signer:0x007fd84ebf5490 @http_method="get", @uri="https://api.example.com/v1/endpoint.json?page=2&per_page=12&order=name:desc&select=id,name", @secret="my_secret">

signer.http_method
=> "GET"

signer.uri
=> "https://api.example.com/v1/endpoint.json?page=2&per_page=12&order=name:desc&select=id,name"

signer.signature
=> "Itt0xvD1ZAHHXP2ItX6PeXMfjOovr8MVgbpoXpq3158%3D"

signer.uri_with_signature
=> "https://api.example.com/v1/endpoint.json?page=2&per_page=12&order=name:desc&select=id,name&_signature=Itt0xvD1ZAHHXP2ItX6PeXMfjOovr8MVgbpoXpq3158%3D"

signer.valid?('Itt0xvD1ZAHHXP2ItX6PeXMfjOovr8MVgbpoXpq3158%3D')
=> true

signer.valid?('invalid')
=> false

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request