Project

mojo_auth

0.0
No commit activity in last 3 years
No release in over 3 years
MojoAuth is a set of standard approaches to cross-app authentication based on HMAC.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 2.6
~> 10.0
~> 3.0
~> 0.7
>= 0
 Project Readme

Gem Version Build Status Dependency Status Code Climate Coverage Status Inline docs

mojo_auth

MojoAuth is a set of standard approaches to cross-app authentication based on Hash-based Message Authentication Codes (HMAC), inspired by "A REST API For Access To TURN Services".

Installation

Add this line to your application's Gemfile:

gem 'mojo_auth'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mojo_auth

Usage

require 'mojo_auth'

# Generate a shared secret
secret = MojoAuth.create_secret
  # => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/NzaIpbK+9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q=="

# Create temporary credentials
credentials = MojoAuth.create_credentials(id: 'foobar', secret: secret)
  # => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw="}

# Test credentials
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
  # => "foobar"
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wrongpassword"}, secret: secret)
  # => false

# 1 day later
MojoAuth.test_credentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw="}, secret: secret)
  # => 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 a new Pull Request