Fix missing password policy definitions (#7225)
* improved contribution guide for parameter groups * improved resetTokenReuseIfValid docs * improved resetTokenValidityDuration docs * recreated definitions * improved parameter group wording
This commit is contained in:
@@ -277,11 +277,16 @@ Introducing new Parse Errors requires the following steps:
|
|||||||
Introducing new [Parse Server configuration][config] parameters requires the following steps:
|
Introducing new [Parse Server configuration][config] parameters requires the following steps:
|
||||||
|
|
||||||
1. Add parameters definitions in [/src/Options/index.js][config-index].
|
1. Add parameters definitions in [/src/Options/index.js][config-index].
|
||||||
1. If a nested configuration object has been added, add the environment variable option prefix to `getENVPrefix` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js).
|
2. If the new parameter does not have one single value but is a parameter group (an object containing multiple sub-parameters):
|
||||||
1. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js][config-def] and [/src/Options/docs.js][config-docs].
|
- add the environment variable prefix for the parameter group to `nestedOptionEnvPrefix` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js)
|
||||||
1. Add parameter value validation in [/src/Config.js](https://github.com/parse-community/parse-server/blob/master/src/Config.js).
|
- add the parameter group type to `nestedOptionTypes` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js)
|
||||||
1. Add test cases to ensure the correct parameter value validation. Parse Server throws an error at launch if an invalid value is set for any configuration parameter.
|
|
||||||
1. Execute `npm run docs` to generate the documentation in the `/out` directory. Take a look at the documentation whether the description and formatting of the newly introduced parameters is satisfactory.
|
For example, take a look at the existing Parse Server `security` parameter. It is a parameter group, because it has multiple sub-parameter such as `checkGroups`. Its interface is defined in [index.js][config-index] as `export interface SecurityOptions`. Therefore, the value to add to `nestedOptionTypes` would be `SecurityOptions`, the value to add to `nestedOptionEnvPrefix` would be `PARSE_SERVER_SECURITY_`.
|
||||||
|
|
||||||
|
3. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js][config-def] and [/src/Options/docs.js][config-docs].
|
||||||
|
4. Add parameter value validation in [/src/Config.js](https://github.com/parse-community/parse-server/blob/master/src/Config.js).
|
||||||
|
5. Add test cases to ensure the correct parameter value validation. Parse Server throws an error at launch if an invalid value is set for any configuration parameter.
|
||||||
|
6. Execute `npm run docs` to generate the documentation in the `/out` directory. Take a look at the documentation whether the description and formatting of the newly introduced parameters is satisfactory.
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,37 @@
|
|||||||
*/
|
*/
|
||||||
const parsers = require('../src/Options/parsers');
|
const parsers = require('../src/Options/parsers');
|
||||||
|
|
||||||
|
/** The types of nested options. */
|
||||||
|
const nestedOptionTypes = [
|
||||||
|
'CustomPagesOptions',
|
||||||
|
'DatabaseOptions',
|
||||||
|
'FileUploadOptions',
|
||||||
|
'IdempotencyOptions',
|
||||||
|
'Object',
|
||||||
|
'PagesCustomUrlsOptions',
|
||||||
|
'PagesOptions',
|
||||||
|
'PagesRoute',
|
||||||
|
'PasswordPolicyOptions',
|
||||||
|
'SecurityOptions',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** The prefix of environment variables for nested options. */
|
||||||
|
const nestedOptionEnvPrefix = {
|
||||||
|
'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_',
|
||||||
|
'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_',
|
||||||
|
'DatabaseOptions': 'PARSE_SERVER_DATABASE_',
|
||||||
|
'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_',
|
||||||
|
'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_',
|
||||||
|
'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_',
|
||||||
|
'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_',
|
||||||
|
'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_',
|
||||||
|
'PagesOptions' : 'PARSE_SERVER_PAGES_',
|
||||||
|
'PagesRoute': 'PARSE_SERVER_PAGES_ROUTE_',
|
||||||
|
'ParseServerOptions' : 'PARSE_SERVER_',
|
||||||
|
'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_',
|
||||||
|
'SecurityOptions': 'PARSE_SERVER_SECURITY_',
|
||||||
|
};
|
||||||
|
|
||||||
function last(array) {
|
function last(array) {
|
||||||
return array[array.length - 1];
|
return array[array.length - 1];
|
||||||
}
|
}
|
||||||
@@ -40,23 +71,8 @@ function getCommentValue(comment) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getENVPrefix(iface) {
|
function getENVPrefix(iface) {
|
||||||
const options = {
|
if (nestedOptionEnvPrefix[iface.id.name]) {
|
||||||
'ParseServerOptions' : 'PARSE_SERVER_',
|
return nestedOptionEnvPrefix[iface.id.name]
|
||||||
'PagesOptions' : 'PARSE_SERVER_PAGES_',
|
|
||||||
'PagesRoute': 'PARSE_SERVER_PAGES_ROUTE_',
|
|
||||||
'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_',
|
|
||||||
'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_',
|
|
||||||
'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_',
|
|
||||||
'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_',
|
|
||||||
'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_',
|
|
||||||
'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_',
|
|
||||||
'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_',
|
|
||||||
'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_',
|
|
||||||
'SecurityOptions': 'PARSE_SERVER_SECURITY_',
|
|
||||||
'DatabaseOptions': 'PARSE_SERVER_DATABASE_'
|
|
||||||
}
|
|
||||||
if (options[iface.id.name]) {
|
|
||||||
return options[iface.id.name]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +185,8 @@ function parseDefaultValue(elt, value, t) {
|
|||||||
if (type == 'NumberOrBoolean') {
|
if (type == 'NumberOrBoolean') {
|
||||||
literalValue = t.numericLiteral(parsers.numberOrBoolParser('')(value));
|
literalValue = t.numericLiteral(parsers.numberOrBoolParser('')(value));
|
||||||
}
|
}
|
||||||
const literalTypes = ['Object', 'SecurityOptions', 'PagesRoute', 'IdempotencyOptions','FileUploadOptions','CustomPagesOptions', 'PagesCustomUrlsOptions', 'PagesOptions', 'DatabaseOptions'];
|
|
||||||
if (literalTypes.includes(type)) {
|
if (nestedOptionTypes.includes(type)) {
|
||||||
const object = parsers.objectParser(value);
|
const object = parsers.objectParser(value);
|
||||||
const props = Object.keys(object).map((key) => {
|
const props = Object.keys(object).map((key) => {
|
||||||
return t.objectProperty(key, object[value]);
|
return t.objectProperty(key, object[value]);
|
||||||
|
|||||||
Reference in New Issue
Block a user