Skip to content

Commit ef1a6f5

Browse files
authored
Merge pull request #47 from mailchimp/enhancement/9
Add OAuth authentication
2 parents 6b0f662 + 9de40f0 commit ef1a6f5

20 files changed

+1168
-114
lines changed

.github/workflows/e2e.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ on:
1010
- develop
1111

1212
jobs:
13+
build:
14+
uses: mailchimp/wordpress/.github/workflows/build-release-zip.yml@develop
15+
1316
cypress:
17+
needs: build
1418
name: ${{ matrix.core.name }}
1519
runs-on: ubuntu-latest
20+
env:
21+
CYPRESS_MAILCHIMP_USERNAME: ${{ secrets.MAILCHIMP_USERNAME }}
22+
CYPRESS_MAILCHIMP_PASSWORD: ${{ secrets.MAILCHIMP_PASSWORD }}
1623
strategy:
1724
matrix:
1825
core:
@@ -24,15 +31,25 @@ jobs:
2431
- name: Checkout
2532
uses: actions/checkout@v4
2633

34+
- name: Download build zip
35+
uses: actions/download-artifact@v4
36+
with:
37+
name: ${{ github.event.repository.name }}
38+
path: ${{ github.event.repository.name }}
39+
40+
- name: Display structure of downloaded files
41+
run: ls -R
42+
working-directory: ${{ github.event.repository.name }}
43+
2744
- uses: actions/setup-node@v4
2845
with:
2946
node-version-file: '.nvmrc'
3047

3148
- name: Install dependencies
3249
run: npm ci
3350

34-
- name: Set the core version
35-
run: ./tests/bin/set-core-version.js ${{ matrix.core.version }}
51+
- name: Set the core version and plugins config
52+
run: ./tests/bin/set-core-version.js --core=${{ matrix.core.version }} --plugins=./${{ github.event.repository.name }}
3653

3754
- name: Set up WP environment
3855
run: npm run env:start
@@ -41,6 +58,7 @@ jobs:
4158
run: npm run cypress:run
4259

