Integrate the passport authentication framework into Collagen.js

npm install collagen-passport
1 downloads in the last day
1 downloads in the last week
41 downloads in the last month

Collagen.js Passport

This module allows the Collagen.js framework to use the Passport authentication framework for node.js.

To use, you will need to also install an authenticatin strategy, which can be found here:

The configuration for your authentication strategy should live in the collagen.json file and can be created as follows (the example uses the passport-oauth1 strategy):

"passport": {
    "oauth1" : { // <---Authentication strategy: module name, without the `passport-` part
        "requestTokenURL": "",
        "accessTokenURL": "",
        "userAuthorizationURL": "",
        "consumerKey": "CONSUMER KEY",
        "consumerSecret": "CONSUMER SECRET",
        "callbackURL": ""

The module currently supports user profile verification function for OAuth strategies, but has sensible defaults in case other mechanisms are used (this can also be extended with your custom logic).

To login using this strategy, browse to http://localhost:3000/auth/oauth1/login (or /auth/KEY/login, where KEY is your authentication strategy). Multiple authentication strategies are supported in the passport object inside collagen.json

This module also supports URL redirection after login/logout. To enable, add the following to your collagen.json file:

"passport": {
    "oauth1": {
        "loginRedirect": "/user",
        "logoutRedirect": "home"

The parameters are passed directly to res.redirect(...). They take the following arguments:

  • "home": Website root (similar to "/"). Default for logoutRedirect.
  • "back": Referer. Redirects back to where the user was. Default for loginRedirect.
  • "/my/absolute/path": Any absolute URL path on the website.
  • "": An external website.

Note: When authorizing an application for the first time, loginRedirect will not work with the back option. In this case, it will default to home.

npm loves you