Skip to content

adhearsion/mojoauth.erl

Repository files navigation

Build Status

mojoauth

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".

Dependencies

  • rebar
  • make

Building

Simply run make.

Usage

% Generate a shared secret
2> Secret = mojoauth:create_secret().
<<"eN1lvHK7cXPYFNwmEwZ3QNMAiCC651E5ikuEOj7+k4EMYTXb3XxXo3iBw4ScxqzJ+aH6aDCCe++LPVGRjgfl3Q==">>

% Create temporary credentials
3> Credentials = mojoauth:create_credentials({id, "foobar"}, {secret, Secret}).
[{username,"1412629132:foobar"},
 {password,<<"Q1RegXu0oYtm1UYqxRkegilugeM=">>}]

% Test credentials
4> mojoauth:test_credentials([{username, "1412629132:foobar"}, {password,<<"Q1RegXu0oYtm1UYqxRkegilugeM=">>}], Secret).
{ok,"foobar"}
5> mojoauth:test_credentials([{username, "1412629132:foobar"}, {password,"wrongpassword"}], Secret).
{invalid}

% 1 day later
6> mojoauth:test_credentials([{username, "1412629132:foobar"}, {password,<<"Q1RegXu0oYtm1UYqxRkegilugeM=">>}], Secret).
{expired}

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

About

Implementation of MojoAuth in Erlang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published