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".
Run npm install mojo-auth.js --save
to add this library as a dependency to your Node.js project.
> var mojoauth = require('mojo-auth.js');
> var secret, credentials;
undefined
// Generate a shared secret
> secret = mojoauth.createSecret();
'27058c65ab05794cdec23abb2ad49f402e011d1ff56b61d4a4c37032ced2d94df6cff260c4fee814d1f9ea35fa7a2962332f0b2c5415e753b329c328a62c86f8'
// Create temporary credentials
> credentials = mojoauth.createCredentials({id: 'foobar', secret: secret});
{ username: '1413151933064:foobar',
password: 'lvpE3AcLea5Io4mj8xT/eMlvw9k=' }
// Test credentials
> mojoauth.testCredentials({username: '1413151933064:foobar', password: 'lvpE3AcLea5Io4mj8xT/eMlvw9k='}, secret);
'foobar'
> mojoauth.testCredentials({username: '1413151933064:foobar', password: 'wrongpassword'}, secret);
false
// 1 day later
> mojoauth.testCredentials({username: '1413151933064:foobar', password: 'lvpE3AcLea5Io4mj8xT/eMlvw9k='}, 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