Skip to content

Commit 9c9de00

Browse files
author
Sam Bacha
committed
merge
2 parents 74a4260 + 36275b5 commit 9c9de00

File tree

168 files changed

+18007
-7902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+18007
-7902
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_style = space
8+
indent_size = 2
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = off
14+
trim_trailing_whitespace = false

.gitignore

100644100755
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
node_modules/
1+
2+
# IDE
3+
/.idea
4+
/.awcache
5+
/.vscode/*.code-workspace
6+
/.vscode/settings.json
7+
8+
# misc
9+
npm-debug.log
10+
11+
# folders
12+
/dist
13+
/node_modules
214
docs/_build/
315
__pycache__/
16+
17+
# files
18+
.DS_Store
419
*.pyc
20+
/aio
521

22+
# codecoverage
23+
/.nyc_output
24+
/coverage

.jshintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.jshintrc

Lines changed: 0 additions & 26 deletions
This file was deleted.

.nycrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "@istanbuljs/nyc-config-typescript",
3+
"all": true,
4+
"reporter": [
5+
"lcovonly",
6+
"html",
7+
"text",
8+
"text-summary"
9+
]
10+
}

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"endOfLine": "lf"
5+
}

.travis.yml

100644100755
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
language: node_js
22

33
node_js:
4-
- 4
5-
- 4.0
6-
- 6
7-
- 6.0
8-
- 7
9-
- 7.0
104
- 8
11-
- 8.0
5+
- 10
6+
- 12
127

138
sudo: false

.vscode/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# VSCode Configuration
2+
3+
This folder contains opt-in [Workspace Settings](https://code.visualstudio.com/docs/getstarted/settings) and [Extension Recommendations](https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions) that our team recommends using when working on this repository.
4+
5+
## Usage
6+
7+
To use the recommended settings follow the steps below:
8+
9+
- copy `.vscode/recommended-settings.json` to `.vscode/settings.json`
10+
- restart the editor
11+
12+
If you already have your custom workspace settings you should instead manually merge the file content.
13+
14+
This isn't an automatic process so you will need to repeat it when settings are updated.
15+
16+
To see the recommended extensions select "Extensions: Show Recommended Extensions" in the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
17+
18+
## Editing `.vscode/recommended-settings.json`
19+
20+
If you wish to add extra configuration items please keep in mind any settings you add here will be used by many users.
21+
22+
Try to keep these settings to things that help facilitate the development process and avoid altering the user workflow whenever possible.

.vscode/extensions.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": [
7+
"editorconfig.editorconfig",
8+
"esbenp.prettier-vscode",
9+
"ms-vscode.vscode-typescript-tslint-plugin"
10+
]
11+
}

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Mocha Tests",
8+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
9+
"args": [
10+
"--require",
11+
"ts-node/register",
12+
"-u",
13+
"tdd",
14+
"--timeout",
15+
"999999",
16+
"--colors",
17+
"--recursive",
18+
"${workspaceFolder}/test/**/*.spec.ts"
19+
],
20+
"internalConsoleOptions": "openOnSessionStart"
21+
}
22+
]
23+
}

.vscode/recommended-settings.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"**/.DS_Store": true,
5+
"**/node_modules": true,
6+
"dist": true
7+
},
8+
"files.watcherExclude": {
9+
"**/.git/**": true,
10+
"**/node_modules/**": true,
11+
"**/dist/**": true
12+
},
13+
"search.exclude": {
14+
"**/node_modules": true,
15+
"**/dist": true
16+
},
17+
"editor.formatOnSave": false,
18+
"typescript.format.enable": false,
19+
"editor.formatOnPaste": false,
20+
"[typescript]": {
21+
"editor.formatOnSave": true,
22+
"editor.codeActionsOnSave": {
23+
"source.organizeImports": true,
24+
"source.fixAll.tslint": true
25+
}
26+
},
27+
"[json]": {
28+
"editor.formatOnSave": true
29+
},
30+
"[jsonc]": {
31+
"editor.formatOnSave": true
32+
},
33+
"[javascript]": {
34+
"editor.formatOnSave": true
35+
},
36+
"prettier.singleQuote": true,
37+
"prettier.trailingComma": "all",
38+
"prettier.printWidth": 80
39+
}

CHANGELOG.md

100644100755
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
## Changelog
22

