Skip to content

Conversation

@mattgawarecki
Copy link
Contributor

Fixes #8226.

Changes proposed in this Pull Request:

  • Add a check in the Antispam component to look for indications of a globally-set WPCOM_API_KEY for Akismet.
  • If a globally-set API key is detected, inform the user and disable input.

Jetpack product discussion

See #8226.

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

How to globally define an Akismet API key:

  • In the Jetpack > Akismet Anti-spam menu, if an API key is already set, disconnect or remove it.
  • In your site's wp-config.php file, add the following line: define( 'WPCOM_API_KEY', 'your api key' ); where your api key is your desired API key.

To test changes in this PR:

  • Globally define a valid Akismet API key for your site (see instructions above).
  • Verify that in Jetpack > Settings > Security, the Anti-spam card shows "Your site is protected from spam." and the text input is disabled, like in the below screenshot.

To test for regressions:

  • Globally define an invalid Akismet API key for your site (see instructions above).
  • Verify that in Jetpack > Settings > Security, the Anti-spam card shows "Your site is not protected from spam." and all UI elements appear/behave as they did before this PR.
  • Remove all global and UI-based API key definitions from your site.
  • Verify that in Jetpack > Settings > Security, the Anti-spam card shows "Your site needs an Antispam key." and all UI elements appear/behave as they did before this PR.
  • Verify that the state of the Anti-spam card changes correctly based on the state of the Your API key text input.
Screenshot (After)

Screen Shot 2020-07-21 at 10 27 36

Proposed changelog entry for your changes:

  • Settings: Globally-configured Akismet API keys (e.g., in wp-config.php) now show as valid and cannot be altered from the UI.

@mattgawarecki mattgawarecki added the [Status] Needs Design Review Design has been added. Needs a review! label Jul 21, 2020
@mattgawarecki mattgawarecki self-assigned this Jul 21, 2020
@mattgawarecki mattgawarecki added the [Status] Needs Review This PR is ready for review. label Jul 21, 2020
@eeeeevon13
Copy link
Contributor

This is looking good from a design standpoint. In the wording (inside the disabled input) is there a way to be more specific? I had originally had it say "a valid key has been set in wp-config.php" Just wondering if a user who did not make this change would be better served by understanding specifically where it is set?
Screenshot 2020-07-21 13 37 53

@jetpackbot
Copy link
Collaborator

jetpackbot commented Jul 21, 2020

Warnings
⚠️

pre-commit hook was skipped for one or more commits

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16542

Generated by 🚫 dangerJS against d3e27c6

@BrookeDot
Copy link
Contributor

BrookeDot commented Jul 21, 2020

I had originally had it say "a valid key has been set in wp-config.php" Just wondering if a user who did not make this change would be better served by understanding specifically where it is set?

I would <3 to be more specific here but the problem is we can't assume that the constant is set in wp-config.php Maybe the text can be filterable so it can be changed at the provider level?

For example, I could add the key to any plugin or theme and it would still be set.

I'm tempted to use WPCOM_API_KEY in the message but it's a poorly named constant which may make things more confusing. If we overlook that maybe this is more clear,

A key has been set using the WPCOM_API_KEY constant

or

The WPCOM_API_KEY constant is set.

@jeherve jeherve added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it Admin Page React-powered dashboard under the Jetpack menu [Feature] Akismet An anti-spam feature that automatically filters spam comments and forms, blocking unwanted content. [Pri] Normal labels Jul 22, 2020
@mattgawarecki
Copy link
Contributor Author

@eeeeevon13 @BrookeDot More than happy to oblige with whatever copy y'all think is best. 😄

On a separate note, to everyone: code-wise, is this PR looking okay?

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Jul 31, 2020
@jeherve jeherve added this to the 8.9 milestone Jul 31, 2020
@BrookeDot
Copy link
Contributor

@beaulebens Do you have thoughts, on the text of the message itself or know who should chime in here?

@beaulebens
Copy link
Member

