Skip to content

fix: harden license refresh and reset cached validity - #49

Merged
kzamanbd merged 1 commit into
developfrom
fix/license-refresh-hardening
Oct 7, 2026
Merged

kzamanbd merged 1 commit into
developfrom
fix/license-refresh-hardening

Conversation

@kzamanbd

@kzamanbd kzamanbd commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Changes

  • License::refresh_license_api() now requires manage_options and a valid nonce (action $this->client->name, field _nonce, the same pair the license form already uses). Otherwise it responds with a 403 JSON error.
  • License::check_license_status() now resets the cached is_valid() result after it saves the license, so later calls in the same request return the refreshed status instead of the old one.

Testing

  • php -l src/License.php
  • Refresh endpoint: a non-admin user or a missing nonce gets 403. An admin with a valid nonce refreshes the license as before.
  • Prime is_valid() with an inactive stored license, run check_license_status() against a valid key, and is_valid() now returns true in the same request.

I ran these as PHPUnit tests inside a WordPress plugin that bundles this SDK, with the license check HTTP request mocked. All pass with this change. On develop, the non-admin, missing-nonce and cache tests fail.

Notes

I found no callers of the refresh endpoint in the Appsero repositories. Any external caller will need to send the _nonce field.

- Require manage_options and a nonce on the license refresh AJAX handler.
- Reset the cached is_valid() result after check_license_status() updates
  the stored license, so callers in the same request see the new status.
@kzamanbd kzamanbd self-assigned this Oct 7, 2026
@kzamanbd
kzamanbd merged commit dc54c07 into develop Oct 7, 2026
1 check failed
@kzamanbd
kzamanbd deleted the fix/license-refresh-hardening branch October 7, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant