Skip to main content

New Plugin Release 4.3.0

· 5 min read
Nicu Micle
Creator of Simple JWT Login

The version 4.3.0 has been released today on WordPress.

The WP-CLI commands are now part of the plugin, and every new JWT gets a unique jti claim. If the separate Simple-JWT-Login CLI plugin is installed, deactivate and delete it after updating.

New Features​

WP-CLI commands built into the plugin​

The wp jwt commands now ship with the plugin. You can turn them on or off in General > CLI, and they are on by default. See the WP-CLI documentation.

  • Commands that were in the separate CLI plugin: wp jwt login, decode, validate, revoke, and wp jwt config get|set|list|export|import
  • wp jwt config set and wp jwt config import now run the same validation as saving the settings in wp-admin. Use --force to skip it.
  • While the separate Simple-JWT-Login CLI plugin is active, the built-in commands stay disabled, the setting defaults to off, and the CLI card shows a warning. Deactivate and delete that plugin to use the built-in commands. See Enable or disable the commands.

New commands:

  • wp jwt setup - set up the plugin from the command line
  • wp jwt generate - issue a JWT for a user without their password
  • wp jwt refresh - exchange a refresh token for a new JWT
  • wp jwt revoke-all - revoke every JWT and refresh token of a user, whether or not "Revoke tokens on password change" is on
  • wp jwt key generate|rotate - --algorithm=random picks a random algorithm and generates a matching key
  • wp jwt api-key create|list|revoke and wp jwt auth-code list|add|remove
  • wp jwt doctor, security-report, and explain-error
  • wp jwt log list|analyze, wp jwt webhook list|test|logs, and wp jwt cleanup

List commands support --format=table|csv|json|yaml|count and --fields.

Other changes to the CLI:

  • wp jwt login no longer needs --password on the command line. It prompts for the password (hidden input) or reads it from STDIN.
  • wp jwt validate exits with code 1 when the token isn't valid, so you can use it in scripts and CI.

Key rotation without breaking issued tokens​

wp jwt key rotate keeps the old key in a JWT Rule that matches tokens issued before the rotation, so those tokens stay valid until they expire. The daily cleanup removes the rule after that. Use --immediate when the old key has leaked and every token signed with it must stop working at once. wp jwt setup uses the same mechanism when it replaces a key. See wp jwt key.

To support this, JWT Rules have a new less than operator for whole-number claims such as iat.

New jti claim​

Authentication > JWT payload has a new jti claim: a unique, random ID added to every issued JWT. Before 4.3.0, two tokens issued for the same user in the same second were identical, so revoking one also revoked the other. With jti, every token is different.

  • jti is enabled by default, including on existing sites. The settings migration (settings schema version 3) adds it to the saved payload list.
  • jti is a reserved payload key and can't be set through custom claims or the payload request parameter.
  • The admin page and the security report show a warning when jti is turned off.

See JWT Payload Configuration.

Audit log events for WP-CLI​

Two new audit log events, cli.command.success and cli.command.failed, record the WP-CLI commands that change something. A command that turns off the audit log is still recorded. See WP-CLI events.

Bug Fixes​

  • Fix a database error on /revoked-tokens, /api-keys, and the audit and webhook logs when a page far past the last one is requested: the SQL offset overflowed into a negative number. Such pages now return an empty list.
  • Fix a 500 error on /users, /user/reset_password, /auth/refresh, and /oauth/token when a parameter is sent as an array or an object. These requests now get the usual validation error.
  • Fix a PHP fatal error when a webhook with the GET method was called. GET webhooks now send the event fields as query parameters and don't use the payload template. See Webhooks.
  • Saving the settings now rejects an unsupported JWT algorithm (settings error code 2010) instead of storing it and then failing on every token.

API Reference​

  • The id in the decoded JWT payload returned by /auth/validate is now documented as a numeric string, which is how the endpoint returns it
  • A Schemathesis check (composer run test-openapi, also run in CI) now verifies that the live REST responses match the OpenAPI spec

If you encounter any issues after updating, please open an issue on GitHub.