Coder Social home page Coder Social logo

akamaiopen-edgegrid-php's Introduction

akamai-open/edgegrid-auth

License Build Status Code Coverage API Docs

Akamai {OPEN} EdgeGrid Authentication for PHP

Note: in version 0.6.0 of the akamai-open/edgegrid-client it was moved to it's own repository, and the \Akamai\Open\EdgeGrid\Authentication library was seperated into the akamai-open/edgegrid-auth package (this repo).

This library implements the Akamai {OPEN} EdgeGrid Authentication scheme.

For more information visit the Akamai {OPEN} Developer Community.

Installation

This library requires PHP 5.3.9+, or HHVM 3.5+ to be used with the built-in Guzzle HTTP client.

PHP 5.3 has been end of life (EOL) since August 14th, 2014, and has known security vulnerabilities, therefore we do not recommend using it. However, we understand that many actively supported LTS distributions are still shipping with PHP 5.3.

To install, use composer:

$ composer require akamai-open/edgegrid-auth

Alternative Install: Single File (PHAR)

Alternatively, download the PHAR file from the releases page.

To use it, you just include it inside your code:

include 'akamai-open-edgegrid-auth.phar';

// Library is ready to use

Alternative Install: Git/Subversion/ZIP Archive

You can clone this repository using git, this repository using subversion, or download the latest ZIP archive or a specific release ZIP archive.

Using the Composer Autoloader

To use the composer autoloader, you must install the dependencies using:

$ composer install

Then include the autoloader:

require_once 'vendor/autoload.php';

Without Composer 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';

Usage

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('/diagnostic-tools/v1/locations');

$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));

Author

Davey Shafik [email protected]

License

Copyright 2016Authentication/ 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.

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.