Skip to content

EdgeCast/php-ectokenv3

Repository files navigation

php-ectokenv3

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.

Support / Compatibility

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

Development

Build

phpize
./configure
make

Test

make test

Install

phpize
./configure
make install

OR

  1. Download the latest packaged release.
  2. Install with pecl (e.g. pecl install ectoken-1.0.0.tgz)

Usage

$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"

Contribute

  • We welcome issues, questions and pull requests.

License

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.

About

PHP 8.x extension for ectokenv3 encryption/decryption

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors