Giter Club home page Giter Club logo

akamaiopen-edgegrid-php's Introduction

akamai-open/edgegrid-auth

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

  1. Either clone or download to pull down a copy of this repository.

  2. Use the composer autoloader and install the dependencies.

      $ composer install
  3. 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.

akamaiopen-edgegrid-php's People

Contributors

dshafik avatar hokamoto avatar mgwoj avatar remicollet avatar skearney-akamai avatar synedra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

akamaiopen-edgegrid-php's Issues

Deprecated warning GuzzleHttp\Client class is considered final

Using php 8.1 we have the following deprecated warning :

User Deprecated: The "GuzzleHttp\Client" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Akamai\Open\EdgeGrid\Client". {"exception":"[object] (ErrorException(code: 0): User Deprecated: The "GuzzleHttp\Client" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Akamai\Open\EdgeGrid\Client". at /var/www/enrj-importer-php/vendor/symfony/error-handler/DebugClassLoader.php:333)"} []

Question: Release a version with PHP 7.4 support?

Hey maintainers,

I am currently struggling with updating

  • akamai-open/edgegrid-client
  • akamai-open/edgegrid-auth

to v2, as it requires PHP 8.1, however, there is no PHP 7.4-compatible version with guzzle 7 in place, which I need as an intermediate step before our hosting provider is able to update to PHP 8.1.

As I noticed in the source code of this repo, it is possible to reduce the PHP version constraint in composer.json to use "^7.4 || ^8.1" without any further effort. This way, a new release is able for people to update their public packages with a better version constraint. After having a 7.4 compatible v2 release (2.0.1), we could then raise again to PHP 8.1+ again.

My question is this: Would you be willing for such a move, or should I create an official fork?

Another official alternative for me is to try to require Guzzle v7 in your akamai-open/edgegrid-* v1.x versions (in case this is still maintained).

Thanks for your feedback in advance!

Deprecated function: http_build_query()

Deprecated function: http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated in Akamai\Open\EdgeGrid\Authentication->buildQueryString()

Seeing this warning thrown in logs.

Tests fail on PHP 7.1

$ php71 vendor/bin/phpunit
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.

Runtime:	PHP 7.1.0RC6
Configuration:	/home/siwinski/projects/AkamaiOPEN-edgegrid-php/phpunit.xml.dist
Warning:	The Xdebug extension is not loaded
		No code coverage will be generated.

..F.........................................

Time: 2.04 seconds, Memory: 6.00MB

There was 1 failure:

1) Akamai\Open\EdgeGrid\Tests\Client\Authentication\TimestampTest::testTimestampFormat
Failed asserting that two DateTime objects are equal.
--- Expected
+++ Actual
@@ @@
 2016-12-09T00:07:14+0000

/home/siwinski/projects/AkamaiOPEN-edgegrid-php/tests/Authentication/TimestampTest.php:32

FAILURES!
Tests: 44, Assertions: 114, Failures: 1.

I was going to submit the following diff/patch but I don't know if it defeats the purpose of that test:

29a30
>         $actual = \PHPUnit_Framework_Assert::readAttribute($timestamp, 'timestamp');
31,32c32,34
<         $check = \DateTime::createFromFormat('Ymd\TH:i:sO', (string) $timestamp, new \DateTimeZone('UTC'));
<         $this->assertEquals($check, \PHPUnit_Framework_Assert::readAttribute($timestamp, 'timestamp'));
---
>         $expected = \DateTime::createFromFormat('Ymd\TH:i:sO', (string) $timestamp, new \DateTimeZone('UTC'));
> 
>         $this->assertEquals($expected->format('Y-m-d H:i:s'), $actual->format('Y-m-d H:i:s'));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.