PHP Extension for Edgecast Token-Based Authentication
Token-Based Authentication safeguards against hotlinking by adding a token requirement to requests for content secured by it. This token, which must be defined in the request URL's query string, defines the criteria that must be met before the requested content may be served via the CDN.
This PHP extension is a thin wrapper around the existing ectokenv3 C implementation.
This extension targets limited PHP versions (8.1+) and OSs (Linux/MacOS). It may work for other platforms, but is entirely untested at this time.
The following platforms are tested in the CI matrix currenty.
| PHP Version | Linux (x64_64, Debian) | Linux (x64_64, Alpine) | MacOS (x86_64) | MacOS (arm64) |
|---|---|---|---|---|
| 8.1 | Yes | Yes | Yes | Yes |
| 8.2 | Yes | Yes | Yes | Yes |
| 8.3 | Yes | Yes | Yes | Yes |
| 8.4 | Yes | Yes | Yes | Yes |
phpize
./configure
make
make test
phpize
./configure
make install
OR
- Download the latest packaged release.
- Install with pecl (e.g.
pecl install ectoken-1.0.0.tgz)
$key = "potential-vitamin-bottle-tree-fan";
$plaintext = "ec_country_allow=US,CA,MX&ec_ref_allow=example.com";
// Encrypt
$token = ectoken_encrypt($plaintext, $key);
echo "Encrypted: " . $token . "\n";
// `Encrypted: IKpEIyLRN8q0oZ2VfSzDlldDR_aFlk4fHuQ2Y3g-A6D2qKyeKw3j3FAT7LleRpMRkm6QTYN_Kauccbf6tdo2yMP6TOjLgPi-MvVDwFAU`
// Decrypt
$decrypted = ectoken_decrypt($token, $key);
echo "Decrypted: " . $decrypted . "\n";
// `Decrypted: ec_country_allow=US,CA,MX&ec_ref_allow=example.com"- We welcome issues, questions and pull requests.
This project is licensed under the terms of the Apache 2.0 open source license. Please refer to the LICENSE-APACHE file for the full terms.