3+
### 5.0.0
4+
* BREAKING: Remove support for node v6
5+
* BREAKING: Remove support for callbacks only support native Promises
6+
* new: Rewrote in TypeScript
7+
* new: Switch from Eslint to Tslint
8+
* new: added .vscode folder for recommend extensions and recommend setting required for development
9+
* new: added suitable TypeScript Interfaces for various Objects
10+
11+
### 4.0.0
12+
* BREAKING: Set server_error Code to 500
13+
* BREAKING: Remove support for node v4
14+
* new: Added revoke-handler to revoke access token
15+
* new: Added implicit grant flow
16+
* new: Switch from jshint to eslin
17+
* fix: authorization_code grant should not be required in implicit flowt
18+
19+
### 3.1.0
20+
* new: Added package-lock.json
21+
* new: Extend model object with request context
22+
* new: .npmignore tests
23+
* fix: validate requested scope on authorize request
24+
* fix: issue correct expiry dates for tokens
25+
* fix: set numArgs for promisify of generateAuthorizationCode
26+
* fix: Changed 'hasOwnProperty' call in Response
27+
* docs: Ensure accessTokenExpiresAt is required
28+
* docs: Add missing notice of breaking change for accessExpireLifetime to migration guide
29+
* docs: Correct tokens time scale for 2.x to 3.x migration guide
30+
* readme: Update Slack badge and link
31+
* readme: Fix link to RFC6750 standard
32+
33+
### 3.0.1
34+
* Updated dependencies
35+
336
### 3.0.0
437
* Complete re-write, with Promises and callback support
538
* Dropped support for node v0.8, v0.10, v0.12

LICENSE

100644100755
File mode changed.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ The *oauth2-server* module is framework-agnostic but there are several officiall
2020

2121
## Features
2222