4360
- name: Update summary
61+
if: always()
4462
run: |
4563
npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json
4664
rm -rf ./tests/cypress/reports/mochawesome-*.json

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Add a Mailchimp signup form widget to your WordPress site.
44
5-
[![Support Level](https://img.shields.io/badge/support-active-green.svg?label=Support)](#support-level) [![GPL-2.0-or-later License](https://img.shields.io/github/license/mailchimp/wordpress?label=License)](https://github.com/mailchimp/wordpress/blob/develop/LICENSE.md) ![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/mailchimp?label=Version) ![WordPress Minimum](https://img.shields.io/wordpress/plugin/wp-version/mailchimp?label=WordPress%20minimum) ![PHP Minimum](https://img.shields.io/wordpress/plugin/required-php/mailchimp?label=PHP%20minimum) ![WordPress Tested Up To](https://img.shields.io/wordpress/plugin/tested/mailchimp?label=WordPress) [![E2E Cypress Tests](https://github.com/mailchimp/wordpress/actions/workflows/e2e.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/e2e.yml) [![PHP Compatibility](https://github.com/mailchimp/wordpress/actions/workflows/php-compat.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/php-compat.yml) [![PHP Linting](https://github.com/mailchimp/wordpress/actions/workflows/phpcs.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/phpcs.yml) [![JS Linting](https://github.com/mailchimp/wordpress/actions/workflows/eslint.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/eslint.yml)
5+
[![Support Level](https://img.shields.io/badge/support-active-green.svg?label=Support)](#support-level) [![GPL-2.0-or-later License](https://img.shields.io/github/license/mailchimp/wordpress?label=License)](https://github.com/mailchimp/wordpress/blob/develop/LICENSE.md) ![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/mailchimp?label=Version) ![WordPress Minimum](https://img.shields.io/wordpress/plugin/wp-version/mailchimp?label=WordPress%20minimum) ![PHP Minimum](https://img.shields.io/wordpress/plugin/required-php/mailchimp?label=PHP%20minimum) ![WordPress Tested Up To](https://img.shields.io/wordpress/plugin/tested/mailchimp?label=WordPress) [![E2E Cypress Tests](https://github.com/mailchimp/wordpress/actions/workflows/e2e.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/e2e.yml) [![PHP Compatibility](https://github.com/mailchimp/wordpress/actions/workflows/php-compat.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/php-compat.yml) [![PHP Linting](https://github.com/mailchimp/wordpress/actions/workflows/phpcs.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/phpcs.yml) [![JS Linting](https://github.com/mailchimp/wordpress/actions/workflows/eslint.yml/badge.svg)](https://github.com/mailchimp/wordpress/actions/workflows/eslint.yml)
66

77
## Overview
88

@@ -18,6 +18,21 @@ WordPress.com compatibility is limited to Business tier users only. [How to add
1818

1919
![Configuring extra fields on your Signup Form (optional)](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-4.jpg?raw=true)
2020

21+
## Access Token Encryption
22+
23+
Starting in version 1.6.0, authentication has changed to use OAuth. As part of this process, we retrieve an access token that can be used to make API requests. To provide a high-level of security, this access token is encrypted before being stored in the WordPress database. In order to ensure this access token can be decrypted when used, the plugin relies on certain security constants that should remain unchanged.
24+
25+
With no additional configuration, we use the standard `LOGGED_IN_KEY` and `LOGGED_IN_SALT` constants that are normally set in your site's `wp-config.php` file. Some sites make use of security plugins that rotate these constants on a periodic basis. When this happens, we won't be able to decrypt the access token and you’ll need to reconnect your Mailchimp account to generate a new access token.
26+
27+
To prevent such issues, it is recommended to define two additional constants in your site's `wp-config.php` file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from [here](https://api.wordpress.org/secret-key/1.1/salt/) and use them. You'll end up with additional code like the following in your `wp-config.php` file:
28+
29+
```php
30+
define( 'MAILCHIMP_SF_ENCRYPTION_KEY', 'put your unique phrase here' );
31+
define( 'MAILCHIMP_SF_ENCRYPTION_SALT', 'put your unique phrase here' );
32+
```
33+
34+
If these constants are added after you've already authenticated with Mailchimp, you will need to reconnect your account. To avoid this, you can copy the values from `LOGGED_IN_KEY` and `LOGGED_IN_SALT` (if they exist) to `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT` respectively.
35+
2136
## Frequently Asked Questions
2237

2338
### Can I have multiple forms on one page?
@@ -41,9 +56,9 @@ This section describes how to install the plugin and get started using it.
4156

4257
### Advanced
4358

44-
If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead.
59+
If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead.
4560

46-
WordPress v2.8 or higher:
61+
WordPress v2.8 or higher:
4762
` [mailchimpsf_form] `
4863

4964
If you are adding it inside a php code block, pop this in:
@@ -89,6 +104,23 @@ Currently we have the plugin configured so it can be translated and the followin
89104
* sv_SE - Swedish in Sweden (thanks to [Sebastian Johnsson](http://www.agiley.se/) for contributing)
90105
* tr_TR - Turkish in Turkey (thanks to [Hakan E.](http://kazancexpert.com/) for contributing)
91106

107+
## E2E tests
108+
The `tests` directory contains end-to-end tests for the project, utilizing Cypress to run tests in an environment created using wp-env.
109+
110+
### Pre-requisites
111+
- Node.js v20
112+
- Docker
113+
- Create an account in [Mailchimp](https://mailchimp.com/)
114+
115+
### Run E2E tests in local
116+
1. Run `npm install`.
117+
2. Run `npm run build`.
118+
3. Run `npm run env:start`.
119+
4. Set Mailchimp credentials as environment variables:
120+
- run `export CYPRESS_MAILCHIMP_USERNAME="your mailchimp username"`
121+
- run `export CYPRESS_MAILCHIMP_PASSWORD="your mailchimp password"`
122+
5. Run `npm run cypress:run`. You can also run `npm run cypress:open` to run tests in UI mode.
123+
92124
## Support Level
93125

94126
**Active:** Mailchimp is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.

css/admin.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,15 @@ th.mailchimp-connect {
254254
#mc-message {
255255
margin-top: 26px;
256256
}
257+
258+
/**
259+
* Mailchimp OAuth CSS
260+
*/
261+
.mailchimp-sf-oauth-section .oauth-error {
262+
display: block;
263+
color: #db3a1b;
264+
}
265+
266+
.mailchimp-sf-oauth-connect-wrapper {
267+
display: flex;
268+
}

0 commit comments

Comments
 (0)