GithubHelp home page GithubHelp logo

jdotpz / node-webmaker-loginapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/node-webmaker-loginapi

0.0 2.0 0.0 371 KB

Express module for Mozilla Webmaker SSO integration

License: Apache License 2.0

node-webmaker-loginapi's Introduction

Webmaker-LoginAPI

Setup

Setup is easy! Add to your package.json and run npm install.

Integration

Pass the module:

  1. Your app's express instance

    NOTE: Do not call the constructor-function returned by the require() until all of your server's general middleware has been declared.

  2. An options object that will pass options used for Express Persona and our SSO integration.

Required Options

  • audience - The URL of your express app when viewed in a browser. Must include the protocol, hostname, and port.
    • Example: http://example.org:80, https://example.org:443
  • loginURL - An http address including a user/pass according to the http uri scheme.

Optional Options

  • verifyResponse - A callback used for custom actions needed for individual apps. It is returned:
    • res - The server response object.
    • data - Contains information useful to determine app specific actions such as: ** email - The email of the Persona Users ** user - An object containing information about this Webmaker user. ** status - Just general information if things didn't fail.

i.e.

var loginHandle = require( "webmaker-loginapi" )( expressApp, {
  loginURL: "http://admin:[email protected]",
  audience: "http://example.org:443"
});

API Exposure

Instantiating this module creates the GET /user/:id route in the parent app for use during SSO integration. It exposes the Webmaker username associated with valid persona credentials as req.session.username.

The route will return { status: "okay", user: user } when successful, and { status: "failure", reason: "error message" } when not.

Methods

The module returns an object with three methods:

loginHandle.getUserById ( id, callback )

...which retrieves the user model for the passed id, passing the callback the parameters ( errorString, userObject ) and

loginHandle.getUserByEmail ( email, callback )

...which retrieves the user model for the passed email, passing the callback the parameters ( errorString, userObject ) and

loginHandle.getUserByUsername ( username, callback )

...which retrieves the user model for the passed username, passing the callback the parameters ( errorString, userObject ) and

Testing

Ensure the grunt and mocha npm modules are installed globally, then run

  1. grunt
  2. mocha

node-webmaker-loginapi's People

Contributors

alicoding avatar humphd avatar jbuck avatar mjschranz avatar pomax avatar sedge avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.