Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moneypenny

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moneypenny

Authentication Server

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
3
Weekly downloads
 
Created
Source

moneypenny

moneypenny - Authentication Service

[Circle CI](https://circleci.com/gh/blueflag/m oneypenny/tree/master) Coverage Status

Moneypenny acts as an authentication service that offers multiple authentication strategies to a backend service and sends a JSON web token(JWT) encripted using a shared secret as a response.

Other services in the architecture should also know the shared secret allowing the token to be passed around in API calls to provide user information related to the request.

##Generating Documentation

   npm run doc

##Related Projects

##Sample Useage

Sample Implementation Code

##Endpoints

The following endpoints are established by the initialize(app) function

EndpointDescription
/oauth2/authorizationoAuth2 Authorization Endpoint
/oauth2/tokenoAuth2 Token Endpoint
/logoutLogout user from moneypenny

##API documentation.

moneypenny-server

Authentication server that uses both oAuth2 and JWT for authentication For single sign on.

module.exports(options) ⇒ MoneyPenny

Create a moneypenny server

Kind: Exported function
Returns: MoneyPenny - moneypenny service.

ParamTypeDescription
optionsOptionsoptions to configure moneypenny with.

module.exports~ensureAuthenticated

Middleware for checking that people using the service are authenticated.

Adds req.sesson.returnTo, the url to redirect the user to after login.

Kind: inner property of module.exports

ParamTypeDescription
reqrequestexpress request to check authenticated
resresponseexpress response related to this request
nextfunctioncallback to next middleware to handle request.

module.exports~ensureAuthenticated(req, res, next)

Middleware for checking that people using the service are authenticated.

Adds req.sesson.returnTo, the url to redirect the user to after login.

Kind: inner method of module.exports

ParamTypeDescription
reqrequestexpress request to check authenticated
resresponseexpress response related to this request
nextfunctioncallback to next middleware to handle request.

module.exports~initialize(app)

Initalize moneypenny. adds oauth authentication endpoints to express app

Kind: inner method of module.exports

ParamTypeDescription
appexpress-appthe express app that this will run on.

Example

var express = require('express');
var moneypenny = require('moneypenny');
var MongoStore = require('moneypenny-mongo-storage');
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('monogdb://localhost:27017/moneypenny', function(err, db) {
		var mpMongoStore = MongoStore(db);
		var app = express();
		var mpOptions = {
			secretOrPrivateKey: 'topsecret',
			storageProvider: mpMongoStore
		}
		var mps = moneypenny(mpOptions);
		// Following endpoints will be addded to the server.
		// /oauth2/token - token endpoint.
		// /logout - logout endpoint.
		// /oauth2/authorization - authorization endpoint.
		mps.initialize(app);
});

module.exports~serializeUser()

Used for passport to serialize the session user. using this method will allow the oauth server to send whatever details are in the user object serialized.

Kind: inner method of module.exports
See: http://passportjs.org/docs/configure#sessions
Example

passport.serializeUser(authServer.serializeUser);

Example

//remove password from user, then serialize.
passport.serializeUser((user, done)=>{
		user.password = ''
		return authServer.serializeUser(user, done);
})

module.exports~deserializeUser()

Used for passport to deserialize the session user.

Kind: inner method of module.exports
Example

passport.deserializeUser(authServer.deserializeUser);

module.exports~loginAndRedirect(req, res, next)

Helper method for login, this method can be used once a login is established from a passport strategy

It will redirect the users back to the approprate locationexpiresIn

Kind: inner method of module.exports

ParamTypeDescription
reqrequestexpress request to check authenticated
resresponseexpress response related to this request
nextfunctioncallback to next middleware to handle request.

module.exports~jwtToken(req, res) ⇒ String

Express middleware that returns a JWT token.

Kind: inner method of module.exports
Returns: String - jwt token for the user

ParamTypeDescription
reqrequestExpress JS Request Object
resresponseExpress JS Response Object

module.exports~jwt(user, ttl) ⇒ String

Sign a JWT token.

Kind: inner method of module.exports
Returns: String - encoded JWT token.

ParamTypeDescription
userObjectuser to encode.
ttlNumbertime for the token to live. (set to value in option if none is sent)

module.exports~user(JWT) ⇒ Object

Get a user from a JWT token.

Kind: inner method of module.exports
Returns: Object - enncoded user object.

ParamTypeDescription
JWTStringtoken to decode.

module.exports~logoutAndRedirect(req, res, next)

Helper method for logging out, logs user out of authentication server after logging user out from all other servers.

Not Yet Implemented

Kind: inner method of module.exports

ParamTypeDescription
reqrequestexpress request
resresponseexpress response
nextfunctioncallback to next middleware to handle request.

module.exports~Options : Options

Options that will be passed to the moneypenny server to determine how to initialize.

Kind: inner typedef of module.exports
Properties

NameTypeDescription
redirectUrlStringdefault redirect url to use if no previous url is found.
loginUrlStringurl to redirect to for login.
secretOrPrivateKeyStringsecret or private key to use for JWT encryption.
ttlNumberlifespan of a token.
storageProviderStorageProviderstorage provider to use to store autentication details. Such as 'moneypenny-mongo-store'. @see https://github.com/blueflag/moneypenny-mongo-storage

FAQs

Package last updated on 12 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc