Repository navigation
fix: harden license refresh and reset cached validity - #49
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
License::refresh_license_api()now requiresmanage_optionsand 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 cachedis_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.phpis_valid()with an inactive stored license, runcheck_license_status()against a valid key, andis_valid()now returnstruein 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
_noncefield.