Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mojolingo/mojo-auth.ex
MojoAuth implementation in Elixir
https://github.com/mojolingo/mojo-auth.ex
Last synced: 4 days ago
JSON representation
MojoAuth implementation in Elixir
- Host: GitHub
- URL: https://github.com/mojolingo/mojo-auth.ex
- Owner: mojolingo
- License: mit
- Fork: true (adhearsion/mojo-auth.ex)
- Created: 2015-10-03T23:02:20.000Z (about 9 years ago)
- Default Branch: develop
- Last Pushed: 2016-02-11T17:34:40.000Z (over 8 years ago)
- Last Synced: 2024-08-02T02:11:18.538Z (3 months ago)
- Language: Elixir
- Homepage: http://mojoauth.mojolingo.com/
- Size: 132 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - MojoAuth implementation in Elixir. (Authentication)
- fucking-awesome-elixir - mojoauth - MojoAuth implementation in Elixir. (Authentication)
- awesome-elixir - mojoauth - MojoAuth implementation in Elixir. (Authentication)
README
[![Build Status](https://travis-ci.org/mojolingo/mojo-auth.ex.svg?branch=develop)](http://travis-ci.org/mojolingo/mojo-auth.ex)
# mojoauth
[MojoAuth](http://mojoauth.mojolingo.com) 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).
## Dependencies
* elixir
* mix## Building
Simply run `mix compile`.
## Usage
```elixir
# Generate a shared secret
iex(1)> secret = MojoAuth.create_secret
"y662KxTm1X4DvVCml+witUgwdJkNbR013JvFFUy6ZxuWozjHwND6vlIREoylJBh/9TiuSMpBqluNekWqN7kaPg=="# Create temporary credentials
iex(2)> credentials = MojoAuth.create_credentials(id: "foobar", secret: secret)
[username: "1413748361:foobar", password: "sJgD0PLv892CUSfp1HL2td5NEeM="]# Test credentials
iex(3)> MojoAuth.test_credentials(credentials, secret)
{:ok, "foobar"}
iex(4)> MojoAuth.test_credentials([username: "1412629132:foobar", password: "wrongpassword"], secret)
{:invalid, "foobar"}# 1 day later
iex(5)> MojoAuth.test_credentials(credentials, secret)
{:expired, "foobar"}
```## Contributing
1. [Fork it](https://github.com/mojolingo/mojo-auth.ex/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