From 5ccd0923b9b2df958d209a7329a0f9a4608f2e8c Mon Sep 17 00:00:00 2001 From: dblythy Date: Thu, 17 Nov 2022 10:24:41 +1100 Subject: [PATCH 1/5] fix: add ipv6 localhost to masterKeyIps --- src/Options/Definitions.js | 2 +- src/Options/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index e25c2e53bc..bf89faed28 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -305,7 +305,7 @@ module.exports.ParseServerOptions = { help: "(Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1']` which means that only `localhost`, the server itself, is allowed to use the master key.", action: parsers.arrayParser, - default: ['127.0.0.1'], + default: ['127.0.0.1', '::1'], }, maxLimit: { env: 'PARSE_SERVER_MAX_LIMIT', diff --git a/src/Options/index.js b/src/Options/index.js index 8b6d4c019e..dd60e7cba7 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -50,7 +50,7 @@ export interface ParseServerOptions { :ENV: PARSE_SERVER_URL */ serverURL: string; /* (Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1']` which means that only `localhost`, the server itself, is allowed to use the master key. - :DEFAULT: ["127.0.0.1"] */ + :DEFAULT: ["127.0.0.1","::1"] */ masterKeyIps: ?(string[]); /* Sets the app name */ appName: ?string; From db824994733a46dcc77142943374c6727470b9aa Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 23 Nov 2022 12:53:23 +1100 Subject: [PATCH 2/5] Update index.spec.js --- spec/index.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/index.spec.js b/spec/index.spec.js index d28d532861..af79e2d7ef 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -508,6 +508,11 @@ describe('server', () => { }).then(done); }); + it('should set default masterKeyIps', () => { + const definitions = require('../lib/Options/Definitions.js'); + expect(definitions.ParseServerOptions.masterKeyIps.default).toEqual(['127.0.0.1', '::1']); + }); + it('should load a middleware', done => { const obj = { middleware: function (req, res, next) { From 603a7abd488b88f101eed4d45836e6715ffab876 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 24 Nov 2022 13:01:00 +1100 Subject: [PATCH 3/5] Update src/Options/index.js Co-authored-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- src/Options/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Options/index.js b/src/Options/index.js index 847bbf8101..7998f0ee09 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -49,7 +49,7 @@ export interface ParseServerOptions { /* URL to your parse server with http:// or https://. :ENV: PARSE_SERVER_URL */ serverURL: string; - /* (Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1']` which means that only `localhost`, the server itself, is allowed to use the master key. + /* (Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server itself, is allowed to use the master key. :DEFAULT: ["127.0.0.1","::1"] */ masterKeyIps: ?(string[]); /* Sets the app name */ From ba7e20d81e6564bcb752ddd660eb3e4173d4e726 Mon Sep 17 00:00:00 2001 From: dblythy Date: Thu, 24 Nov 2022 13:01:32 +1100 Subject: [PATCH 4/5] definitions --- src/Options/Definitions.js | 2 +- src/Options/docs.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index 429417b90d..548f40e3ed 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -303,7 +303,7 @@ module.exports.ParseServerOptions = { masterKeyIps: { env: 'PARSE_SERVER_MASTER_KEY_IPS', help: - "(Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1']` which means that only `localhost`, the server itself, is allowed to use the master key.", + "(Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server itself, is allowed to use the master key.", action: parsers.arrayParser, default: ['127.0.0.1', '::1'], }, diff --git a/src/Options/docs.js b/src/Options/docs.js index 6c22e91e2e..fa67846a64 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -58,7 +58,7 @@ * @property {String} logLevel Sets the level for logs * @property {String} logsFolder Folder for the logs (defaults to './logs'); set to null to disable file based logging * @property {String} masterKey Your Parse Master Key - * @property {String[]} masterKeyIps (Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1']` which means that only `localhost`, the server itself, is allowed to use the master key. + * @property {String[]} masterKeyIps (Optional) Restricts the use of master key permissions to a list of IP addresses.

This option accepts a list of single IP addresses, for example:
`['10.0.0.1', '10.0.0.2']`

You can also use CIDR notation to specify an IP address range, for example:
`['10.0.1.0/24']`

Special cases:
- Setting an empty array `[]` means that `masterKey`` cannot be used even in Parse Server Cloud Code.
- Setting `['0.0.0.0/0']` means disabling the filter and the master key can be used from any IP address.

To connect Parse Dashboard from a different server requires to add the IP address of the server that hosts Parse Dashboard because Parse Dashboard uses the master key.

Defaults to `['127.0.0.1', '::1']` which means that only `localhost`, the server itself, is allowed to use the master key. * @property {Number} maxLimit Max value for limit option on queries, defaults to unlimited * @property {Number|String} maxLogFiles Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null) * @property {String} maxUploadSize Max file size for uploads, defaults to 20mb From f6fbe32bb7790b5fc74edc879da723ba9221b297 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 24 Nov 2022 13:01:52 +1100 Subject: [PATCH 5/5] Update spec/index.spec.js Co-authored-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- spec/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/index.spec.js b/spec/index.spec.js index af79e2d7ef..ffeb694fd4 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -508,7 +508,7 @@ describe('server', () => { }).then(done); }); - it('should set default masterKeyIps', () => { + it('should set default masterKeyIps for IPv4 and IPv6 localhost', () => { const definitions = require('../lib/Options/Definitions.js'); expect(definitions.ParseServerOptions.masterKeyIps.default).toEqual(['127.0.0.1', '::1']); });