Skip to content

License key validation does not work with new license key format from MaxMind #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oschwald opened this issue Mar 21, 2023 · 1 comment

Comments

@oschwald
Copy link

The current license key validation fails on new license keys from MaxMind, e.g., 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. It appears that the current validation requires the keys to match ^[A-Za-z0-9]{16}$:

public function validateApiKey($key) {
$message = '';
$key = trim($key);
if (mb_strlen($key) != 16) {
$message = __('The license key usually is a 16-char alphanumeric string. Are you sure this is the right key?', 'geoip-detect');
if (mb_strlen($key) < 16) {
$message .= ' ' . __('Do not use the "unhashed format" when generating the license key.', 'geoip-detect');
// Unhashed: 13char alphanumeric
}
$message .= ' ' . sprintf(__('This key is %d chars long.', 'geoip-detect'), mb_strlen($key));
} else if (1 !== preg_match('/^[a-z0-9]+$/i', $key)) {
$message = __('The license key usually is a 16-char alphanumeric string. Are you sure this is the right key?', 'geoip-detect');
$message .= ' ' . __('This key contains characters other than a-z and 0-9.', 'geoip-detect');
}
if ($message) return $message;
return true;
}

The new license keys match [A-Za-z0-9]{6}_[A-Za-z0-9]{29}_mmk. The length may also increase in the future. See these release notes for more information.

@benjaminpick
Copy link
Member

Thank you for notifying me!

benjaminpick pushed a commit that referenced this issue Apr 1, 2023
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

No branches or pull requests

2 participants