Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Deprecation DEPPS5: Config option allowClientClassCreation defaults to false #8849

Merged
merged 14 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
| 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) | removed | - |
| 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) | removed | - |
| DEPPS4 | Remove convenience method for http request `Parse.Cloud.httpRequest` | [#7589](https://github.com/parse-community/parse-server/pull/7589) | 5.0.0 (2022) | 6.0.0 (2023) | removed | - |
| DEPPS5 | Config option `allowClientClassCreation` defaults to `false` | [#7925](https://github.com/parse-community/parse-server/pull/7925) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
| DEPPS5 | Config option `allowClientClassCreation` defaults to `false` | [#7925](https://github.com/parse-community/parse-server/pull/7925) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
| DEPPS6 | Auth providers disabled by default | [#7953](https://github.com/parse-community/parse-server/pull/7953) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
| DEPPS7 | Remove file trigger syntax `Parse.Cloud.beforeSaveFile((request) => {})` | [#7966](https://github.com/parse-community/parse-server/pull/7966) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
| DEPPS8 | Login with expired 3rd party authentication token defaults to `false` | [#7079](https://github.com/parse-community/parse-server/pull/7079) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
Expand Down
28 changes: 28 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4402,3 +4402,31 @@ describe('login as other user', () => {
done();
});
});

describe('allowClientClassCreation option', () => {
it('should enforce boolean values', async () => {
const options = [[], 'a', '', 0, 1, {}, 'true', 'false'];
for (const option of options) {
await expectAsync(reconfigureServer({ allowClientClassCreation: option })).toBeRejected();
}
});

it('should accept true value', async () => {
await reconfigureServer({ allowClientClassCreation: true });
expect(Config.get(Parse.applicationId).allowClientClassCreation).toBe(true);
});

it('should accept false value', async () => {
await reconfigureServer({ allowClientClassCreation: false });
expect(Config.get(Parse.applicationId).allowClientClassCreation).toBe(false);
});

it('should default false', async () => {
// remove predefined allowClientClassCreation:true on global defaultConfiguration
delete defaultConfiguration.allowClientClassCreation;
await reconfigureServer(defaultConfiguration);
expect(Config.get(Parse.applicationId).allowClientClassCreation).toBe(false);
// Need to set it back to true to avoid other test fails
defaultConfiguration.allowClientClassCreation = true;
});
});
1 change: 1 addition & 0 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const defaultConfiguration = {
},
shortLivedAuth: mockShortLivedAuth(),
},
allowClientClassCreation: true,
};

if (process.env.PARSE_SERVER_TEST_CACHE === 'redis') {
Expand Down
8 changes: 8 additions & 0 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class Config {
rateLimit,
databaseOptions,
extendSessionOnUse,
allowClientClassCreation,
}) {
if (masterKey === readOnlyMasterKey) {
throw new Error('masterKey and readOnlyMasterKey should be different');
Expand Down Expand Up @@ -132,6 +133,7 @@ export class Config {
this.validateRateLimit(rateLimit);
this.validateLogLevels(logLevels);
this.validateDatabaseOptions(databaseOptions);
this.validateAllowClientClassCreation(allowClientClassCreation);
}

static validateControllers({
Expand Down Expand Up @@ -174,6 +176,12 @@ export class Config {
}
}

static validateAllowClientClassCreation(allowClientClassCreation) {
if (typeof allowClientClassCreation !== 'boolean') {
throw 'Parse Server option allowClientClassCreation must be a boolean.';
}
}

static validateSecurityOptions(security) {
if (Object.prototype.toString.call(security) !== '[object Object]') {
throw 'Parse Server option security must be an object.';
Expand Down
1 change: 0 additions & 1 deletion src/Deprecator/Deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
* If there are no deprecations, this must return an empty array.
*/
module.exports = [
{ optionKey: 'allowClientClassCreation', changeNewDefault: 'false' },
{ optionKey: 'encodeParseObjectInCloudFunction', changeNewDefault: 'true' },
];
4 changes: 2 additions & 2 deletions src/Options/Definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ module.exports.ParseServerOptions = {
},
allowClientClassCreation: {
env: 'PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION',
help: 'Enable (or disable) client class creation, defaults to true',
help: 'Enable (or disable) client class creation, defaults to false',
action: parsers.booleanParser,
default: true,
default: false,
},
allowCustomObjectId: {
env: 'PARSE_SERVER_ALLOW_CUSTOM_OBJECT_ID',
Expand Down
2 changes: 1 addition & 1 deletion src/Options/docs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ export interface ParseServerOptions {
:ENV: PARSE_SERVER_ENABLE_ANON_USERS
:DEFAULT: true */
enableAnonymousUsers: ?boolean;
/* Enable (or disable) client class creation, defaults to true
/* Enable (or disable) client class creation, defaults to false
:ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION
:DEFAULT: true */
:DEFAULT: false */
allowClientClassCreation: ?boolean;
/* Enable (or disable) custom objectId
:ENV: PARSE_SERVER_ALLOW_CUSTOM_OBJECT_ID
Expand Down
Loading