npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sails-hook-sso

v0.0.9

Published

Single Sign-on for sails.js using passport and passport-sso

Downloads

6

Readme

sails-hook-sso

Passport-SSO for the Sails framework. This is still in development and not ready for production use.

This project relies on passport-sso

npm install passport-sso --save

Getting started

1.) Create a sso.js file in the sails project's config directory (i.e: config/sso.js)

2.) Add the following to your new sso.js config file. Make sure to change the values of each setting to match that of your database connections and schema

  /***************************************************************************
  *                                                                          *
  * Override sails-hook-sso database connections                             *
  *                                                                          *
  ***************************************************************************/

  connections: {
    hosts       : "{hosts-connection}",     # Connection for host table/collection (config/connections.js)
    providers   : "{providers-connection}", # Connection for providers table/collection (config/connections.js)
    users       : "{users-connection}",     # Connection for users table/collection (config/connections.js)
    passports   : "{passports-connection}", # Connection for passports table/collection (config/connections.js)
    groups      : "{groupsConnection}",     # Connection for groups table/collection (config/connections.js)
  },

  /***************************************************************************
  *                                                                          *
  * Override sails-hook-sso database table/collection names                  *
  *                                                                          *
  ***************************************************************************/
  collections: {
      hosts       : "sso_hosts",     # Name of your host table/collection
      providers   : "sso_providers", # Name of your provider table/collection
      users       : "sso_users",     # Name of your user table/collection
      passports   : "sso_passports", # Name of your passport table/collection
      groups      : "sso_groups",    # Name of your group table/collection
  }

1.) Add a host controller (i.e: api/controllers/V1/Settings/Global/HostsController.js) to your sails project:

module.exports = {

    /**
     * `HostsController.index()`
     * @author      :: Matt McCarty
     * @description :: Returns all supported hosts from the global configuration
     * @method      :: GET
     * @example     :: version#/settings/global/hosts
     */
    index: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.hosts.index(req, res);
    },

    /**
     * `HostsController.create()`
     * @author      :: Matt McCarty
     * @description :: Add a new host to the global configuration
     * @method      :: POST
     * @example     :: version#/settings/global/hosts/create
     */
    create: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.hosts.create(req, res);
    },

    /**
     * `HostsController.update()`
     * @author      :: Matt McCarty
     * @description :: Update an existing host in the database
     * @method      :: PUT
     * @example     :: version#/settings/global/hosts/update
     */
    update: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.hosts.update(req, res);
    },

    /**
     * `HostsController.destroy()`
     * @author      :: Matt McCarty
     * @description :: Deletes an existing host record from the database
     * @method      :: DELETE
     * @example     :: version#/settings/global/hosts/destroy
     */
    destroy: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.hosts.destroy(req, res);
    }
};

2.) Add a groups controller (i.e: api/controllers/V1/Settings/Global/GroupsController.js) to your sails project:

module.exports = {

    /**
     * `GroupsController.index()`
     * @author      :: Matt McCarty
     * @description :: Returns all supported groups from the global configuration
     * @method      :: GET
     * @example     :: version#/settings/global/groups
     */
    index: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.groups.index(req, res);
    },

    /**
     * `GroupsController.create()`
     * @author      :: Matt McCarty
     * @description :: Add a new group to the global configuration
     * @method      :: POST
     * @example     :: version#/settings/global/hogroupssts/create
     */
    create: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.groups.create(req, res);
    },

   /**
     * `GroupsController.update()`
     * @author      :: Matt McCarty
     * @description :: Update an existing group in the database
     * @method      :: PUT
     * @example     :: version#/settings/global/groups/update
     */
    update: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.groups.update(req, res);
    },

    /**
     * `GroupsController.destroy()`
     * @author      :: Matt McCarty
     * @description :: Deletes an existing group record from the database
     * @method      :: DELETE
     * @example     :: version#/settings/global/groups/destroy
     */
    destroy: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.groups.destroy(req, res);
    }
};

3.) Add a providers controller (i.e: api/controllers/V1/Settings/Global/ProvidersController.js) to your sails project:

module.exports = {

    /**
     * `ProvidersController.index()`
     * @author      :: Matt McCarty
     * @description :: Returns all supported providers from the global configuration
     * @method      :: GET
     * @example     :: version#/settings/global/providers
     */
    index: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.providers.index(req, res);
    },

    /**
    * `ProvidersController.defaults()`
    * @author      :: Matt McCarty
    * @description :: Returns a list of the provider default settings
    * @method      :: GET
    * @example     :: version#/settings/global/defaults
    */
    defaults: function (req, res) {
        return sails.controllers.sso.providers.defaults(req, res);
    },

    /**
     * `ProvidersController.create()`
     * @author      :: Matt McCarty
     * @description :: Add a new provider to the global configuration
     * @method      :: POST
     * @example     :: version#/settings/global/providers/create
     */
    create: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.providers.create(req, res);
    },

    /**
     * `ProvidersController.update()`
     * @author      :: Matt McCarty
     * @description :: Update an existing provider in the database
     * @method      :: PUT
     * @example     :: version#/settings/global/providers/update
     */
    update: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.providers.update(req, res);
    },

    /**
     * `ProvidersController.destroy()`
     * @author      :: Matt McCarty
     * @description :: Deletes an existing provider record from the database
     * @method      :: DELETE
     * @example     :: version#/settings/global/providers/destroy
     */
    destroy: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.providers.destroy(req, res);
    }
};

4.) Add a passports controller (i.e: api/controllers/V1/User/Auth/PassportsController.js) to your sails project:

module.exports = {

    /**
     * `PassportsController.index()`
     * @author      :: Matt McCarty
     * @description :: Returns all supported pasports from the global configuration
     * @method      :: GET
     * @example     :: version#/user/auth/pasports
     */
    index: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.pasports.index(req, res);
    },

    /**
     * `PassportsController.create()`
     * @author      :: Matt McCarty
     * @description :: Add a new passport to the global configuration
     * @method      :: POST
     * @example     :: version#/user/auth/create
     */
    create: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.pasports.create(req, res);
    },

    /**
     * `PassportsController.update()`
     * @author      :: Matt McCarty
     * @description :: Update an existing passport in the database
     * @method      :: PUT
     * @example     :: version#/user/auth/update
     */
    update: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.pasports.update(req, res);
    },

    /**
     * `PassportsController.destroy()`
     * @author      :: Matt McCarty
     * @description :: Deletes an existing passport record from the database
     * @method      :: DELETE
     * @example     :: version#/user/auth/destroy
     */
    destroy: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.pasports.destroy(req, res);
    }
};

5.) Add a user controller (i.e: api/controllers/V1/UsersController.js) to your sails project:

module.exports = {

    /**
     * `UsersController.index()`
     * @author      :: Matt McCarty
     * @description :: Returns user profile page
     * @method      :: GET
     * @example     :: version#/user
     */
    index: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.users.index(req, res);
    },

    /**
     * `UsersController.register()`
     * @author      :: Matt McCarty
     * @description :: Creates (registers) a new user
     * @method      :: POST
     * @example     :: version#/user/register
     */
    register: function (req, res) {
        // Defined in sails-hook-sso module
        return sails.controllers.sso.users.register(req, res);
    }
};

6.) Configure your routes in config/routes.js to match the new controllers and actions

7.) Run sails:

sails lift

8.) Make a REST API request to one of the endpoints. For example:

POST   = /v1/settings/global/hosts/create
Values = {
    host    : 'localhost:1337',
    master  : 1,
    children: []
}

to be continued...