user-management-system
User Management System(UMS) for vigour projects
- Launches an express server to manage authentication
- uses passport and the following strategies:
- passport-facebook A file system-based session store.
- if you wish to use another passport strategy, please let me know or implement it yourself and make a pull request
- Session managed with: express-session using one of the following session stores:
- session-file-store A file system-based session store.
- connect-redis A Redis-based session store.
- if you wish to use another session store, please let me know or implement it yourself and make a pull request
Usage:
$ npm install user-management-system
var ums = var config = umsstartconfig
Config:
this is what a typical config should look like:
- port - the port on which the UMS express server will be running (defaults to 9000)
- session - information about the session management (optional)
- options - see session options
- defaults to:
{ secret: 'my-little-pony', resave: true, saveUninitialized: true }
- note: you can override the "store" option at your own risk
- defaults to:
- store - choice of predefined session stores
- type - type of store to use (defaults to "file"), can be:
- file - use session-file-store
- default options:
{ path: "/<tmpdir>/.ums-sessions", logFn: function(){} }
- default options:
- redis - use connect-redis
- default options:
{ uri: "localhost", port: 6379 }
- default options:
- file - use session-file-store
- type - type of store to use (defaults to "file"), can be:
- auth - settings for each of the Strategies being used
- note: no need to specify callback urls
- note: you should specify the "scope" property here
Advanced usage
checkout the example folder to see a real world implementation using mongodb to store users and sessions
you can run the example simply with $ npm start
note: you need a mongodb server running on the default port(27017)
User management:
out of the box, UMS uses the following function for serializing and deserializing users:
{ }
and the following verify callback:
//example for the facebook strategy { var user = strategy: 'facebook' profile: profile_json userfacebooktoken = token ifserverconfigauthverifyCallback serverconfigauth else }
and req.user will be an object, looking like:
facebook: id: '10153112773881034' email: 'andre.padez@gmail.com' gender: 'male' link: 'https://www.facebook.com/app_scoped_user_id/10153112773881034/' locale: 'en_US' last_name: 'Padez' first_name: 'André' middle_name: 'Alçada' timezone: 1 updated_time: '2015-10-28T10:29:39+0000' verified: true token: '<oauth_token>'
you can, however, override those by setting them to the config object, so:
var ums = var config = configauth{db} configauth { } configauth{ db} umsstartconfig
note: all db operations are fictitious here, just to illustrate