<commit_before>[![Gem Version](https://badge.fury.io/rb/mojo_auth.png)](https://rubygems.org/gems/mojo_auth)
[![Build Status](https://secure.travis-ci.org/mojolingo/mojo-auth.rb.png?branch=develop)](http://travis-ci.org/mojolingo/mojo-auth.rb)
[![Dependency Status](https://gemnasium.com/mojolingo/mojo-auth.rb.png?travis)](https://gemnasium.com/mojolingo/mojo-auth.rb)
[![Code Climate](https://codeclimate.com/github/mojolingo/mojo-auth.rb.png)](https://codeclimate.com/github/mojolingo/mojo-auth.rb)
[![Coverage Status](https://coveralls.io/repos/mojolingo/mojo-auth.rb/badge.png?branch=develop)](https://coveralls.io/r/mojolingo/mojo-auth.rb)
[![Inline docs](http://inch-ci.org/github/mojolingo/mojo-auth.rb.png?branch=develop)](http://inch-ci.org/github/mojolingo/mojo-auth.rb)

# mojo_auth

[MojoAuth](http://mojolingo.com/mojoauth) is a set of standard approaches to cross-app authentication based on [Hash-based Message Authentication Codes](http://en.wikipedia.org/wiki/Hash-based_message_authentication_code) (HMAC), inspired by ["A REST API For Access To TURN Services"](http://tools.ietf.org/html/draft-uberti-behave-turn-rest).

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'mojo_auth'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install mojo_auth

## Usage

```ruby
require 'mojo_auth'

# Generate a shared secret
secret = MojoAuth.create_secret
  # => "<KEY>9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q==\n"

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

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

# 1 day later
MojoAuth.test_credentials({username: "1411837760:foobar", password: "<PASSWORD>"}, secret: secret)
  # => false
```

## Contributing

1. [Fork it](https://github.com/mojolingo/mojo_auth.rb/fork)
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
<commit_msg>Higher quality badges<commit_after>[![Gem Version](https://badge.fury.io/rb/mojo_auth@2x.png)](https://rubygems.org/gems/mojo_auth)
[![Build Status](https://travis-ci.org/mojolingo/mojo-auth.rb.svg?branch=develop)](http://travis-ci.org/mojolingo/mojo-auth.rb)
[![Dependency Status](https://gemnasium.com/mojolingo/mojo-auth.rb.png?travis)](https://gemnasium.com/mojolingo/mojo-auth.rb)
[![Code Climate](https://codeclimate.com/github/mojolingo/mojo-auth.rb/badges/gpa.svg)](https://codeclimate.com/github/mojolingo/mojo-auth.rb)
[![Coverage Status](https://img.shields.io/coveralls/mojolingo/mojo-auth.rb.svg)](https://coveralls.io/r/mojolingo/mojo-auth.rb?branch=develop)
[![Inline docs](http://inch-ci.org/github/mojolingo/mojo-auth.rb.svg?branch=develop)](http://inch-ci.org/github/mojolingo/mojo-auth.rb)

# mojo_auth

[MojoAuth](http://mojolingo.com/mojoauth) is a set of standard approaches to cross-app authentication based on [Hash-based Message Authentication Codes](http://en.wikipedia.org/wiki/Hash-based_message_authentication_code) (HMAC), inspired by ["A REST API For Access To TURN Services"](http://tools.ietf.org/html/draft-uberti-behave-turn-rest).

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'mojo_auth'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install mojo_auth

## Usage

```ruby
require 'mojo_auth'

# Generate a shared secret
secret = MojoAuth.create_secret
  # => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/<KEY>"

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

# Test credentials
MojoAuth.test_credentials({username: "1411837760:foobar", password: "<PASSWORD>QHw=\n"}, secret: secret)
  # => "foobar"
MojoAuth.test_credentials({username: "1411837760:foobar", password: "<PASSWORD>"}, secret: secret)
  # => false

# 1 day later
MojoAuth.test_credentials({username: "1411837760:foobar", password: "<PASSWORD>"}, secret: secret)
  # => false
```

## Contributing

1. [Fork it](https://github.com/mojolingo/mojo_auth.rb/fork)
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

{'fraction_non_alphanumeric': 0.16848407098567458, 'fraction_numerical': 0.023091725465041693, 'mean_word_length': 5.542657342657343, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5946015', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1711, 'n_words': 298}