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

devmtn-auth

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devmtn-auth

devmountain.com authentication module using json web tokens

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

DEPRECATED

This authentication service should be considered deprecated. Existing applications will continue to work, all new applications should utilize the DevMountain Single-Sign-On Service.

Contact a member of the development team for details.

DevMountain Auth

With Passport & JSON Web Tokens

This module is a Passport strategy to allow for DevMountain microservice authentication with relatively little configuration. You get all the normal benefits of Passport, including auth redirect/callback, req.user and req.logout, and serializing the user onto the session. Successful authentication will provide a user object with email, user roles, and the unique id from the authentication server database. If your app needs different/more information, it must be configured on DevMountain's app.

Example/recommended server setup here.

Testing: npm test.

Usage

  • Install devmtn-auth: npm i -S devmtn-auth

  • Add devmtnAuthConfig.js to your .gitignore

  • touch a devmtnAuthConfig.js and set it up like this (you provide specific values):

    module.exports = { app : 'app-name' , client_token : 'client-token' , callbackURL : 'callbackURL' , jwtSecret : 'jwtSecret' }

That's it for setup! However, for this to work, your app must be configured on the authentication server, and you must be given appropriate configuration values.


The token can be accessed in the verification callback when you set up the strategy.

passport.use('devmtn', new DevmtnStrategy(devmtnAuthConfig, function(jwtoken, user, done){
  // could attach the token to the session for use against DevMountain APIs
  req.session.jwtoken = jwtoken
  User.findOrCreate({email: user.email}, function(err, local_user){
    return done(err, local_user)
  })
}))

For convenience, devmtn-auth exposes a checkRoles function that can be used to verify user roles from the decoded JSON web token.

var Devmtn = require('devmtn-auth')
Devmtn.checkRoles(req.user, 'student')
// returns bool

devmtn-auth also has an optional 'clearJwtAuthCookie' middleware function to clear the auth cookie that is used for SSO.

var Devmtn = require('devmtn-auth')

app.get('/logout', Devmtn.clearJwtAuthCookie, (req, res, next) => {
  req.logout();
  res.redirect('/');
})

FAQs

Package last updated on 15 Jan 2019

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