Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jaredhanson/passport
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.0
Choose a base ref
...
head repository: jaredhanson/passport
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.1
Choose a head ref

Commits on Sep 16, 2017

  1. Copy the full SHA
    821a474 View commit details

Commits on Nov 30, 2017

  1. Copy the full SHA
    906a0ec View commit details
  2. Copy the full SHA
    13c550c View commit details

Commits on Dec 13, 2017

  1. Add sponsorship.

    jaredhanson committed Dec 13, 2017
    Copy the full SHA
    9125409 View commit details

Commits on Jan 23, 2018

  1. Update sponsorship links

    Eric Berry authored Jan 23, 2018
    Copy the full SHA
    2f24254 View commit details

Commits on Jan 24, 2018

  1. Merge pull request #649 from coderberry/master

    Update sponsorship links
    jaredhanson authored Jan 24, 2018
    Copy the full SHA
    0736707 View commit details

Commits on Feb 22, 2018

  1. Copy the full SHA
    57584dd View commit details

Commits on Feb 28, 2018

  1. Merge pull request #652 from matheushf/patch-2

    Update Strategies count from HomePage
    jaredhanson authored Feb 28, 2018
    Copy the full SHA
    df6e2b7 View commit details

Commits on Apr 4, 2018

  1. Remove sponsorship.

    jaredhanson committed Apr 4, 2018
    Copy the full SHA
    42aa9a3 View commit details
  2. Update status badges.

    jaredhanson committed Apr 4, 2018
    Copy the full SHA
    fa296ee View commit details
  3. Copy the full SHA
    8ac66b4 View commit details
  4. Copy the full SHA
    0a66012 View commit details
  5. Add GitHub templates.

    jaredhanson committed Apr 4, 2018
    Copy the full SHA
    d784e17 View commit details
  6. Update README.

    jaredhanson committed Apr 4, 2018
    Copy the full SHA
    e458838 View commit details

Commits on Apr 28, 2018

  1. Update sponsors.

    jaredhanson committed Apr 28, 2018
    Copy the full SHA
    2327a36 View commit details

Commits on Oct 8, 2018

  1. Update GitHub templates.

    jaredhanson committed Oct 8, 2018
    Copy the full SHA
    8ea4f24 View commit details
  2. Update README.

    jaredhanson committed Oct 8, 2018
    Copy the full SHA
    882d65e View commit details

Commits on May 23, 2019

  1. Add FUNDING.

    jaredhanson committed May 23, 2019
    Copy the full SHA
    dc16cba View commit details

Commits on May 24, 2019

  1. Update README.

    jaredhanson committed May 24, 2019
    Copy the full SHA
    1c8ede3 View commit details

Commits on Aug 9, 2019

  1. Copy the full SHA
    4cce2f2 View commit details

Commits on Dec 9, 2019

  1. Stylistic edits.

    jaredhanson committed Dec 9, 2019
    Copy the full SHA
    380b5c8 View commit details
  2. Move test.

    jaredhanson committed Dec 9, 2019
    Copy the full SHA
    5c288ae View commit details
  3. Merge pull request #749 from jaredhanson/ayZagen-feat/strategy-as-object

    Feature: Pass instantiated strategy to authenticate.
    jaredhanson authored Dec 9, 2019
    Copy the full SHA
    08f57c2 View commit details
  4. Copy the full SHA
    e15ee93 View commit details
  5. Copy the full SHA
    0362042 View commit details
  6. 0.4.1

    jaredhanson committed Dec 9, 2019
    3
    Copy the full SHA
    42ff63c View commit details
Showing with 196 additions and 36 deletions.
  1. +2 −0 .github/FUNDING.yml
  2. +53 −0 .github/ISSUE_TEMPLATE.md
  3. +41 −0 .github/PULL_REQUEST_TEMPLATE.md
  4. +3 −0 .npmignore
  5. +6 −2 .travis.yml
  6. +20 −0 CONTRIBUTING.md
  7. +1 −1 LICENSE
  8. +9 −26 README.md
  9. +4 −0 SPONSORS.md
  10. +10 −5 lib/middleware/authenticate.js
  11. +1 −1 package.json
  12. +45 −0 test/authenticator.middleware.test.js
  13. +1 −1 test/authenticator.test.js
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
patreon: jaredhanson
ko_fi: jaredhanson
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
** READ THIS FIRST! **

#### Are you looking for help?

Reminder: The issue tracker is not a support forum.

Issues should only be filed in this project once they are able to be reproduced
and confirmed as a flaw in the software or incorrect information in associated
documention.

