Skip to content

Commit 3276db3

Browse files
authored
Merge pull request #21 from leaonline/migration/3.0
Migration to Meteor 3.0
2 parents 69af291 + b696430 commit 3276db3

23 files changed

+721
-617
lines changed

.versions

Lines changed: 64 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,65 @@
1-
accounts-base@2.2.10
2-
accounts-password@2.4.0
3-
allow-deny@1.1.1
4-
babel-compiler@7.10.5
5-
babel-runtime@1.5.1
6-
base64@1.0.12
7-
binary-heap@1.0.11
8-
boilerplate-generator@1.7.2
9-
caching-compiler@1.2.2
10-
callback-hook@1.5.1
11-
check@1.3.2
12-
coffeescript@1.0.17
13-
dburles:mongo-collection-instances@0.1.3
14-
ddp@1.4.1
15-
ddp-client@2.6.1
16-
ddp-common@1.4.0
17-
ddp-rate-limiter@1.2.1
18-
ddp-server@2.7.0
19-
diff-sequence@1.1.2
20-
dynamic-import@0.7.3
21-
ecmascript@0.16.8
22-
ecmascript-runtime@0.8.1
23-
ecmascript-runtime-client@0.12.1
24-
ecmascript-runtime-server@0.11.0
25-
ejson@1.1.3
26-
email@2.2.5
27-
fetch@0.1.4
28-
geojson-utils@1.0.11
29-
http@1.4.4
30-
id-map@1.1.1
31-
inter-process-messaging@0.1.1
1+
accounts-base@3.0.4
2+
accounts-password@3.0.3
3+
allow-deny@2.1.0
4+
babel-compiler@7.11.3
5+
babel-runtime@1.5.2
6+
base64@1.0.13
7+
binary-heap@1.0.12
8+
boilerplate-generator@2.0.0
9+
callback-hook@1.6.0
10+
check@1.4.4
11+
core-runtime@1.0.0
12+
dburles:mongo-collection-instances@1.0.0
13+
ddp@1.4.2
14+
ddp-client@3.1.0
15+
ddp-common@1.4.4
16+
ddp-rate-limiter@1.2.2
17+
ddp-server@3.1.0
18+
diff-sequence@1.1.3
19+
dynamic-import@0.7.4
20+
ecmascript@0.16.10
21+
ecmascript-runtime@0.8.3
22+
ecmascript-runtime-client@0.12.2
23+
ecmascript-runtime-server@0.11.1
24+
ejson@1.1.4
25+
email@3.1.2
26+
facts-base@1.0.2
27+
fetch@0.1.5
28+
geojson-utils@1.0.12
29+
id-map@1.2.0
30+
inter-process-messaging@0.1.2
3231
jkuester:http@2.1.0
33-
leaonline:oauth2-server@5.1.0
34-
lmieulet:meteor-coverage@3.2.0
35-
lmieulet:meteor-legacy-coverage@0.1.0
36-
lmieulet:meteor-packages-coverage@0.1.0
37-
local-test:leaonline:oauth2-server@5.1.0
38-
localstorage@1.2.0
39-
logging@1.3.3
40-
meteor@1.11.5
41-
meteortesting:browser-tests@1.3.5
42-
meteortesting:mocha@2.0.3
43-
meteortesting:mocha-core@8.0.1
44-
minimongo@1.9.3
45-
modern-browsers@0.1.10
46-
modules@0.20.0
47-
modules-runtime@0.13.1
48-
mongo@1.16.8
49-
mongo-decimal@0.1.3
50-
mongo-dev-server@1.1.0
51-
mongo-id@1.0.8
52-
npm-mongo@4.17.2
53-
ordered-dict@1.1.0
54-
practicalmeteor:chai@1.9.2_3
55-
promise@0.12.2
56-
random@1.2.1
57-
rate-limit@1.1.1
58-
react-fast-refresh@0.2.8
59-
reactive-var@1.0.12
60-
reload@1.3.1
61-
retry@1.1.0
62-
routepolicy@1.1.1
63-
sha@1.0.9
64-
socket-stream-client@0.5.2
65-
tracker@1.3.3
66-
typescript@4.9.5
67-
underscore@1.6.0
68-
url@1.3.2
69-
webapp@1.13.8
70-
webapp-hashing@1.1.1
32+
lai:collection-extensions@1.0.0
33+
leaonline:oauth2-server@6.0.0
34+
local-test:leaonline:oauth2-server@6.0.0
35+
localstorage@1.2.1
36+
logging@1.3.5
37+
meteor@2.1.0
38+
meteortesting:browser-tests@1.7.0
39+
meteortesting:mocha@3.2.0
40+
meteortesting:mocha-core@8.2.0
41+
minimongo@2.0.2
42+
modern-browsers@0.2.0
43+
modules@0.20.3
44+
modules-runtime@0.13.2
45+
mongo@2.1.0
46+
mongo-decimal@0.2.0
47+
mongo-dev-server@1.1.1
48+
mongo-id@1.0.9
49+
npm-mongo@6.10.2
50+
ordered-dict@1.2.0
51+
promise@1.0.0
52+
random@1.2.2
53+
rate-limit@1.1.2
54+
react-fast-refresh@0.2.9
55+
reactive-var@1.0.13
56+
reload@1.3.2
57+
retry@1.1.1
58+
routepolicy@1.1.2
59+
sha@1.0.10
60+
socket-stream-client@0.6.0
61+
tracker@1.3.4
62+
typescript@5.6.3
63+
url@1.3.5
64+
webapp@2.0.5
65+
webapp-hashing@1.1.2

