• Stars
    star
    628
  • Rank 71,541 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 13 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple customizable OAuth 2.0 provider (server) for node.js.

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.x"

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

To support client authentication (sometimes known as xAuth) for trusted clients, handle the client_auth event to exchange a username and password for an access token. See examples/simple_express4/app.js.

Example

Within the examples sub-folder matching your preferred version of Express (for example, examples/simple_express4), run npm install and then run:

node app.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):

Running tests

Install dev dependencies:

$ npm install -d

Run the tests:

$ make test

More Repositories

1

node-gdata

Google Data API client for node.js
JavaScript
45
star
2

express-couch-proxy

A CouchDB reverse proxy (as an Express middleware) that lets you redirect clients to different CouchDB servers with custom authentication without changing your CouchDB configuration.
JavaScript
18
star
3

octoploy

A simple deployment server for GitHub post-receive hooks.
JavaScript
13
star
4

Lua.framework

A simple Lua and Objective-C bridge that lets you call Lua functions without too much sugar.
Objective-C
13
star
5

elixir-dropbox

Dropbox Core API client for Elixir
Elixir
13
star
6

express-skel

A node.js project skeleton using Express 3
JavaScript
5
star
7

node-restalytics

node.js server-side agent for RESTalytics
JavaScript
5
star
8

twitter-stalker

Twitter to SMS forwarding of anyone's tweets
JavaScript
4
star
9

qwikmail

QwikMail SMTP Server
C
3
star
10

node-emailyak

node.js library for receiving email with EmailYak
JavaScript
3
star
11

userspy

A sample node.js application using Express and Socket.IO built for Valio Con 2012.
JavaScript
3
star
12

node-idgen

A port of Twitter's Snowflake ID generation technique to node.js.
C++
3
star
13

hc11

a simple firmware for motorola 68hc11 that has a dumb shell with the uptime
C
3
star
14

shopicient

JavaScript
2
star
15

NKOResume

A little "resume" to help me connect with others looking to form a Node Knockout team
2
star
16

unter

Unter Ridematching Server
Elixir
2
star
17

eymsg

1
star
18

ammmir.github.com

1
star
19

inboxissues-test

test issues
1
star
20

ii-issues

1
star
21

dot-files

~/.*
Vim Script
1
star
22

lua-playground

my musings with lua
Lua
1
star
23

walletwatch

A small HTTP interface to the bitcoind ZeroMQ event stream
Go
1
star