akamai-open / edgegrid-auth
Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client_Auth.html
Installs: 2 453 782
Dependents: 7
Suggesters: 0
Security: 0
Stars: 14
Watchers: 12
Forks: 14
Open Issues: 0
Requires
- php: >=8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- humbug/box: >=4.1.0
- phpspec/prophecy: ~1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
Suggests
- akamai-open/edgegrid-client: Provide a fully featured HTTP client & CLI pre-configured with EdgeGrid authentication. (PHP 8.1+)
This package is auto-updated.
Last update: 2024-10-18 17:32:30 UTC
README
Akamai EdgeGrid Authentication for PHP
This library requires PHP 8+ and implements the Akamai EdgeGrid Authentication scheme for PHP.
Install
To install, use composer
:
$ composer require akamai-open/edgegrid-auth
Alternative installation methods
Single file (PHAR)
Download the PHAR file from the releases page and include it inside your code:
```php
include 'akamai-open-edgegrid-auth.phar';
// Library is ready to use
```
Clone or download
-
Either clone or download to pull down a copy of this repository.
- Clone the repository using git or subversion.
- Download the latest ZIP archive or specific release ZIP archive.
-
Use the composer autoloader and install the dependencies.
$ composer install
-
Include the autoloader.
require_once 'vendor/autoload.php';
If you don't use the autoloader, include all the required classes manually in your code.
require_once 'src/Authentication.php'; require_once 'src/Authentication/Timestamp.php'; require_once 'src/Authentication/Nonce.php'; require_once 'src/Authentication/Exception.php'; require_once 'src/Authentication/Exception/ConfigException.php'; require_once 'src/Authentication/Exception/SignerException.php'; require_once 'src/Authentication/Exception/SignerException/InvalidSignDataException.php';
Use
Once you have installed the library, you can create the header value by calling the appropriate \Akamai\Open\Edgegrid\Authentication::set*()
methods.
For example, using it with the built-in streams HTTP client might look like the following:
$auth = \Akamai\Open\EdgeGrid\Authentication::createFromEdgeRcFile('default', '/.edgerc'); $auth->setHttpMethod('GET'); $auth->setPath('/identity-management/v3/user-profile'); $context = array( 'http' => array( 'header' => array( 'Authorization: ' . $auth->createAuthHeader(), 'Content-Type: application/json' ) ) ); $context = stream_context_create($context); $response = json_decode(file_get_contents('https://' . $auth->getHost() . $auth->getPath(), null, $context));
License
Copyright © 2022 Akamai Technologies, Inc. All rights reserved
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.