Skip to content

Commit 1ccdcc5

Browse files
authored
Merge branch 'master' into modernize-httprequest-spec
2 parents 905baa2 + 484c2e8 commit 1ccdcc5

File tree

12 files changed

+90
-32
lines changed

12 files changed

+90
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ ___
114114
- Added Deprecation Policy to govern the introduction of breaking changes in a phased pattern that is more predictable for developers (Manuel Trezza) [#7199](https://github.com/parse-community/parse-server/pull/7199)
115115
- Add REST API endpoint `/loginAs` to create session of any user with master key; allows to impersonate another user. (GormanFletcher) [#7406](https://github.com/parse-community/parse-server/pull/7406)
116116
- Add official support for MongoDB 5.0 (Manuel Trezza) [#7469](https://github.com/parse-community/parse-server/pull/7469)
117+
- Added Parse Server Configuration `enforcePrivateUsers`, which will remove public access by default on new Parse.Users (dblythy) [#7319](https://github.com/parse-community/parse-server/pull/7319)
117118

118119
### Other Changes
119120
- Support native mongodb syntax in aggregation pipelines (Raschid JF Rafeally) [#7339](https://github.com/parse-community/parse-server/pull/7339)

DEPRECATIONS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
66
|--------|-------------------------------------------------|----------------------------------------------------------------------|---------------------------------|---------------------------------|-----------------------|-------|
77
| DEPPS1 | Native MongoDB syntax in aggregation pipeline | [#7338](https://github.com/parse-community/parse-server/issues/7338) | 5.0.0 (2022) | 6.0.0 (2023) | deprecated | - |
88
| DEPPS2 | Config option `directAccess` defaults to `true` | [#6636](https://github.com/parse-community/parse-server/pull/6636) | 5.0.0 (2022) | 6.0.0 (2023) | deprecated | - |
9+
| DEPPS3 | Config option `enforcePrivateUsers` defaults to `true` | [#7319](https://github.com/parse-community/parse-server/pull/7319) | 5.0.0 (2022) | 6.0.0 (2023) | deprecated | - |
910

1011
[i_deprecation]: ## "The version and date of the deprecation."
1112
[i_removal]: ## "The version and date of the planned removal."

package-lock.json

Lines changed: 3 additions & 3 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
@@ -35,7 +35,7 @@
3535
"follow-redirects": "1.14.1",
3636
"graphql": "15.5.3",
3737
"graphql-list-fields": "2.0.2",
38-
"graphql-relay": "0.8.0",
38+
"graphql-relay": "0.9.0",
3939
"graphql-tag": "2.12.5",
4040
"graphql-upload": "11.0.0",
4141
"intersect": "1.0.1",

spec/ParseUser.spec.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@ const passwordCrypto = require('../lib/password');
1313
const Config = require('../lib/Config');
1414
const cryptoUtils = require('../lib/cryptoUtils');
1515

16-
function verifyACL(user) {
17-
const ACL = user.getACL();
18-
expect(ACL.getReadAccess(user)).toBe(true);
19-
expect(ACL.getWriteAccess(user)).toBe(true);
20-
expect(ACL.getPublicReadAccess()).toBe(true);
21-
expect(ACL.getPublicWriteAccess()).toBe(false);
22-
const perms = ACL.permissionsById;
23-
expect(Object.keys(perms).length).toBe(2);
24-
expect(perms[user.id].read).toBe(true);
25-
expect(perms[user.id].write).toBe(true);
26-
expect(perms['*'].read).toBe(true);
27-
expect(perms['*'].write).not.toBe(true);
28-
}
29-
3016
describe('Parse.User testing', () => {
3117
it('user sign up class method', async done => {
3218
const user = await Parse.User.signUp('asdf', 'zxcv');
@@ -146,7 +132,17 @@ describe('Parse.User testing', () => {
146132
await Parse.User.signUp('asdf', 'zxcv');
147133
const user = await Parse.User.logIn('asdf', 'zxcv');
148134
equal(user.get('username'), 'asdf');
149-
verifyACL(user);
135+
const ACL = user.getACL();
136+
expect(ACL.getReadAccess(user)).toBe(true);
137+
expect(ACL.getWriteAccess(user)).toBe(true);
138+
expect(ACL.getPublicReadAccess()).toBe(true);
139+
expect(ACL.getPublicWriteAccess()).toBe(false);
140+
const perms = ACL.permissionsById;
141+
expect(Object.keys(perms).length).toBe(2);
142+
expect(perms[user.id].read).toBe(true);
143+
expect(perms[user.id].write).toBe(true);
144+
expect(perms['*'].read).toBe(true);
145+
expect(perms['*'].write).not.toBe(true);
150146
done();
151147
});
152148

@@ -3934,6 +3930,31 @@ describe('Parse.User testing', () => {
39343930
}
39353931
});
39363932

3933+
it('should throw when enforcePrivateUsers is invalid', async () => {
3934+
const options = [[], 'a', 0, {}];
3935+
for (const option of options) {
3936+
await expectAsync(reconfigureServer({ enforcePrivateUsers: option })).toBeRejected();
3937+
}
3938+
});
3939+
3940+
it('user login with enforcePrivateUsers', async done => {
3941+
await reconfigureServer({ enforcePrivateUsers: true });
3942+
await Parse.User.signUp('asdf', 'zxcv');
3943+
const user = await Parse.User.logIn('asdf', 'zxcv');
3944+
equal(user.get('username'), 'asdf');
3945+
const ACL = user.getACL();
3946+
expect(ACL.getReadAccess(user)).toBe(true);
3947+
expect(ACL.getWriteAccess(user)).toBe(true);
3948+
expect(ACL.getPublicReadAccess()).toBe(false);
3949+
expect(ACL.getPublicWriteAccess()).toBe(false);
3950+
const perms = ACL.permissionsById;
3951+
expect(Object.keys(perms).length).toBe(1);
3952+
expect(perms[user.id].read).toBe(true);
3953+
expect(perms[user.id].write).toBe(true);
3954+
expect(perms['*']).toBeUndefined();
3955+
done();
3956+
});
3957+
39373958
describe('issue #4897', () => {
39383959
it_only_db('mongo')('should be able to login with a legacy user (no ACL)', async () => {
39393960
// This issue is a side effect of the locked users and legacy users which don't have ACL's

src/Config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class Config {
7575
fileUpload,
7676
pages,
7777
security,
78+
enforcePrivateUsers,
7879
}) {
7980
if (masterKey === readOnlyMasterKey) {
8081
throw new Error('masterKey and readOnlyMasterKey should be different');
@@ -111,6 +112,13 @@ export class Config {
111112
this.validateIdempotencyOptions(idempotencyOptions);
112113
this.validatePagesOptions(pages);
113114
this.validateSecurityOptions(security);
115+
this.validateEnforcePrivateUsers(enforcePrivateUsers);
116+
}
117+
118+
static validateEnforcePrivateUsers(enforcePrivateUsers) {
119+
if (typeof enforcePrivateUsers !== 'boolean') {
120+
throw 'Parse Server option enforcePrivateUsers must be a boolean.';
121+
}
114122
}
115123

116124
static validateSecurityOptions(security) {

src/Deprecator/Deprecations.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* The deprecations.
33
*
44
* Add deprecations to the array using the following keys:
5-
* - `optionKey`: The option key incl. its path, e.g. `security.enableCheck`.
6-
* - `envKey`: The environment key, e.g. `PARSE_SERVER_SECURITY`.
7-
* - `changeNewKey`: Set the new key name if the current key will be replaced,
5+
* - `optionKey` {String}: The option key incl. its path, e.g. `security.enableCheck`.
6+
* - `envKey` {String}: The environment key, e.g. `PARSE_SERVER_SECURITY`.
7+
* - `changeNewKey` {String}: Set the new key name if the current key will be replaced,
88
* or set to an empty string if the current key will be removed without replacement.
9-
* - `changeNewDefault`: Set the new default value if the key's default value
9+
* - `changeNewDefault` {String}: Set the new default value if the key's default value
1010
* will change in a future version.
1111
* - `solution`: The instruction to resolve this deprecation warning. Optional. This
1212
* instruction must not include the deprecation warning which is auto-generated.
@@ -22,4 +22,5 @@ module.exports = [
2222
solution:
2323
"Additionally, the environment variable 'PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS' will be deprecated and renamed to 'PARSE_SERVER_DIRECT_ACCESS' in a future version; it is currently possible to use either one.",
2424
},
25+
{ optionKey: 'enforcePrivateUsers', changeNewDefault: 'true' },
2526
];

src/Options/Definitions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ module.exports.ParseServerOptions = {
154154
env: 'PARSE_SERVER_ENCRYPTION_KEY',
155155
help: 'Key for encrypting your files',
156156
},
157+
enforcePrivateUsers: {
158+
env: 'PARSE_SERVER_ENFORCE_PRIVATE_USERS',
159+
help: 'Set to true if new users should be created without public read and write access.',
160+
action: parsers.booleanParser,
161+
default: false,
162+
},
157163
expireInactiveSessions: {
158164
env: 'PARSE_SERVER_EXPIRE_INACTIVE_SESSIONS',
159165
help:

src/Options/docs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @property {Boolean} enableAnonymousUsers Enable (or disable) anonymous users, defaults to true
2929
* @property {Boolean} enableExpressErrorHandler Enables the default express error handler for all errors
3030
* @property {String} encryptionKey Key for encrypting your files
31+
* @property {Boolean} enforcePrivateUsers Set to true if new users should be created without public read and write access.
3132
* @property {Boolean} expireInactiveSessions Sets whether we should expire the inactive sessions, defaults to true. If false, all new sessions are created with no expiration date.
3233
* @property {String} fileKey Key for your files
3334
* @property {Adapter<FilesAdapter>} filesAdapter Adapter module for the files sub-system

src/Options/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ export interface ParseServerOptions {
246246
/* The security options to identify and report weak security settings.
247247
:DEFAULT: {} */
248248
security: ?SecurityOptions;
249+
/* Set to true if new users should be created without public read and write access.
250+
:DEFAULT: false */
251+
enforcePrivateUsers: ?boolean;
249252
}
250253

251254
export interface SecurityOptions {

0 commit comments

Comments
 (0)