Socket
Socket
Sign inDemoInstall

passport-bluemix-obc

Package Overview
Dependencies
5
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    passport-bluemix-obc

BlueMix OAuth 2.0 authentication strategy for Passport for Blockchain Service.


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

passport-bluemix

Passport strategy for authenticating with Bluemix using the OAuth 2.0 API.

You can use this module to authenticate users with IBM ID in your Node.js applications. The module can also be used as middleware in Express. Manage your client configurations in Bluemix IDaaS.

Install

$ npm install passport-bluemix

Usage

Authentication Strategy

Use BlueMix as OAuth2 authentication strategy for Passport. After authenticate using IBM ID, this strategy requires a verify callback which can be used to create/verify an user in your application. Calling done(null, profile) will save user profile from IBM to the current passport session. You can also write anything to the passport session, for example user.

var passport = require('passport')
, BlueMixOAuth2Strategy = require('passport-bluemix').BlueMixOAuth2Strategy;

passport.use('bluemix', new BlueMixOAuth2Strategy({
	authorizationURL : 'https://idaas.ng.bluemix.net/sps/oauth20sp/oauth20/authorize',
	tokenURL : 'https://idaas.ng.bluemix.net/sps/oauth20sp/oauth20/token',
	clientID : 'your_app_client_id',
	scope: 'profile',
	grant_type: 'authorization_code',
	clientSecret : 'your_app_client_secret',
	callbackURL : 'your_callback_url',
	profileURL: 'https://idaas.ng.bluemix.net/idaas/resources/profile.jsp'
}, function(accessToken, refreshToken, profile, done) {
	... //find or create new user
	return done(null, ...);
}));
Authenticate Requests

Use passport.authenticate(), specifying the 'bluemix' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/ibm', passport.authenticate('bluemix', {requestedAuthnPolicy: 'http://www.ibm.com/idaas/authnpolicy/basic'}));
app.get('/auth/ibm/callback', 
		passport.authenticate('bluemix'),
		function(req, res) {
		// Successful authentication, redirect home.
    	res.redirect('/');
});

Credits

License

The MIT License

Copyright (c) 2014 Minh Hoang http://minhhoang.de/

Keywords

FAQs

Last updated on 22 Jul 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc