Skip to content

Commit a28433f

Browse files
authored
Replace mailgun adapter with mock adapter (#7321)
1 parent 7042552 commit a28433f

File tree

10 files changed

+1407
-1691
lines changed

10 files changed

+1407
-1691
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ ___
9191
### Breaking Changes
9292
- Improved schema caching through database real-time hooks. Reduces DB queries, decreases Parse Query execution time and fixes a potential schema memory leak. If multiple Parse Server instances connect to the same DB (for example behind a load balancer), set the [Parse Server Option](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) `databaseOptions.enableSchemaHooks: true` to enable this feature and keep the schema in sync across all instances. Failing to do so will cause a schema change to not propagate to other instances and re-syncing will only happen when these instances restart. The options `enableSingleSchemaCache` and `schemaCacheTTL` have been removed. To use this feature with MongoDB, a replica set cluster with [change stream](https://docs.mongodb.com/manual/changeStreams/#availability) support is required. (Diamond Lewis, SebC) [#7214](https://github.com/parse-community/parse-server/issues/7214)
9393
- Added file upload restriction. File upload is now only allowed for authenticated users by default for improved security. To allow file upload also for Anonymous Users or Public, set the `fileUpload` parameter in the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) (dblythy, Manuel Trezza) [#7071](https://github.com/parse-community/parse-server/pull/7071)
94+
- Removed [parse-server-simple-mailgun-adapter](https://github.com/parse-community/parse-server-simple-mailgun-adapter) dependency; to continue using the adapter it has to be explicitly installed (Manuel Trezza) [#7321](https://github.com/parse-community/parse-server/pull/7321)
9495
### Notable Changes
9596
- Added Parse Server Security Check to report weak security settings (Manuel Trezza, dblythy) [#7247](https://github.com/parse-community/parse-server/issues/7247)
9697
- EXPERIMENTAL: Added new page router with placeholder rendering and localization of custom and feature pages such as password reset and email verification (Manuel Trezza) [#6891](https://github.com/parse-community/parse-server/issues/6891)

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.**

0 commit comments

Comments
 (0)