Giter Club home page Giter Club logo

node-oauth2-provider's Introduction

OAuth 2 Provider for Connect & Express

This is a node.js module for implementing OAuth2 servers (providers) that support server-side (code) and client-side (token) OAuth flows.

It's very customizable, so you can (and currently, must) take care of OAuth token storage and client lists. In the future, a Mongo or Redis backed abstraction will be provided so you don't need to care about any kind of storage at all.

Using it with npm

If you're using this module via npm, please be sure the bracket the version in your app's package.json file. Major versions may have an incompatible API that's not backwards-compatible, so use a safe version range under dependencies (eg. for version 1.x):

"oauth2-provider": ">=1.0.0 <2.0.0"

Quick Start

Install via npm:

npm install oauth2-provider

You can add it to your Connect or Express application as another middleware. Be sure to enable the bodyParser and query middleware.

The OAuth2Provider instance providers two middleware:

  • oauth(): OAuth flow entry and access token generation
  • login(): Access control for protected resources

The most importand event emitted by OAuth2Provider is access_token, which lets you set up the request as if it were authenticated. For example, to support both cookie-authenticated and OAuth access to protected URLs, you could populate req.session.user so that individual URLs don't need to care about which type of authentication was used.

Example

In the root directory, run npm install express and then run:

node examples/simple.js

Visit http://localhost:8081/login to gain access to http://localhost:8081/secret or use OAuth to obtain an access token as a code (default) or a token (in the URL hash):

node-oauth2-provider's People

Contributors

ammmir 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.