Skip to content

Commit

Permalink
Merge 609603d into 0ad9f48
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Jun 10, 2019
2 parents 0ad9f48 + 609603d commit 04cea41
Show file tree
Hide file tree
Showing 45 changed files with 5,440 additions and 1,641 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.git
coverage/
node_modules/
node_modules/
var/
docs/jsdoc
118 changes: 105 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,116 @@
module.exports = {
env: {
// jest: true,
mocha: true,
node: true,
browser: false
},
extends: [
'airbnb-base',
'ash-nazg/sauron-node',
// Override ash-nazg's current preference for ESM
'plugin:node/recommended-script'
],
settings: {
polyfills: [
// Needing these for some reason to avoid an error
"Promise",
"Promise.reject",
"Promise.resolve"
]
},
overrides: [
{
files: ['test/**'],
env: {
// jest: true,
mocha: true
},
globals: {
expect: 'readonly'
},
rules: {
'jsdoc/require-jsdoc': 'off'
// 'jest/no-disabled-tests': [2],
// 'jest/no-focused-tests': [2],
// 'jest/no-identical-title': [2],
// 'jest/prefer-to-have-length': [2],
// 'jest/valid-expect': [2],
}
},
{
files: ['**/*.md'],
rules: {
'eol-last': 'off',
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'warn',
'padded-blocks': 'off',
'import/unambiguous': 'off',
'import/no-unresolved': 'off',
'node/no-missing-import': 'off',
'node/no-missing-require': 'off',
'func-names': 'off',
'import/newline-after-import': 'off',
strict: 'off',
// Disable until eslint-plugin-jsdoc may fix: https://github.com/gajus/eslint-plugin-jsdoc/issues/211
indent: 'off'
}
}
],
globals: {
// By some ESLint bug, config overrides not working with globals
require: 'readonly',
module: 'readonly',
exports: 'writable'
},
plugins: [
// 'jest'
],
rules: {
"comma-dangle": 0,
"no-underscore-dangle": 0,
"no-param-reassign": 0,
"prefer-destructuring": 0,
// 'jest/no-disabled-tests': [2],
// 'jest/no-focused-tests': [2],
// 'jest/no-identical-title': [2],
// 'jest/prefer-to-have-length': [2],
// 'jest/valid-expect': [2],
'comma-dangle': 0,
'no-underscore-dangle': 0,
'no-param-reassign': 0,

// Disable as middleware approach requires some callbacks
'promise/prefer-await-to-callbacks': 0,

// Disable until ready to tackle
'require-jsdoc': 0,

// Disable current preferences of ash-nazg
'import/no-commonjs': 0,
'node/exports-style': 0,

// add back different or stricter rules from airbnb
'object-curly-spacing': ['error', 'always'],
'func-names': 'warn',
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always'
}],
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }],
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: true,
}],
'no-empty-function': ['error', {
allow: [
'arrowFunctions',
'functions',
'methods',
]
}],
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
'no-multi-assign': ['error'],
'no-unused-expressions': ['error', {
allowShortCircuit: false,
allowTernary: false,
allowTaggedTemplates: false,
}]
}
};
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
docs/
reports/
var/

# Mac OS X
.DS_Store
Expand Down
18 changes: 0 additions & 18 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ docs/
examples/
reports/
test/
var/

.github/
.jshintrc
.travis.yml
.gitlab-ci.yml
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Contributing

