Skip to content

Commit

Permalink
Release v2.0.0 (#3)
Browse files Browse the repository at this point in the history
Release v2.0.0

* Require Node 4 or greater
* Remove legacy oauth 1 strategy and related code
* Sign all requests when using a signer
* Add support for userName parameter
* Low Bandwidth: Passing low_bandwidth param if in options. (#1)
* Improve example app
* Improve test coverage
  • Loading branch information
redbugz authored Dec 4, 2017
1 parent 2252892 commit 34509b0
Show file tree
Hide file tree
Showing 26 changed files with 377 additions and 810 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
# Node.js
node_modules
npm-debug.log
.nyc_output
reports
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
README.md
Makefile
doc/
examples/
test/
Expand Down
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: "node_js"
node_js:
- 0.4
- 0.6
- 0.8
- '4'
- '6'
- '8'
- 'node'
dist: trusty
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 2.0.0 (unreleased)

## **Breaking Changes**
- Drop support for Node versions before 4.x
- Drop support for OAuth 1(a) Legacy strategy

## New features:
- Add flag for low bandwidth mobile login
- Add flag to help with post-registration login

## Fixes:
- Example app updated to current Express and other dependencies

# 1.0.0

First public release
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

27 changes: 2 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Passport-FamilySearch

[Passport](http://passportjs.org/) strategy for authenticating with [FamilySearch](http://familysearch.org)
using the OAuth 2.0 API. The legacy strategy using the OAuth 1.0a API is
available for use, to support older applications.
using the OAuth 2.0 API.

This module lets you authenticate using FamilySearch in your Node.js
applications. By plugging into Passport, FamilySearch authentication can be
Expand Down Expand Up @@ -58,28 +57,6 @@ application:

For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-familysearch/tree/master/examples/login).

## Legacy Usage

#### Configure Strategy

The FamilySearch authentication strategy authenticates users using a
FamilySearch account and OAuth tokens. The strategy requires a `verify`
callback, which accepts these credentials and calls `done` providing a user, as
well as `options` specifying a consumer key, consumer secret, and callback URL.

var FamilySearchStrategy = require('passport-familysearch').LegacyStrategy;

passport.use(new FamilySearchStrategy({
consumerKey: FAMILYSEARCH_DEVELOPER_KEY,
consumerSecret: '',
callbackURL: "http://127.0.0.1:3000/auth/familysearch/callback"
},
function(token, tokenSecret, profile, done) {
User.findOrCreate({ familysearchId: profile.id }, function (err, user) {
return done(err, user);
});
}
));

## Tests

Expand All @@ -98,4 +75,4 @@ well as `options` specifying a consumer key, consumer secret, and callback URL.

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2012-2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
Copyright (c) 2012-2017 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
125 changes: 0 additions & 125 deletions examples/legacy-login/app.js

This file was deleted.

10 changes: 0 additions & 10 deletions examples/legacy-login/package.json

This file was deleted.

2 changes: 0 additions & 2 deletions examples/legacy-login/views/account.ejs

This file was deleted.

9 changes: 0 additions & 9 deletions examples/legacy-login/views/index.ejs

This file was deleted.

1 change: 0 additions & 1 deletion examples/legacy-login/views/login.ejs

This file was deleted.

79 changes: 46 additions & 33 deletions examples/login/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
var express = require('express')
, passport = require('passport')
, util = require('util')
, FamilySearchStrategy = require('passport-familysearch').Strategy;

var FAMILYSEARCH_DEVELOPER_KEY = "insert_familysearch_developer_key_here";

const express = require('express');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const session = require("express-session");

const passport = require('passport');
const FamilySearchStrategy = require('passport-familysearch').Strategy;

/*
Provide your FamilySearch developer key here. You can register for one at https://www.familysearch.org/developers/
*/
const FAMILYSEARCH_DEVELOPER_KEY = 'insert_familysearch_developer_key_here';

/*
Uncomment the environment that you want to run against. Your developer key must be registered with this environment.
*/
// const FAMILYSEARCH_IDENT_BASE = 'https://ident.familysearch.org';
// const FAMILYSEARCH_IDENT_BASE = 'https://identbeta.familysearch.org';
const FAMILYSEARCH_IDENT_BASE = 'https://integration.familysearch.org';
// const FAMILYSEARCH_API_BASE = 'https://api.familysearch.org';
// const FAMILYSEARCH_API_BASE = 'https://apibeta.familysearch.org';
const FAMILYSEARCH_API_BASE = 'https://api-integ.familysearch.org';

// Passport session setup.
// To support persistent login sessions, Passport needs to be able to
Expand All @@ -27,10 +44,11 @@ passport.deserializeUser(function(obj, done) {
// credentials (in this case, a token, tokenSecret, and FamilySearch profile), and
// invoke a callback with a user object.
passport.use(new FamilySearchStrategy({
authorizationURL: 'https://sandbox.familysearch.org/cis-web/oauth2/v3/authorization',
tokenURL: 'https://sandbox.familysearch.org/cis-web/oauth2/v3/token',
authorizationURL: `${FAMILYSEARCH_IDENT_BASE}/cis-web/oauth2/v3/authorization`,
tokenURL: `${FAMILYSEARCH_IDENT_BASE}/cis-web/oauth2/v3/token`,
devKey: FAMILYSEARCH_DEVELOPER_KEY,
callbackURL: "http://127.0.0.1:3000/auth/familysearch/callback"
callbackURL: "http://localhost:3000/auth/familysearch/callback",
userProfileURL: `${FAMILYSEARCH_API_BASE}/platform/users/current`
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
Expand All @@ -45,31 +63,22 @@ passport.use(new FamilySearchStrategy({
}
));

const app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');


var app = express();

// configure Express
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.logger());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({ secret: 'keyboard cat' }));
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});

app.use(logger('dev'));
app.use(session({secret: 'keyboard cat', resave: false, saveUninitialized: true}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(passport.initialize());
app.use(passport.session());

app.get('/', function(req, res){
res.render('index', { user: req.user, layout: 'layout' });
res.render('index', { user: req.user });
});

app.get('/account', ensureAuthenticated, function(req, res){
Expand Down Expand Up @@ -97,7 +106,7 @@ app.get('/auth/familysearch',
// request. If authentication fails, the user will be redirected back to the
// login page. Otherwise, the primary route function function will be called,
// which, in this example, will redirect the user to the home page.
app.get('/auth/familysearch/callback',
app.get('/auth/familysearch/callback',
passport.authenticate('familysearch', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
Expand All @@ -108,7 +117,9 @@ app.get('/logout', function(req, res){
res.redirect('/');
});

app.listen(3000);
app.listen(3000, function () {
console.log('Listening on port 3000');
});


// Simple route middleware to ensure user is authenticated.
Expand All @@ -120,3 +131,5 @@ function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login')
}

module.exports = app;
Loading

0 comments on commit 34509b0

Please sign in to comment.