coderofsalvation / flowee-auth

helper module for passport authentication (incl. apitoken- + local-auth examples)

Repository from Github https://github.comcoderofsalvation/flowee-authRepository from Github https://github.comcoderofsalvation/flowee-auth

Helper / Example extension for flowee (passport) authentication (incl. local- and apitoken passport examples)

Usage

Assuming you already have your flowee api running/installed:

npm install flowee-auth

Optional: REST Apitoken authentication using passport-accesstoken

npm install passport passport-accesstoken

Optional: local POST authentication with session passport-local

npm install express-session body-parser passport passport-local

Usage

You can install the apitoken, local (or both) as shown above, and you've got 2 ways of authentication out of the box!

All restpoints are now secured, except when they have public:true

'/model':
  'get':
    public: true                    <------ set this to false if you want to secure this with authentication 

Also, you can turn endpoints into public ones at runtime:

flowee.auth.ignore "/foo", "get"

Other/Custom passport strategies

However, this module is also handy to use for extra passport strategies, because it exposes the flowee.auth.getuser function.

flowee.auth.getuser can be used with passsport strategies:

flowee.auth.getuser({id:"444"}, function(user){  } );
flowee.auth.getuser({username:"john",password:"doe"}, function(user){  } );

If you look at the README.md files of random passport-strategies, you know exactly where to use this function.

About

helper module for passport authentication (incl. apitoken- + local-auth examples)


Languages

Language:Shell 64.3%Language:CoffeeScript 35.7%