Skip to content

Commit 3fdeba2

Browse files
authored
Merge branch 'alpha' into coratgerl/fix-logo-docs
2 parents 6011f28 + 6207a02 commit 3fdeba2

13 files changed

+80
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: ci
22
on:
33
push:
4-
branches: [ release*, alpha, beta ]
4+
branches: [ release, alpha, beta, next-major, 'release-[0-9]+.x.x' ]
55
pull_request:
66
branches:
77
- '**'

.github/workflows/release-automated.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
env:
4343
REGISTRY: docker.io
4444
IMAGE_NAME: parseplatform/parse-server
45-
runs-on: ubuntu-18.04
45+
runs-on: ubuntu-latest
4646
permissions:
4747
contents: read
4848
packages: write
@@ -86,7 +86,7 @@ jobs:
8686
docs:
8787
needs: release
8888
if: needs.release.outputs.current_tag != '' && github.ref == 'refs/heads/release'
89-
runs-on: ubuntu-18.04
89+
runs-on: ubuntu-latest
9090
timeout-minutes: 15
9191
steps:
9292
- uses: actions/checkout@v2

.github/workflows/release-manual-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
IMAGE_NAME: parseplatform/parse-server
1515
jobs:
1616
build:
17-
runs-on: ubuntu-18.04
17+
runs-on: ubuntu-latest
1818
permissions:
1919
contents: read
2020
packages: write

