Skip to content

Commit d50cb2d

Browse files
authored
fix: use array scope and do not ignore scope on refresh token call
Merge pull request #238 from jorenvandeweyer/feature/scope-validation thanks to @jorenvandeweyer
2 parents 9c8c05b + 0d4e5f3 commit d50cb2d

32 files changed

+397
-379
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- this is a breaking change, because **it removes callback support** for
99
`OAuthServer` and your model implementation.
1010
- fixed missing await in calling generateAuthorizationCode in AuthorizeHandler
11+
- validate scope as an array of strings
1112

1213
## 4.2.0
1314
### Fixed
@@ -52,7 +53,7 @@
5253
- Upgrades all code from ES5 to ES6, where possible.
5354

5455
## 4.1.0
55-
### Changed
56+
### Changed
5657
* Bump dev dependencies to resolve vulnerabilities
5758
* Replaced jshint with eslint along with should and chai
5859
* Use sha256 when generating tokens

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ If you're using one of those frameworks it is strongly recommended to use the re
2727
## Features
2828

2929
- Supports `authorization_code`, `client_credentials`, `refresh_token` and `password` grant, as well as *extension grants*, with scopes.
30-
- Can be used with *promises*, *Node-style callbacks*, *ES6 generators* and *async*/*await* (using [Babel](https://babeljs.io)).
30+
- Can be used with *promises*, *ES6 generators* and *async*/*await* (using [Babel](https://babeljs.io)).
3131
- Fully [RFC 6749](https://tools.ietf.org/html/rfc6749.html) and [RFC 6750](https://tools.ietf.org/html/rfc6750.html) compliant.
3232
- Implicitly supports any form of storage, e.g. *PostgreSQL*, *MySQL*, *MongoDB*, *Redis*, etc.
3333
- Support for PKCE

docs/api/oauth2-server.rst

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Advanced example with additional options:
5757

5858
.. _OAuth2Server#authenticate:
5959

60-
``authenticate(request, response, [options], [callback])``
60+
``authenticate(request, response, [options])``
6161
==========================================================
6262

6363
Authenticates a request.
@@ -73,16 +73,14 @@ Authenticates a request.
7373
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
7474
| [options={}] | Object | Handler options. |
7575
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
76-
| [options.scope=undefined] | String | The scope(s) to authenticate. |
76+
| [options.scope=undefined] | String[] | The scope(s) to authenticate. |
7777
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
7878
| [options.addAcceptedScopesHeader=true] | Boolean | Set the ``X-Accepted-OAuth-Scopes`` HTTP header on response objects. |
7979
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
8080
| [options.addAuthorizedScopesHeader=true] | Boolean | Set the ``X-OAuth-Scopes`` HTTP header on response objects. |
8181
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
8282
| [options.allowBearerTokensInQueryString=false] | Boolean | Allow clients to pass bearer tokens in the query string of a request. |
8383
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
84-
| [callback=undefined] | Function | Node-style callback to be used instead of the returned ``Promise``. |
85-
+------------------------------------------------+-----------------+-----------------------------------------------------------------------+
8684

8785
**Return value:**
8886

@@ -94,8 +92,6 @@ Possible errors include but are not limited to:
9492
:doc:`/api/errors/unauthorized-request-error`:
9593
The protected resource request failed authentication.
9694

97-
The returned ``Promise`` **must** be ignored if ``callback`` is used.
98-
9995
**Remarks:**
10096

10197
::
@@ -121,7 +117,7 @@ The returned ``Promise`` **must** be ignored if ``callback`` is used.
121117

122118
.. _OAuth2Server#authorize:
123119

124-
``authorize(request, response, [options], [callback])``
120+
``authorize(request, response, [options])``
125121
=======================================================
126122

127123
Authorizes a token request.
@@ -145,8 +141,6 @@ Authorizes a token request.
145141
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
146142
| [options.authorizationCodeLifetime=300] | Number | Lifetime of generated authorization codes in seconds (default = 5 minutes). |
147143
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
148-
| [callback=undefined] | Function | Node-style callback to be used instead of the returned ``Promise``. |
149-
+-----------------------------------------+-----------------+-----------------------------------------------------------------------------+
150144

151145
**Return value:**
152146

@@ -158,8 +152,6 @@ Possible errors include but are not limited to:
158152
:doc:`/api/errors/access-denied-error`
159153
The resource owner denied the access request (i.e. ``request.query.allow`` was ``'false'``).
160154

161-
The returned ``Promise`` **must** be ignored if ``callback`` is used.
162-
163155
**Remarks:**
164156

165157
If ``request.query.allowed`` equals the string ``'false'`` the access request is denied and the returned promise is rejected with an :doc:`/api/errors/access-denied-error`.
@@ -211,7 +203,7 @@ When working with a session-based login mechanism, the handler can simply look l
211203

212204
.. _OAuth2Server#token:
213205

214-
``token(request, response, [options], [callback])``
206+
``token(request, response, [options])``
215207
===================================================
216208

217209
Retrieves a new token for an authorized token request.
@@ -239,8 +231,6 @@ Retrieves a new token for an authorized token request.
239231
+----------------------------------------------+-----------------+-------------------------------------------------------------------------------------------+
240232
| [options.extendedGrantTypes={}] | Object | Additional supported grant types. |
241233
+----------------------------------------------+-----------------+-------------------------------------------------------------------------------------------+
242-
| [callback=undefined] | Function | Node-style callback to be used instead of the returned ``Promise``. |
243-
+----------------------------------------------+-----------------+-------------------------------------------------------------------------------------------+
244234

245235
**Return value:**
246236

@@ -252,8 +242,6 @@ Possible errors include but are not limited to:
252242
:doc:`/api/errors/invalid-grant-error`:
253243
The access token request was invalid or not authorized.
254244

255-
The returned ``Promise`` **must** be ignored if ``callback`` is used.
256-
257245
**Remarks:**
258246

259247
If ``options.allowExtendedTokenAttributes`` is ``true`` any additional properties set on the object returned from :ref:`Model#saveToken() <Model#saveToken>` are copied to the token response sent to the client.

docs/docs/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Features
2828
========
2929

3030
- Supports :ref:`authorization code <AuthorizationCodeGrant>`, :ref:`client credentials <ClientCredentialsGrant>`, :ref:`refresh token <RefreshTokenGrant>` and :ref:`password <PasswordGrant>` grant, as well as :ref:`extension grants <ExtensionGrants>`, with scopes.
31-
- Can be used with *promises*, *Node-style callbacks*, *ES6 generators* and *async*/*await* (using Babel_).
31+
- Can be used with *promises*, *ES6 generators* and *async*/*await* (using Babel_).
3232
- Fully :rfc:`6749` and :rfc:`6750` compliant.
3333
- Implicitly supports any form of storage, e.g. *PostgreSQL*, *MySQL*, *MongoDB*, *Redis*, etc.
3434
- Complete `test suite`_.

0 commit comments

Comments
 (0)