Pull Requests are welcome for any issues, if you have any questions please
Pull Requests are welcome for any issues, if you have any questions please
[raise an issue](https://github.com/passport-next/passport/issues).

If you discover a security issue please create an issue stating you've discovered a security
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ LCOVFILE = ./reports/coverage/lcov.info

MOCHAFLAGS = --require ./test/bootstrap/node

COVDIR = ./var/cov/*

view-docs:
open ./docs/index.html

view-cov:
open ./reports/coverage/lcov-report/index.html
open ./var/cov/index.html

clean-cov:
-rm -r $(COVDIR)

clean: clean-docs clean-cov
-rm -r $(REPORTSDIR)
Expand Down
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Passport Next aims to:
* Follow [Semantic Versioning](https://semver.org/)
* Keep an up to date CHANGELOG.md

**Passport Next does not aim to be backwards compatible with the upstream repositories.
**Passport Next does not aim to be backwards compatible with the upstream repositories.
The changes required to keep up to date and functioning prohibit that so if you're migrating
from the upstream modules please test your code thouroughly!**

Expand All @@ -62,13 +62,15 @@ application must be configured.

```javascript
passport.use(new LocalStrategy(
function(username, password, done) {
User.findOne({ username: username }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
if (!user.verifyPassword(password)) { return done(null, false); }
return done(null, user);
});
async function (username, password) {
let user;
try {
user = await User.findOne({ username });
} catch (err) {
throw err;
}
if (!user || !user.verifyPassword(password)) { return false; }
return user;
}
));
```
Expand All @@ -88,14 +90,13 @@ as simple as serializing the user ID, and finding the user by ID when
deserializing.

```javascript
passport.serializeUser(function(user, done) {
done(null, user.id);
passport.serializeUser(function (user) {
return user.id;
});

passport.deserializeUser(function(id, done) {
User.findById(id, function (err, user) {
done(err, user);
});
passport.deserializeUser(async function (id) {
const user = await User.findById(id);
return user;
});
```

Expand All @@ -108,9 +109,8 @@ persistent login sessions (recommended, but not required), `passport.session()`
middleware must also be used.

```javascript
var app = express();
app.use(require('serve-static')(__dirname + '/../../public'));
app.use(require('cookie-parser')());
const app = express();
app.use(require('serve-static')(path.join(__dirname, '/../../public')));
app.use(require('body-parser').urlencoded({ extended: true }));
app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true }));
app.use(passport.initialize());
Expand All @@ -123,31 +123,31 @@ Passport provides an `authenticate()` function, which is used as route
middleware to authenticate requests.

```javascript
app.post('/login',
app.post('/login',
passport.authenticate('local', { failureRedirect: '/login' }),
function(req, res) {
function (req, res) {
res.redirect('/');
});
```

#### Protect Routes When Using Sessions

Passport provides an `isAuthenticated()` function on the request object, which
is used to determine if the user has been authenticated and stored in the
Passport provides an `isAuthenticated()` function on the request object, which
is used to determine if the user has been authenticated and stored in the
session.

```javascript
app.post('/some/protected/route',
function(req, res, next) {
if(req.isAuthenticated()){
app.post('/some/protected/route',
function (req, res, next) {
if (req.isAuthenticated()) {
next();
} else {
next(new Error('Unauthorized'));
return;
}
next(new Error('Unauthorized'));
});
```

For a more complete solution to handling unauthenticated users, see
For a more complete solution to handling unauthenticated users, see
[connect-ensure-login](https://github.com/jaredhanson/connect-ensure-login), a
middleware to ensure login sessions.

Expand All @@ -162,16 +162,16 @@ There is a **Strategy Search** at [passportjs.org](http://passportjs.org)

The following table lists commonly used strategies:

|Strategy | Protocol |Developer |
|Strategy | Protocol |Developer |
|---------------------------------------------------------------|--------------------------|------------------------------------------------|
|[Local](https://github.com/jaredhanson/passport-local) | HTML form |[Jared Hanson](https://github.com/jaredhanson) |
|[OpenID](https://github.com/jaredhanson/passport-openid) | OpenID |[Jared Hanson](https://github.com/jaredhanson) |
|[BrowserID](https://github.com/jaredhanson/passport-browserid) | BrowserID |[Jared Hanson](https://github.com/jaredhanson) |
|[Facebook](https://github.com/jaredhanson/passport-facebook) | OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson) |
|[Google](https://github.com/jaredhanson/passport-google) | OpenID |[Jared Hanson](https://github.com/jaredhanson) |
|[Google](https://github.com/jaredhanson/passport-google-oauth) | OAuth / OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson) |
|[Twitter](https://github.com/jaredhanson/passport-twitter) | OAuth |[Jared Hanson](https://github.com/jaredhanson) |
|[Azure Active Directory](https://github.com/AzureAD/passport-azure-ad) | OAuth 2.0 / OpenID / SAML |[Azure](https://github.com/azuread) |
|[Local](https://github.com/jaredhanson/passport-local) | HTML form |[Jared Hanson](https://github.com/jaredhanson)|
|[OpenID](https://github.com/jaredhanson/passport-openid) | OpenID |[Jared Hanson](https://github.com/jaredhanson)|
|[BrowserID](https://github.com/jaredhanson/passport-browserid) | BrowserID |[Jared Hanson](https://github.com/jaredhanson)|
|[Facebook](https://github.com/jaredhanson/passport-facebook) | OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson)|
|[Google](https://github.com/jaredhanson/passport-google) | OpenID |[Jared Hanson](https://github.com/jaredhanson)|
|[Google](https://github.com/jaredhanson/passport-google-oauth) | OAuth / OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson)|
|[Twitter](https://github.com/jaredhanson/passport-twitter) | OAuth |[Jared Hanson](https://github.com/jaredhanson)|
|[Azure Active Directory](https://github.com/AzureAD/passport-azure-ad)|OAuth 2.0 / OpenID / SAML|[Azure](https://github.com/azuread) |

## Examples

Expand Down

0 comments on commit 04cea41

Please sign in to comment.