changelogs/CHANGELOG_alpha.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [6.1.0-alpha.8](https://github.com/parse-community/parse-server/compare/6.1.0-alpha.7...6.1.0-alpha.8) (2023-05-01)
2+
3+
4+
### Features
5+
6+
* Allow multiple origins for header `Access-Control-Allow-Origin` ([#8517](https://github.com/parse-community/parse-server/issues/8517)) ([4f15539](https://github.com/parse-community/parse-server/commit/4f15539ac244aa2d393ac5177f7604b43f69e271))
7+
18
# [6.1.0-alpha.7](https://github.com/parse-community/parse-server/compare/6.1.0-alpha.6...6.1.0-alpha.7) (2023-03-10)
29

310

changelogs/CHANGELOG_beta.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# [6.1.0-beta.2](https://github.com/parse-community/parse-server/compare/6.1.0-beta.1...6.1.0-beta.2) (2023-05-01)
2+
3+
4+
### Bug Fixes
5+
6+
* LiveQuery can return incorrectly formatted date ([#8456](https://github.com/parse-community/parse-server/issues/8456)) ([4ce135a](https://github.com/parse-community/parse-server/commit/4ce135a4fe930776044bc8fd786a4e17a0144e03))
7+
* Nested date is incorrectly decoded as empty object `{}` when fetching a Parse Object ([#8446](https://github.com/parse-community/parse-server/issues/8446)) ([22d2446](https://github.com/parse-community/parse-server/commit/22d2446dfea2bc339affc20535d181097e152acf))
8+
* Parameters missing in `afterFind` trigger of authentication adapters ([#8458](https://github.com/parse-community/parse-server/issues/8458)) ([ce34747](https://github.com/parse-community/parse-server/commit/ce34747e8af54cb0b6b975da38f779a5955d2d59))
9+
* Rate limiting across multiple servers via Redis not working ([#8469](https://github.com/parse-community/parse-server/issues/8469)) ([d9e347d](https://github.com/parse-community/parse-server/commit/d9e347d7413f30f58ffbb8397fc8b5ae23be6ff0))
10+
11+
### Features
12+
13+
* Add `afterFind` trigger to authentication adapters ([#8444](https://github.com/parse-community/parse-server/issues/8444)) ([c793bb8](https://github.com/parse-community/parse-server/commit/c793bb88e7485743c7ceb65fe419cde75833ff33))
14+
* Add rate limiting across multiple servers via Redis ([#8394](https://github.com/parse-community/parse-server/issues/8394)) ([34833e4](https://github.com/parse-community/parse-server/commit/34833e42eec08b812b733be78df0535ab0e096b6))
15+
* Allow multiple origins for header `Access-Control-Allow-Origin` ([#8517](https://github.com/parse-community/parse-server/issues/8517)) ([4f15539](https://github.com/parse-community/parse-server/commit/4f15539ac244aa2d393ac5177f7604b43f69e271))
16+
* Export `AuthAdapter` to make it available for extension with custom authentication adapters ([#8443](https://github.com/parse-community/parse-server/issues/8443)) ([40c1961](https://github.com/parse-community/parse-server/commit/40c196153b8efa12ae384c1c0092b2ed60a260d6))
17+
118
# [6.1.0-beta.1](https://github.com/parse-community/parse-server/compare/6.0.0...6.1.0-beta.1) (2023-03-02)
219

320

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-server",
3-
"version": "6.1.0-alpha.7",
3+
"version": "6.1.0-beta.2",
44
"description": "An express module providing a Parse-compatible API server",
55
"main": "lib/index.js",
66
"repository": {

resources/buildConfigDefinitions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ function mapperFor(elt, t) {
161161
if (type == 'NumberOrBoolean') {
162162
return wrap(t.identifier('numberOrBooleanParser'));
163163
}
164+
if (type === 'StringOrStringArray') {
165+
return wrap(t.identifier('arrayParser'));
166+
}
164167
return wrap(t.identifier('objectParser'));
165168
}
166169
}
@@ -278,6 +281,9 @@ function inject(t, list) {
278281
const adapterType = elt.typeAnnotation.typeParameters.params[0].id.name;
279282
type = `Adapter<${adapterType}>`;
280283
}
284+
if (type === 'StringOrStringArray') {
285+
type = 'String|String[]';
286+
}
281287
comments += ` * @property {${type}} ${elt.name} ${elt.help}\n`;
282288
const obj = t.objectExpression(props);
283289
return t.objectProperty(t.stringLiteral(elt.name), obj);

spec/Middlewares.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,35 @@ describe('middlewares', () => {
287287
expect(headers['Access-Control-Allow-Origin']).toEqual('https://parseplatform.org/');
288288
});
289289

290+
it('should support multiple origins if several are defined in allowOrigin as an array', () => {
291+
AppCache.put(fakeReq.body._ApplicationId, {
292+
allowOrigin: ['https://a.com', 'https://b.com', 'https://c.com'],
293+
});
294+
const headers = {};
295+
const res = {
296+
header: (key, value) => {
297+
headers[key] = value;
298+
},
299+
};
300+
const allowCrossDomain = middlewares.allowCrossDomain(fakeReq.body._ApplicationId);
301+
// Test with the first domain
302+
fakeReq.headers.origin = 'https://a.com';
303+
allowCrossDomain(fakeReq, res, () => {});
304+
expect(headers['Access-Control-Allow-Origin']).toEqual('https://a.com');
305+
// Test with the second domain
306+
fakeReq.headers.origin = 'https://b.com';
307+
allowCrossDomain(fakeReq, res, () => {});
308+
expect(headers['Access-Control-Allow-Origin']).toEqual('https://b.com');
309+
// Test with the third domain
310+
fakeReq.headers.origin = 'https://c.com';
311+
allowCrossDomain(fakeReq, res, () => {});
312+
expect(headers['Access-Control-Allow-Origin']).toEqual('https://c.com');
313+
// Test with an unauthorized domain
314+
fakeReq.headers.origin = 'https://unauthorized.com';
315+
allowCrossDomain(fakeReq, res, () => {});
316+
expect(headers['Access-Control-Allow-Origin']).toEqual('https://a.com');
317+
});
318+
290319
it('should use user provided on field userFromJWT', done => {
291320
AppCache.put(fakeReq.body._ApplicationId, {
292321
masterKey: 'masterKey',

src/Options/Definitions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ module.exports.ParseServerOptions = {
8181
},
8282
allowOrigin: {
8383
env: 'PARSE_SERVER_ALLOW_ORIGIN',
84-
help: 'Sets the origin to Access-Control-Allow-Origin',
84+
help:
85+
'Sets origins for Access-Control-Allow-Origin. This can be a string for a single origin or an array of strings for multiple origins.',
86+
action: parsers.arrayParser,
8587
},
8688
analyticsAdapter: {
8789
env: 'PARSE_SERVER_ANALYTICS_ADAPTER',

src/Options/docs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Adapter<T> = string | any | T;
3535
type NumberOrBoolean = number | boolean;
3636
type NumberOrString = number | string;
3737
type ProtectedFields = any;
38+
type StringOrStringArray = string | string[];
3839
type RequestKeywordDenylist = {
3940
key: string | any,
4041
value: any,
@@ -61,8 +62,8 @@ export interface ParseServerOptions {
6162
appName: ?string;
6263
/* Add headers to Access-Control-Allow-Headers */
6364
allowHeaders: ?(string[]);
64-
/* Sets the origin to Access-Control-Allow-Origin */
65-
allowOrigin: ?string;
65+
/* Sets origins for Access-Control-Allow-Origin. This can be a string for a single origin or an array of strings for multiple origins. */
66+
allowOrigin: ?StringOrStringArray;
6667
/* Adapter module for the analytics */
6768
analyticsAdapter: ?Adapter<AnalyticsAdapter>;
6869
/* Adapter module for the files sub-system */

src/middlewares.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,13 @@ export function allowCrossDomain(appId) {
384384
if (config && config.allowHeaders) {
385385
allowHeaders += `, ${config.allowHeaders.join(', ')}`;
386386
}
387-
const allowOrigin = (config && config.allowOrigin) || '*';
388-
res.header('Access-Control-Allow-Origin', allowOrigin);
387+
388+
const baseOrigins =
389+
typeof config?.allowOrigin === 'string' ? [config.allowOrigin] : config?.allowOrigin ?? ['*'];
390+
const requestOrigin = req.headers.origin;
391+
const allowOrigins =
392+
requestOrigin && baseOrigins.includes(requestOrigin) ? requestOrigin : baseOrigins[0];
393+
res.header('Access-Control-Allow-Origin', allowOrigins);
389394
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
390395
res.header('Access-Control-Allow-Headers', allowHeaders);
391396
res.header('Access-Control-Expose-Headers', 'X-Parse-Job-Status-Id, X-Parse-Push-Status-Id');

0 commit comments

Comments
 (0)