Repository navigation
Remote verification with Sentinel::verify() now works with ALTCHA Sentinel v2 (POST /v2/verify/signature), and Sentinel v1 (POST /v1/verify/signature) is still supported.
Highlights
Sentinel v2 support
Sentinel v2 requires the request to be authenticated with a restricted or full API key of the account that owns the payload's API key. Pass it with the new apiKey option; it is sent as Authorization: Basic base64(id:secret):
use AltchaOrg\Altcha\Sentinel;
use AltchaOrg\Altcha\VerifyServerApiKey;
use AltchaOrg\Altcha\VerifyServerOptions;
$result = Sentinel::verify(new VerifyServerOptions(
payload: $_POST['altcha'],
url: 'https://sentinel.example.com/v2/verify/signature',
apiKey: new VerifyServerApiKey('key_...', 'sec_...'),
retries: 2,
));When apiKey is set, the request body is {"payload": …} only: secret is not sent, because Sentinel v2 rejects it.
Sentinel v1 unchanged
Without apiKey, requests are sent as before. secret stays optional and goes in the request body, where Sentinel checks it against the payload's API key. This also covers the /v1/verify/signature alias that Sentinel v2 serves with [server] v1_compat = true.
$result = Sentinel::verify(new VerifyServerOptions(
payload: $_POST['altcha'],
url: 'https://sentinel.example.com/v1/verify/signature',
secret: 'sec_...', // optional
));Breaking changes
These match altcha-lib (JS) and ship in a minor release, per this project's versioning policy.
- 4xx responses are no longer retried. Before, only HTTP
400was terminal; now every4xx(e.g. v2's401/403for missing, wrong orpubliccredentials,429) returnsverified: falseimmediately. Network errors,5xxresponses and unparseable bodies are still retried up toretriestimes. - Error
reasoncomes from Sentinel's error body. It is the body'scode(Sentinel v2, e.g.API_KEY_REQUIRED), else itserror(Sentinel v1), elseHTTP_<status>. A5xxthat outlasts all retries now reports this reason too, instead ofHTTP_<status>only. verificationDatais flattened. Sentinel v2 returns it nested ({"device": {"browser": …}});VerifyServerResult::$verificationDatanow holds the signed dotted keys ($result->verificationData['device.browser']). Lists such asfieldsandreasonsstay arrays. Flat data from Sentinel v1 is unchanged.
Upgrading
- Moving to Sentinel v2: change
urlto/v2/verify/signature, create arestrictedorfullAPI key in the account that owns your widget's key, and pass it asapiKey: new VerifyServerApiKey($id, $secret). Dropsecret; it is ignored whenapiKeyis set. - If you read nested
verificationData($data['device']['browser']), switch to the dotted keys ($data['device.browser']). - If you relied on 4xx responses being retried, handle them as final failures and check
$result->reason.
VerifyServerOptions::$apiKey is the last constructor parameter, so existing positional and named calls keep working.
Other
- README documents both Sentinel versions, the options table and the error/retry behavior.
examples/server_sentinel.phpdefaults to Sentinel v2 (ALTCHA_SENTINEL_API_KEY+ALTCHA_SENTINEL_SECRET) and falls back to Sentinel v1 whenALTCHA_SENTINEL_API_KEYis unset.
See CHANGELOG.md for the full list.