If you are encountering problems integrating this module into your application,
please post a question on the [discussion forum](https://github.com/passport/discuss)
rather than filing an issue.

#### Is this a security issue?

Do not open issues that might have security implications. Potential security
vulnerabilities should be reported privately to jaredhanson@gmail.com. Once any
vulerabilities have been repaired, the details will be disclosed publicly in a
responsible manner. This also allows time for coordinating with affected parties
in order to mitigate negative consequences.


If neither of the above two scenarios apply to your situation, you should open
an issue. Delete this paragraph and the text above, and fill in the information
requested below.

<!-- Provide a brief summary of the issue in the title field above. -->

<!-- Provide a detailed description of your use case, including as much -->
<!-- detail as possible about what you are trying to accomplish and why. -->

### Expected behavior
<!-- Provide a detailed description of how you expected the software to -->
<!-- behave. -->

### Actual behavior
<!-- Provide a detailed description of how the software actually behaved, -->
<!-- including any rationale for why that behavior is incorrect. -->

### Steps to reproduce
<!-- Provide an unambiguous series of steps that can be used to reproduce -->
<!-- this issue, including any code if applicable. -->

```js
// Format code using Markdown code blocks
```

### Environment

* Operating System:
* Node version: <!-- $ node -v -->
* passport version: <!-- $ npm list passport -->
41 changes: 41 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
** READ THIS FIRST! **

#### Are you implementing a new feature?

Requests for new features should first be discussed on the [developer forum](https://github.com/passport/develop).
This allows the community to gather feedback and assess whether or not there is
an existing way to achieve the desired functionality.

If it is determined that a new feature needs to be implemented, include a link
to the relevant discussion along with the pull request.

#### Is this a security patch?

Do not open pull requests that might have security implications. Potential
security vulnerabilities should be reported privately to jaredhanson@gmail.com.
Once any vulerabilities have been repaired, the details will be disclosed
publicly in a responsible manner. This also allows time for coordinating with
affected parties in order to mitigate negative consequences.


If neither of the above two scenarios apply to your situation, you should open
a pull request. Delete this paragraph and the text above, and fill in the
information requested below.

<!-- Provide a brief summary of the request in the title field above. -->

<!-- Provide a detailed description of your use case, including as much -->
<!-- detail as possible about what you are trying to accomplish and why. -->
<!-- If this patch closes an open issue, include a reference to the issue -->
<!-- number. -->

### Checklist

<!-- Place an `x` in the boxes that apply. If you are unsure, please ask and -->
<!-- we will help. -->

- [ ] I have read the [CONTRIBUTING](https://github.com/jaredhanson/passport/blob/master/CONTRIBUTING.md) guidelines.
- [ ] I have added test cases which verify the correct operation of this feature or patch.
- [ ] I have added documentation pertaining to this feature or patch.
- [ ] The automated test suite (`$ make test`) executes successfully.
- [ ] The automated code linting (`$ make lint`) executes successfully.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
CONTRIBUTING.md
Makefile
SPONSORS.md
docs/
examples/
reports/
test/

.github/
.jshintrc
.travis.yml
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
language: "node_js"
node_js:
- "13"
- "12"
- "11"
- "10"
- "9"
- "8"
- "7"
- "6"
@@ -10,8 +15,7 @@ node_js:
- "1" # io.js
- "0.12"
- "0.10"
- "0.8"
- "0.6"
# - "0.8"


before_install:
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Contributing

### Tests

The test suite is located in the `test/` directory. All new features are
expected to have corresponding test cases with complete code coverage. Patches
that increase test coverage are happily accepted.

Ensure that the test suite passes by executing:

```bash
$ make test
```

Coverage reports can be generated and viewed by executing:

```bash
$ make test-cov
$ make view-cov
```
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2011-2015 Jared Hanson
Copyright (c) 2011-2019 Jared Hanson

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,13 +2,6 @@

# Passport

[![Build](https://travis-ci.org/jaredhanson/passport.svg?branch=master)](https://travis-ci.org/jaredhanson/passport)
[![Coverage](https://coveralls.io/repos/jaredhanson/passport/badge.svg?branch=master)](https://coveralls.io/r/jaredhanson/passport)
[![Quality](https://codeclimate.com/github/jaredhanson/passport/badges/gpa.svg)](https://codeclimate.com/github/jaredhanson/passport)
[![Dependencies](https://david-dm.org/jaredhanson/passport.svg)](https://david-dm.org/jaredhanson/passport)
[![Tips](https://img.shields.io/gratipay/jaredhanson.svg)](https://gratipay.com/jaredhanson/)


Passport is [Express](http://expressjs.com/)-compatible authentication
middleware for [Node.js](http://nodejs.org/).

@@ -19,6 +12,12 @@ allows application-level decisions to be made by the developer. The API is
simple: you provide Passport a request to authenticate, and Passport provides
hooks for controlling what occurs when authentication succeeds or fails.

Status:
[![Build](https://travis-ci.org/jaredhanson/passport.svg?branch=master)](https://travis-ci.org/jaredhanson/passport)
[![Coverage](https://coveralls.io/repos/jaredhanson/passport/badge.svg?branch=master)](https://coveralls.io/r/jaredhanson/passport)
[![Dependencies](https://david-dm.org/jaredhanson/passport.svg)](https://david-dm.org/jaredhanson/passport)


## Install

```
@@ -50,7 +49,7 @@ passport.use(new LocalStrategy(
));
```

There are 300+ strategies. Find the ones you want at: [passportjs.org](http://passportjs.org)
There are 480+ strategies. Find the ones you want at: [passportjs.org](http://passportjs.org)

#### Sessions

@@ -109,7 +108,7 @@ app.post('/login',

## Strategies

Passport has a comprehensive set of **over 300** authentication strategies
Passport has a comprehensive set of **over 480** authentication strategies
covering social networking, enterprise integration, API services, and more.

## Search all strategies
@@ -154,24 +153,8 @@ The [modules](https://github.com/jaredhanson/passport/wiki/Modules) page on the
[wiki](https://github.com/jaredhanson/passport/wiki) lists other useful modules
that build upon or integrate with Passport.

## Tests

```
$ npm install
$ make test
```

## Credits

- [Jared Hanson](http://github.com/jaredhanson)

## Supporters

This project is supported by ![](http://passportjs.org/images/supported_logo.svg) [Auth0](https://auth0.com)

## License

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

Copyright (c) 2011-2015 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>

Copyright (c) 2011-2019 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
4 changes: 4 additions & 0 deletions SPONSORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Sponsors

- [CodePilot.ai](https://codepilot.ai/)
- Kelly Burke
15 changes: 10 additions & 5 deletions lib/middleware/authenticate.js
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ var http = require('http')
*
* passport.authenticate('twitter');
*
* @param {String|Array} name
* @param {Strategy|String|Array} name
* @param {Object} options
* @param {Function} callback
* @return {Function}
@@ -182,10 +182,15 @@ module.exports = function authenticate(passport, name, options, callback) {
// Get the strategy, which will be used as prototype from which to create
// a new instance. Action functions will then be bound to the strategy
// within the context of the HTTP request/response pair.
var prototype = passport._strategy(layer);
if (!prototype) { return next(new Error('Unknown authentication strategy "' + layer + '"')); }

var strategy = Object.create(prototype);
var strategy, prototype;
if (typeof layer.authenticate == 'function') {
strategy = layer;
} else {
prototype = passport._strategy(layer);
if (!prototype) { return next(new Error('Unknown authentication strategy "' + layer + '"')); }

strategy = Object.create(prototype);
}


// ----- BEGIN STRATEGY AUGMENTATION -----
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "passport",
"version": "0.4.0",
"version": "0.4.1",
"description": "Simple, unobtrusive authentication for Node.js.",
"keywords": [
"express",
45 changes: 45 additions & 0 deletions test/authenticator.middleware.test.js
Original file line number Diff line number Diff line change
@@ -150,6 +150,51 @@ describe('Authenticator', function() {
});
});

describe('handling a request with instantiated strategy', function() {
function Strategy() {
}
Strategy.prototype.authenticate = function(req) {
var user = { id: '1', username: 'jaredhanson' };
this.success(user);
};

var passport = new Authenticator();

var request, error;

before(function(done) {
chai.connect.use(passport.authenticate(new Strategy()))
.req(function(req) {
request = req;

req.logIn = function(user, options, done) {
this.user = user;
done();
};
})
.next(function(err) {
error = err;
done();
})
.dispatch();
});

it('should not error', function() {
expect(error).to.be.undefined;
});

it('should set user', function() {
expect(request.user).to.be.an('object');
expect(request.user.id).to.equal('1');
expect(request.user.username).to.equal('jaredhanson');
});

it('should set authInfo', function() {
expect(request.authInfo).to.be.an('object');
expect(Object.keys(request.authInfo)).to.have.length(0);
});
});

});


2 changes: 1 addition & 1 deletion test/authenticator.test.js
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ describe('Authenticator', function() {
expect(authenticator._strategies['default']).to.be.undefined;
});
});

it('should throw if lacking a name', function() {
function Strategy() {
}