23-
- Supports `authorization_code`, `client_credentials`, `refresh_token` and `password` grant, as well as *extension grants*, with scopes.
23+
- Supports `authorization_code`, `client_credentials`, `refresh_token`, `implicit` and `password` grant, as well as *extension grants*, with scopes.
2424
- Can be used with *promises*, *Node-style callbacks*, *ES6 generators* and *async*/*await* (using [Babel](https://babeljs.io)).
25-
- Fully [RFC 6749](https://tools.ietf.org/html/rfc6749.html) and [RFC 6750](https://tools.ietf.org/html/rfc6749.html) compliant.
25+
- Fully [RFC 6749](https://tools.ietf.org/html/rfc6749.html) and [RFC 6750](https://tools.ietf.org/html/rfc6750.html) compliant.
2626
- Implicitly supports any form of storage, e.g. *PostgreSQL*, *MySQL*, *MongoDB*, *Redis*, etc.
2727
- Complete [test suite](https://github.com/oauthjs/node-oauth2-server/tree/master/test).
2828

@@ -63,6 +63,6 @@ npm test
6363
[travis-url]: https://travis-ci.org/oauthjs/node-oauth2-server
6464
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
6565
[license-url]: https://raw.githubusercontent.com/oauthjs/node-oauth2-server/master/LICENSE
66-
[slack-image]: https://img.shields.io/badge/slack-join-E01563.svg
67-
[slack-url]: https://oauthjs.slack.com
66+
[slack-image]: https://slack.oauthjs.org/badge.svg
67+
[slack-url]: https://slack.oauthjs.org
6868

TODO

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Todo:
3+
✔ Add a todo
4+
✔ A Basic Rewrite of library in TypeScript
5+
✔ A Basic Rewrite of tests in TypeScript
6+
☐ Add examples for nestjs, expressjs, koa and others
7+
☐ Add Migration guide
8+
☐ Review all Docs

docs/api/oauth2-server.rst

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,27 @@ Authorizes a token request.
128128

129129
**Arguments:**
130130

131-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
132-
| Name | Type | Description |
133-
+=========================================+=================+=============================================================================+
134-
| request | :doc:`request` | Request object. |
135-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
136-
| [request.query.allowed=undefined] | String | ``'false'`` to deny the authorization request (see remarks section). |
137-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
138-
| response | :doc:`response` | Response object. |
139-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
140-
| [options={}] | Object | Handler options. |
141-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
142-
| [options.authenticateHandler=undefined] | Object | The authenticate handler (see remarks section). |
143-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
144-
| [options.allowEmptyState=false] | Boolean | Allow clients to specify an empty ``state``. |
145-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
146-
| [options.authorizationCodeLifetime=300] | Number | Lifetime of generated authorization codes in seconds (default = 5 minutes). |
147-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
148-
| [callback=undefined] | Function | Node-style callback to be used instead of the returned ``Promise``. |
149-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
131+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
132+
| Name | Type | Description |
133+
+=========================================+=================+================================================================================+
134+
| request | :doc:`request` | Request object. |
135+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
136+
| [request.query.allowed=undefined] | String | ``'false'`` to deny the authorization request (see remarks section). |
137+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
138+
| response | :doc:`response` | Response object. |
139+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
140+
| [options={}] | Object | Handler options. |
141+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
142+
| [options.authenticateHandler=undefined] | Object | The authenticate handler (see remarks section). |
143+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
144+
| [options.allowEmptyState=false] | Boolean | Allow clients to specify an empty ``state``. |
145+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
146+
| [options.authorizationCodeLifetime=300] | Number | Lifetime of generated authorization codes in seconds (default = 5 minutes). |
147+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
148+
| [options.accessTokenLifetime=3600] | Number | Lifetime of generated implicit grant access token in seconds (default = 1 hr). |
149+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
150+
| [callback=undefined] | Function | Node-style callback to be used instead of the returned ``Promise``. |
151+
+-----------------------------------------+-----------------+--------------------------------------------------------------------------------+
150152

151153
**Return value:**
152154

docs/misc/migrating-v2-to-v3.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@ The naming of the exposed middlewares has changed to match the OAuth2 _RFC_ more
2828
Server options
2929
--------------
3030

31-
The following server options can be set when instantiating the OAuth service:
31+
The following server options can be set when instantiating the OAuth service:
3232

3333
* `addAcceptedScopesHeader`: **default true** Add the `X-Accepted-OAuth-Scopes` header with a list of scopes that will be accepted
3434
* `addAuthorizedScopesHeader`: **default true** Add the `X-OAuth-Scopes` header with a list of scopes that the user is authorized for
3535
* `allowBearerTokensInQueryString`: **default false** Determine if the bearer token can be included in the query string (i.e. `?access_token=`) for validation calls
3636
* `allowEmptyState`: **default false** If true, `state` can be empty or not passed. If false, `state` is required.
37-
* `authorizationCodeLifetime`: **default 300** Default number of milliseconds that the authorization code is active for
38-
* `accessTokenLifetime`: **default 3600** Default number of milliseconds that an access token is valid for
39-
* `refreshTokenLifetime`: **default 1209600** Default number of milliseconds that a refresh token is valid for
37+
* `authorizationCodeLifetime`: **default 300** Default number of seconds that the authorization code is active for
38+
* `accessTokenLifetime`: **default 3600** Default number of seconds that an access token is valid for
39+
* `refreshTokenLifetime`: **default 1209600** Default number of seconds that a refresh token is valid for
4040
* `allowExtendedTokenAttributes`: **default false** Allows additional attributes (such as `id_token`) to be included in token responses.
41-
* `requireClientAuthentication`: **default true for all grant types** Allow ability to set client/secret authentication to `false` for a specific grant type.
41+
* `requireClientAuthentication`: **default true for all grant types** Allow ability to set client/secret authentication to `false` for a specific grant type.
4242

43-
The following server options have been removed in v3.0.0
43+
The following server options have changed behavior in v3.0.0:
44+
45+
* `accessTokenLifetime` can no longer be set to `null` to indicate a non-expiring token. The recommend alternative is to set accessTokenLifetime to a high value.
46+
47+
The following server options have been removed in v3.0.0:
4448

4549
* `grants`: **removed** (now returned by the `getClient` method).
4650
* `debug`: **removed** (not the responsibility of this module).
@@ -56,7 +60,7 @@ Model specification
5660
* `generateAuthorizationCode()` is **optional** and should return a `String`.
5761
* `generateRefreshToken(client, user, scope)` is **optional** and should return a `String`.
5862
* `getAccessToken(token)` should return an object with:
59-
63+
6064
* `accessToken` (`String`)
6165
* `accessTokenExpiresAt` (`Date`)
6266
* `client` (`Object`), containing at least an `id` property that matches the supplied client
@@ -71,7 +75,7 @@ Model specification
7175
* `user` (`Object`)
7276

7377
* `getClient(clientId, clientSecret)` should return an object with, at minimum:
74-
78+
7579
* `redirectUris` (`Array`)
7680
* `grants` (`Array`)
7781

@@ -84,11 +88,11 @@ Model specification
8488
* `user` (`Object`)
8589

8690
* `getUser(username, password)` should return an object:
87-
91+
8892
* No longer requires that `id` be returned.
8993

9094
* `getUserFromClient(client)` should return an object:
91-
95+
9296
* No longer requires that `id` be returned.
9397

9498
* `grantTypeAllowed()` was **removed**. You can instead:

0 commit comments

Comments
 (0)