I doubt I'm the best person to comment here, but there are really only 2 instances that I can think of where this handling/message are relevant;

  1. Because the user themselves set a constant in code somewhere (very intentional, very specific, they should know what's going on), or, probably more likely;
  2. The sysadmin/host/someone else set a constant, so they know what's going on, but the specific user does not.

I'd lean towards optimizing for the second one, but either way just making the message something pretty generic like "Your site has been configured with a valid antispam key" or something like that.

@mattgawarecki mattgawarecki force-pushed the fix/globally-configured-akismet-key branch from 634e6aa to d3e27c6 Compare August 3, 2020 13:17
@mattgawarecki mattgawarecki requested a review from jeherve August 5, 2020 17:19
@mattgawarecki mattgawarecki added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Aug 5, 2020
@mattgawarecki mattgawarecki dismissed jeherve’s stale review August 6, 2020 18:42

Addressed the change

@mattgawarecki
Copy link
Contributor Author

  1. Because the user themselves set a constant in code somewhere (very intentional, very specific, they should know what's going on), or, probably more likely;
  2. The sysadmin/host/someone else set a constant, so they know what's going on, but the specific user does not.

@beaulebens Does my proposed copy, "A valid key has been set in your site's configuration," cover both of these cases?

Specifically looking at case 2, I think this wording lets the user know that even though they may not have set a key themselves, a valid key exists somewhere and has been recognized, whether put there by a provider or another site admin. I'm not a copywriter or a designer, though, only a developer 😅 What are your thoughts?

something pretty generic like "Your site has been configured with a valid antispam key" or something like that.

Since we also have help text below the input that reads "Your Antispam key is valid," I wonder if mentioning Antispam again woulld come across as too repetitive?

@beaulebens
Copy link
Member

That change works for me, yep. I think it strikes a good enough balance of detail and simplicity.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Aug 12, 2020
@mattgawarecki mattgawarecki merged commit 388b619 into master Aug 12, 2020
@mattgawarecki mattgawarecki deleted the fix/globally-configured-akismet-key branch August 12, 2020 12:44
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Aug 12, 2020
davidlonjon added a commit that referenced this pull request Aug 14, 2020
* master: (41 commits)
  use blog token to make the request (#16635)
  External Media: Add account disconnect button (#16759)
  CI: Try collect js coverage (#16786)
  Sync: Fix nonce action string in theme edit sync (#16702)
  Connect-in-place: hide new heading during connection process (#16703)
  Update dependency eslint-plugin-jsdoc to v30.2.1 (#16765)
  Theme Tools: Resolve PHP 7.4 array offset notice. (#16795)
  New shell command for easier access to the database. (#16761)
  My Plan: Add Offer Reset project new plans (Jetpack Security, Jetpack Complete) (#16739)
  Increase the `editor.MediaUpload` hook priority (#16669)
  External Media: Remove `speak` announcement when inserting media.
  Extensions: make `render_callback` optional when checking block registration against plan (#16746)
  Conditional check for wrapper before giving focus to new page (#16817)
  Docker: Add package testing shortcut (#16810)
  Settings: Recognize valid Akismet keys from wp-config and restrict input (#16542)
  Social Previews: Add Modal (#16704)
  Update dependency preact to v10.4.7 (#16768)
  Improve a11y of amp-social-share (#16737)
  Instant Search: Tweak expanded result path styling (#16762)
  Docker: Add phpmyadmin to the docker-composer.yml (#16806)
  ...
jeherve added a commit that referenced this pull request Aug 25, 2020
pereirinha pushed a commit that referenced this pull request Sep 10, 2020
…and restrict input (#16542)

* [not verified] Settings: Recognize valid Akismet keys set in wp-config.php and restrict input

* Add text domain for 'valid key set' copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu [Feature] Akismet An anti-spam feature that automatically filters spam comments and forms, blocking unwanted content. [Pri] Normal [Status] Needs Design Review Design has been added. Needs a review! [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI doesn't handle Akismet keys set via constant properly

8 participants