Skip to content

Commit b11cc20

Browse files
committed
removed simple-mailgun-adapter from README
also cleaned up readme and definitions of password / account policy
1 parent 58c0b08 commit b11cc20

File tree

4 files changed

+161
-106
lines changed

4 files changed

+161
-106
lines changed

README.md

+44-58
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The full documentation for Parse Server is available in the [wiki](https://githu
5858
- [Basic Options](#basic-options)
5959
- [Client Key Options](#client-key-options)
6060
- [Email Verification and Password Reset](#email-verification-and-password-reset)
61+
- [Password and Account Policy](#password-and-account-policy)
6162
- [Custom Routes](#custom-routes)
6263
- [Example](#example)
6364
- [Reserved Paths](#reserved-paths)
@@ -313,76 +314,32 @@ The client keys used with Parse are no longer necessary with Parse Server. If yo
313314

314315
## Email Verification and Password Reset
315316

316-
Verifying user email addresses and enabling password reset via email requires an email adapter. As part of the `parse-server` package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
317+
Verifying user email addresses and enabling password reset via email requires an email adapter. There are many email adapters provided and maintained by the community. The following is an example configuration with an example email adapter. See the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) for more details and a full list of available options.
317318

318319
```js
319-
var server = ParseServer({
320+
const server = ParseServer({
320321
...otherOptions,
322+
321323
// Enable email verification
322324
verifyUserEmails: true,
323325

324-
// if `verifyUserEmails` is `true` and
325-
// if `emailVerifyTokenValidityDuration` is `undefined` then
326-
// email verify token never expires
327-
// else
328-
// email verify token expires after `emailVerifyTokenValidityDuration`
329-
//
330-
// `emailVerifyTokenValidityDuration` defaults to `undefined`
331-
//
332-
// email verify token below expires in 2 hours (= 2 * 60 * 60 == 7200 seconds)
333-
emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds)
334-
335-
// set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email
336-
// set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified
337-
preventLoginWithUnverifiedEmail: false, // defaults to false
338-
339-
// The public URL of your app.
340-
// This will appear in the link that is used to verify email addresses and reset passwords.
341-
// Set the mount path as it is in serverURL
342-
publicServerURL: 'https://example.com/parse',
343-
// Your apps name. This will appear in the subject and body of the emails that are sent.
344-
appName: 'Parse App',
345-
// The email adapter
326+
// Set email verification token validity to 2 hours
327+
emailVerifyTokenValidityDuration: 2 * 60 * 60,
328+
329+
// Set email adapter
346330
emailAdapter: {
347-
module: '@parse/simple-mailgun-adapter',
331+
module: 'example-mail-adapter',
348332
options: {
349-
// The address that your emails come from
350-
fromAddress: '[email protected]',
351-
// Your domain from mailgun.com
352-
domain: 'example.com',
353-
// Your API key from mailgun.com
354-
apiKey: 'key-mykey',
333+
// Additional adapter options
334+
...mailAdapterOptions
355335
}
356336
},
357-
358-
// account lockout policy setting (OPTIONAL) - defaults to undefined
359-
// if the account lockout policy is set and there are more than `threshold` number of failed login attempts then the `login` api call returns error code `Parse.Error.OBJECT_NOT_FOUND` with error message `Your account is locked due to multiple failed login attempts. Please try again after <duration> minute(s)`. After `duration` minutes of no login attempts, the application will allow the user to try login again.
360-
accountLockout: {
361-
duration: 5, // duration policy setting determines the number of minutes that a locked-out account remains locked out before automatically becoming unlocked. Set it to a value greater than 0 and less than 100000.
362-
threshold: 3, // threshold policy setting determines the number of failed sign-in attempts that will cause a user account to be locked. Set it to an integer value greater than 0 and less than 1000.
363-
unlockOnPasswordReset: true, // Is true if the account lock should be removed after a successful password reset. Default: false.
364-
}
365-
},
366-
// optional settings to enforce password policies
367-
passwordPolicy: {
368-
// Two optional settings to enforce strong passwords. Either one or both can be specified.
369-
// If both are specified, both checks must pass to accept the password
370-
// 1. a RegExp object or a regex string representing the pattern to enforce
371-
validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/, // enforce password with at least 8 char with at least 1 lower case, 1 upper case and 1 digit
372-
// 2. a callback function to be invoked to validate the password
373-
validatorCallback: (password) => { return validatePassword(password) },
374-
validationError: 'Password must contain at least 1 digit.' // optional error message to be sent instead of the default "Password does not meet the Password Policy requirements." message.
375-
doNotAllowUsername: true, // optional setting to disallow username in passwords
376-
maxPasswordAge: 90, // optional setting in days for password expiry. Login fails if user does not reset the password within this period after signup/last reset.
377-
maxPasswordHistory: 5, // optional setting to prevent reuse of previous n passwords. Maximum value that can be specified is 20. Not specifying it or specifying 0 will not enforce history.
378-
//optional setting to set a validity duration for password reset links (in seconds)
379-
resetTokenValidityDuration: 24*60*60, // expire after 24 hours
380-
}
381337
});
382338
```
383339

384-
You can also use other email adapters contributed by the community such as:
385-
- [parse-smtp-template (Multi Language and Multi Template)](https://www.npmjs.com/package/parse-smtp-template)
340+
Email adapters contributed by the community:
341+
- [parse-server-api-mail-adapter](https://www.npmjs.com/package/parse-server-api-mail-adapter) (localization, templates, universally supports any email provider)
342+
- [parse-smtp-template](https://www.npmjs.com/package/parse-smtp-template) (localization, templates)
386343
- [parse-server-postmark-adapter](https://www.npmjs.com/package/parse-server-postmark-adapter)
387344
- [parse-server-sendgrid-adapter](https://www.npmjs.com/package/parse-server-sendgrid-adapter)
388345
- [parse-server-mandrill-adapter](https://www.npmjs.com/package/parse-server-mandrill-adapter)
@@ -392,7 +349,36 @@ You can also use other email adapters contributed by the community such as:
392349
- [parse-server-mailjet-adapter](https://www.npmjs.com/package/parse-server-mailjet-adapter)
393350
- [simple-parse-smtp-adapter](https://www.npmjs.com/package/simple-parse-smtp-adapter)
394351
- [parse-server-generic-email-adapter](https://www.npmjs.com/package/parse-server-generic-email-adapter)
395-
- [parse-server-api-mail-adapter](https://www.npmjs.com/package/parse-server-api-mail-adapter)
352+
353+
## Password and Account Policy
354+
355+
Set a password and account policy that meets your security requirements. The following is an example configuration. See the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) for more details and a full list of available options.
356+
357+
```js
358+
const server = ParseServer({
359+
...otherOptions,
360+
361+
// The account lock policy
362+
accountLockout: {
363+
// Lock the account for 5 minutes.
364+
duration: 5,
365+
// Lock an account after 3 failed log-in attempts
366+
threshold: 3,
367+
// Unlock the account after a successful password reset
368+
unlockOnPasswordReset: true,
369+
},
370+
371+
// The password policy
372+
passwordPolicy: {
373+
// Enforce a password of at least 8 characters which contain at least 1 lower case, 1 upper case and 1 digit
374+
validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/,
375+
// Do not allow the username as part of the password
376+
doNotAllowUsername: true,
377+
// Do not allow to re-use the last 5 passwords when setting a new password
378+
maxPasswordHistory: 5,
379+
},
380+
});
381+
```
396382

397383
## Custom Routes
398384
**Caution, this is an experimental feature that may not be appropriate for production.**

src/Options/Definitions.js

+34-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var parsers = require('./parsers');
88
module.exports.ParseServerOptions = {
99
accountLockout: {
1010
env: 'PARSE_SERVER_ACCOUNT_LOCKOUT',
11-
help: 'account lockout policy for failed login attempts',
11+
help: 'The account lockout policy for failed login attempts.',
1212
action: parsers.objectParser,
1313
},
1414
allowClientClassCreation: {
@@ -128,13 +128,14 @@ module.exports.ParseServerOptions = {
128128
emailVerifyTokenReuseIfValid: {
129129
env: 'PARSE_SERVER_EMAIL_VERIFY_TOKEN_REUSE_IF_VALID',
130130
help:
131-
'an existing email verify token should be reused when resend verification email is requested',
131+
'Set to `true` if a email verification token should be reused in case another token is requested but there is a token that is still valid, i.e. has not expired. This avoids the often observed issue that a user requests multiple emails and does not know which link contains a valid token because each newly generated token would invalidate the previous token.<br><br>Default is `false`.<br>Requires option `verifyUserEmails: true`.',
132132
action: parsers.booleanParser,
133133
default: false,
134134
},
135135
emailVerifyTokenValidityDuration: {
136136
env: 'PARSE_SERVER_EMAIL_VERIFY_TOKEN_VALIDITY_DURATION',
137-
help: 'Email verification token validity duration, in seconds',
137+
help:
138+
'Set the validity duration of the email verification token in seconds after which the token expires. The token is used in the link that is set in the email. After the token expires, the link becomes invalid and a new link has to be sent. If the option is not set or set to `undefined`, then the token never expires.<br><br>For example, to expire the token after 2 hours, set a value of 7200 seconds (= 60 seconds * 60 minutes * 2 hours).<br><br>Default is `undefined`.<br>Requires option `verifyUserEmails: true`.',
138139
action: parsers.numberParser('emailVerifyTokenValidityDuration'),
139140
},
140141
enableAnonymousUsers: {
@@ -291,7 +292,7 @@ module.exports.ParseServerOptions = {
291292
},
292293
passwordPolicy: {
293294
env: 'PARSE_SERVER_PASSWORD_POLICY',
294-
help: 'Password policy for enforcing password related rules',
295+
help: 'The password policy for enforcing password related rules.',
295296
action: parsers.objectParser,
296297
},
297298
playgroundPath: {
@@ -314,7 +315,7 @@ module.exports.ParseServerOptions = {
314315
preventLoginWithUnverifiedEmail: {
315316
env: 'PARSE_SERVER_PREVENT_LOGIN_WITH_UNVERIFIED_EMAIL',
316317
help:
317-
'Prevent user from login if email is not verified and PARSE_SERVER_VERIFY_USER_EMAILS is true, defaults to false',
318+
'Set to `true` to prevent a user from logging in if the email has not yet been verified and email verification is required.<br><br>Default is `false`.<br>Requires option `verifyUserEmails: true`.',
318319
action: parsers.booleanParser,
319320
default: false,
320321
},
@@ -407,7 +408,8 @@ module.exports.ParseServerOptions = {
407408
},
408409
verifyUserEmails: {
409410
env: 'PARSE_SERVER_VERIFY_USER_EMAILS',
410-
help: 'Enable (or disable) user email validation, defaults to false',
411+
help:
412+
'Set to `true` to require users to verify their email address to complete the sign-up process.<br><br>Default is `false`.',
411413
action: parsers.booleanParser,
412414
default: false,
413415
},
@@ -704,54 +706,70 @@ module.exports.AccountLockoutOptions = {
704706
duration: {
705707
env: 'PARSE_SERVER_ACCOUNT_LOCKOUT_DURATION',
706708
help:
707-
'number of minutes that a locked-out account remains locked out before automatically becoming unlocked.',
709+
'Set the duration in minutes that a locked-out account remains locked out before automatically becoming unlocked.<br><br>Valid values are greater than `0` and less than `100000`.',
708710
action: parsers.numberParser('duration'),
709711
},
710712
threshold: {
711713
env: 'PARSE_SERVER_ACCOUNT_LOCKOUT_THRESHOLD',
712-
help: 'number of failed sign-in attempts that will cause a user account to be locked',
714+
help:
715+
'Set the number of failed sign-in attempts that will cause a user account to be locked. If the account is locked. The account will unlock after the duration set in the `duration` option has passed and no further login attempts have been made.<br><br>Valid values are greater than `0` and less than `1000`.',
713716
action: parsers.numberParser('threshold'),
714717
},
715718
unlockOnPasswordReset: {
716719
env: 'PARSE_SERVER_ACCOUNT_LOCKOUT_UNLOCK_ON_PASSWORD_RESET',
717-
help: 'Is true if the account lock should be removed after a successful password reset.',
720+
help:
721+
'Set to `true` if the account should be unlocked after a successful password reset.<br><br>Default is `false`.<br>Requires options `duration` and `threshold` to be set.',
718722
action: parsers.booleanParser,
719723
default: false,
720724
},
721725
};
722726
module.exports.PasswordPolicyOptions = {
723727
doNotAllowUsername: {
724728
env: 'PARSE_SERVER_PASSWORD_POLICY_DO_NOT_ALLOW_USERNAME',
725-
help: 'disallow username in passwords',
729+
help:
730+
'Set to `true` to disallow the username as part of the password.<br><br>Default is `false`.',
726731
action: parsers.booleanParser,
732+
default: false,
727733
},
728734
maxPasswordAge: {
729735
env: 'PARSE_SERVER_PASSWORD_POLICY_MAX_PASSWORD_AGE',
730-
help: 'days for password expiry',
736+
help:
737+
'Set the number of days after which a password expires. Login attempts fail if the user does not reset the password before expiration.',
731738
action: parsers.numberParser('maxPasswordAge'),
732739
},
733740
maxPasswordHistory: {
734741
env: 'PARSE_SERVER_PASSWORD_POLICY_MAX_PASSWORD_HISTORY',
735-
help: 'setting to prevent reuse of previous n passwords',
742+
help:
743+
'Set the number of previous password that will not be allowed to be set as new password. If the option is not set or set to `0`, no previous passwords will be considered.<br><br>Valid values are >= `0` and <= `20`.<br>Default is `0`.',
736744
action: parsers.numberParser('maxPasswordHistory'),
737745
},
738746
resetTokenReuseIfValid: {
739747
env: 'PARSE_SERVER_PASSWORD_POLICY_RESET_TOKEN_REUSE_IF_VALID',
740-
help: "resend token if it's still valid",
748+
help:
749+
'Set to `true` if a password reset token should be reused in case another token is requested but there is a token that is still valid, i.e. has not expired. This avoids the often observed issue that a user requests multiple emails and does not know which link contains a valid token because each newly generated token would invalidate the previous token.<br><br>Default is `false`.',
741750
action: parsers.booleanParser,
751+
default: false,
742752
},
743753
resetTokenValidityDuration: {
744754
env: 'PARSE_SERVER_PASSWORD_POLICY_RESET_TOKEN_VALIDITY_DURATION',
745-
help: 'time for token to expire',
755+
help:
756+
'Set the validity duration of the password reset token in seconds after which the token expires. The token is used in the link that is set in the email. After the token expires, the link becomes invalid and a new link has to be sent. If the option is not set or set to `undefined`, then the token never expires.<br><br>For example, to expire the token after 2 hours, set a value of 7200 seconds (= 60 seconds * 60 minutes * 2 hours).<br><br>Default is `undefined`.',
746757
action: parsers.numberParser('resetTokenValidityDuration'),
747758
},
759+
validationError: {
760+
env: 'PARSE_SERVER_PASSWORD_POLICY_VALIDATION_ERROR',
761+
help:
762+
'Set the error message to be sent.<br><br>Default is `Password does not meet the Password Policy requirements.`',
763+
},
748764
validatorCallback: {
749765
env: 'PARSE_SERVER_PASSWORD_POLICY_VALIDATOR_CALLBACK',
750-
help: 'a callback function to be invoked to validate the password',
766+
help:
767+
'Set a callback function to validate a password to be accepted.<br><br>If used in combination with `validatorPattern`, the password must pass both to be accepted.',
751768
},
752769
validatorPattern: {
753770
env: 'PARSE_SERVER_PASSWORD_POLICY_VALIDATOR_PATTERN',
754-
help: 'a RegExp object or a regex string representing the pattern to enforce',
771+
help:
772+
'Set the regular expression validation pattern a password must match to be accepted.<br><br>If used in combination with `validatorCallback`, the password must pass both to be accepted.',
755773
},
756774
};
757775
module.exports.FileUploadOptions = {

0 commit comments

Comments
 (0)