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".
package main
import (
"fmt"
"github.com/mojolingo/mojoauth.go"
)
func main() {
// Generate a shared secret
secret = mojoauth.CreateSecret
// => "XyD+xeJHivzbOUe3vwdU6Z5vDe/vio34MxKX8HYViR0+p4t/NzaIpbK+9VwX\n5qHCj7m4f7UNRXgOJPXzn6MT0Q==\n"
// Create temporary credentials
credentials = mojoauth.CreateCredentials(id: 'foobar', secret: secret)
// => {:username=>"1411837760:foobar", :password=>"wb6KxLj6NXcUaqNb1SlHH1V3QHw=\n"}
// Test credentials
mojoauth.TestCredentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw=\n"}, secret: secret)
// => "foobar"
mojoauth.TestCredentials({username: "1411837760:foobar", password: "wrongpassword"}, secret: secret)
// => false
// 1 day later
mojoauth.TestCredentials({username: "1411837760:foobar", password: "wb6KxLj6NXcUaqNb1SlHH1V3QHw=\n"}, secret: secret)
// => false
}
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request