API.md

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ Uses the following values to check:</p>
4646
<li>&#39;saveRefreshToken&#39;,</li>
4747
<li>&#39;saveToken&#39;,</li>
4848
<li>&#39;getAccessToken&#39;</li>
49+
<li>&#39;revokeToken&#39;</li>
4950
</ul>
5051
</dd>
5152
<dt><a href="#UserValidation">UserValidation</a></dt>
5253
<dd><p>Used to register handlers for different instances that validate users.
5354
This allows you to validate user access on a client-based level.</p>
5455
</dd>
56+
<dt><a href="#validateParams">validateParams</a> ⇒ <code>boolean</code></dt>
57+
<dd><p>Abstraction that checks given query/body params against a given schema</p>
58+
</dd>
5559
<dt><a href="#app">app</a> : <code>Object</code></dt>
5660
<dd><p>Wrapped <code>WebApp</code> with express-style get/post and default use routes.</p>
5761
</dd>
@@ -76,6 +80,8 @@ Implements the OAuth2Server model with Meteor-Mongo bindings.
7680
* [.saveRefreshToken(token, clientId, expires, user)](#OAuthMeteorModel+saveRefreshToken) ⇒ <code>Promise.&lt;\*&gt;</code>
7781
* [.getRefreshToken()](#OAuthMeteorModel+getRefreshToken)
7882
* [.grantTypeAllowed(clientId, grantType)](#OAuthMeteorModel+grantTypeAllowed) ⇒ <code>boolean</code>
83+
* [.verifyScope(accessToken, scope)](#OAuthMeteorModel+verifyScope) ⇒ <code>Promise.&lt;boolean&gt;</code>
84+
* [.revokeToken()](#OAuthMeteorModel+revokeToken)
7985

8086
<a name="OAuthMeteorModel+log"></a>
8187

@@ -199,6 +205,24 @@ getRefreshToken(token) should return an object with:
199205
| clientId |
200206
| grantType |
201207

208+
<a name="OAuthMeteorModel+verifyScope"></a>
209+
210+
### oAuthMeteorModel.verifyScope(accessToken, scope) ⇒ <code>Promise.&lt;boolean&gt;</code>
211+
Compares expected scope from token with actual scope from request
212+
213+
**Kind**: instance method of [<code>OAuthMeteorModel</code>](#OAuthMeteorModel)
214+
215+
| Param |
216+
| --- |
217+
| accessToken |
218+
| scope |
219+
220+
<a name="OAuthMeteorModel+revokeToken"></a>
221+
222+
### oAuthMeteorModel.revokeToken()
223+
revokeToken(refreshToken) is required and should return true
224+
225+
**Kind**: instance method of [<code>OAuthMeteorModel</code>](#OAuthMeteorModel)
202226
<a name="OAuth2ServerDefaults"></a>
203227

204228
## OAuth2ServerDefaults : <code>Object</code>
@@ -250,6 +274,7 @@ Defaults to a 500 response, unless further details were added.
250274
| res | | |
251275
| options | <code>Object</code> | options with error information |
252276
| options.error | <code>String</code> | Error name |
277+
| options.logError | <code>boolean</code> | optional flag to log the erroe to the console |
253278
| options.description | <code>String</code> | Error description |
254279
| options.uri | <code>String</code> | Optional uri to redirect to when error occurs |
255280
| options.status | <code>Number</code> | Optional statuscode, defaults to 500 |
@@ -274,6 +299,7 @@ Uses the following values to check:
274299
- 'saveRefreshToken',
275300
- 'saveToken',
276301
- 'getAccessToken'
302+
- 'revokeToken'
277303

278304
**Kind**: global constant
279305
**Returns**: <code>boolean</code> - true if valid, otherwise false
@@ -289,6 +315,24 @@ Used to register handlers for different instances that validate users.
289315
This allows you to validate user access on a client-based level.
290316

291317
**Kind**: global constant
318+
319+
* [UserValidation](#UserValidation)
320+
* [.register(instance, validationHandler)](#UserValidation.register)
321+
* [.isValid(instance, handlerArgs)](#UserValidation.isValid) ⇒ <code>\*</code>
322+
323+
<a name="UserValidation.register"></a>
324+
325+
### UserValidation.register(instance, validationHandler)
326+
Registers a validation method that allows
327+
to validate users on custom logic.
328+
329+
**Kind**: static method of [<code>UserValidation</code>](#UserValidation)
330+
331+
| Param | Type | Description |
332+
| --- | --- | --- |
333+
| instance | [<code>OAuth2Server</code>](#OAuth2Server) | |
334+
| validationHandler | <code>function</code> | sync or async function that performs the validation |
335+
292336
<a name="UserValidation.isValid"></a>
293337

294338
### UserValidation.isValid(instance, handlerArgs) ⇒ <code>\*</code>
@@ -302,53 +346,23 @@ Delegates `handlerArgs` to the registered validation handler.
302346
| instance | [<code>OAuth2Server</code>](#OAuth2Server) |
303347
| handlerArgs | <code>\*</code> |
304348

305-
<a name="app"></a>
349+
<a name="validateParams"></a>
306350

307-
## app : <code>Object</code>
308-
Wrapped `WebApp` with express-style get/post and default use routes.
351+
## validateParams ⇒ <code>boolean</code>
352+
Abstraction that checks given query/body params against a given schema
309353

310354
**Kind**: global constant
311-
**See**: https://docs.meteor.com/packages/webapp.html
312-
313-
* [app](#app) : <code>Object</code>
314-
* [.get(url, handler)](#app.get)
315-
* [.post(url, handler)](#app.post)
316-
* [.use(args)](#app.use)
317-
318-
<a name="app.get"></a>
319-
320-
### app.get(url, handler)
321-
Creates a get route for a given handler
322-
323-
**Kind**: static method of [<code>app</code>](#app)
324-
325-
| Param | Type |
326-
| --- | --- |
327-
| url | <code>string</code> |
328-
| handler | <code>function</code> |
329-
330-
<a name="app.post"></a>
331-
332-
### app.post(url, handler)
333-
Creates a post route for a given handler.
334-
If headers' content-type does not equal to `application/x-www-form-urlencoded`
335-
then it will be transformed accordingly.
336-
337-
**Kind**: static method of [<code>app</code>](#app)
338-
339-
| Param | Type |
340-
| --- | --- |
341-
| url | <code>string</code> |
342-
| handler | <code>function</code> |
343-
344-
<a name="app.use"></a>
345-
346-
### app.use(args)
347-
Default wrapper around `WebApp.use`
348-
349-
**Kind**: static method of [<code>app</code>](#app)
350355

351356
| Param |
352357
| --- |
353-
| args |
358+
| actualParams |
359+
| requiredParams |
360+
| debug |
361+
362+
<a name="app"></a>
354363

364+
## app : <code>Object</code>
365+
Wrapped `WebApp` with express-style get/post and default use routes.
366+
367+
**Kind**: global constant
368+
**See**: https://docs.meteor.com/packages/webapp.html

HISTORY.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# History
22

3+
### 6.0.0
4+
- Meteor 3 / Express compatibility
5+
- added scope verification in authenticated routes
6+
- improved internal logging
7+
- fix bug in validation for custom models
8+
- fix support for explicit `client.id` field
9+
10+
## 5.0.0
11+
- sync support for @node-oauth/oauth2-server 5.x by
12+
313
## 4.2.1
414
- this is a patch release, fixing a syntax error
515
(that never got picked up, due to wrong linter config)

lib/middleware/getDebugMiddleware.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,29 @@ import { debug } from '../utils/console'
44
* Creates a middleware to debug routes on an instance level
55
* @private
66
* @param instance
7-
* @return {function(*, *, *): *}
7+
* @param options {object?} optional options
8+
* @param options.description {string?} optional way to descrive the next handler
9+
* @param options.data {boolean?} optional flag to log body/query
810
*/
9-
export const getDebugMiddleWare = instance => (req, res, next) => {
10-
if (instance.debug === true) {
11+
export const getDebugMiddleWare = (instance, options = {}) => {
12+
if (!instance.debug) {
13+
return function (req, res, next) { next() }
14+
}
15+
16+
return function (req, res, next) {
1117
const baseUrl = req.originalUrl.split('?')[0]
12-
debug(req.method, baseUrl, req.query || req.body)
18+
let message = `${req.method} ${baseUrl}`
19+
20+
if (options.description) {
21+
message = `${message} (${options.description})`
22+
}
23+
24+
if (options.data) {
25+
const data = { query: req.query, body: req.body }
26+
message = `${message} data: ${data}`
27+
}
28+
29+
debug(message)
30+
next()
1331
}
14-
return next()
1532
}

lib/middleware/secureHandler.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { bind } from '../utils/bind'
88
* @param handler
99
* @return {Function}
1010
*/
11-
export const secureHandler = (self, handler) => bind(function (req, res, next) {
11+
export const secureHandler = (self, handler) => bind(async function (req, res, next) {
1212
const that = this
13-
1413
try {
15-
handler.call(that, req, res, next)
14+
return handler.call(that, req, res, next)
1615
} catch (anyError) {
1716
// to avoid server-crashes we wrap all request handlers and
1817
// catch the error here, creating a default 500 response

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy