devster / buzz-wsse-plugin
Buzz plugin to manage WSSE authentication
Installs: 19 080
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.3
Requires (Dev)
- atoum/atoum: dev-master
- kriswallsmith/buzz: dev-master
This package is auto-updated.
Last update: 2024-10-29 01:57:21 UTC
README
Buzz plugin to manage WSSE authentication
Buzz is a lightweight PHP 5.3 library for issuing HTTP requests.
More informations on WSSE authentication http://www.xml.com/pub/a/2003/12/17/dive.html
Installation
Install via composer
# Install Composer curl -sS https://getcomposer.org/installer | php # Add the plugin as a dependency php composer.phar require devster/buzz-wsse-plugin:~1.0
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Basic usage
require 'vendor/autoload.php' use Buzz\Browser; use Devster\Buzz\Listener\WsseAuthListener; // Create a Buzz client $browser = new Browser(); // and add the Wsse listener $browser->addListener(new WsseAuthListener('username', '*******')); // finally use Buzz as usual $response = $browser->get('http://www.google.com'); echo $browser->getLastRequest()."\n"; echo $response;
Customization
All the plugin is configurable: the way to generate the nonce, the timestamp and also the password digest.
use Buzz\Browser; use Buzz\Message\RequestInterface; use Devster\Buzz\Listener\WsseAuthListener; $browser = new Buzz\Browser(); $wsse = new WsseAuthListener('bob', '*********'); $wsse // Customize the nonce generator // A callable that must return a string ->setNonceCallback(function(RequestInterface $request) { return uniqid('myapp_', true); }) // Customize the timestamp generator // A callable that must return a string ->setTimestampCallback(function(RequestInterface $request) { $date = new \DateTime("now"); return $date->format('c'); }) // Customize the digest generator // A callable that must return a string ->setDigestCallback(function($nonce, $timestamp, $password, RequestInterface $request) { return hash('sha512', $nonce.$timestamp.$password, true); }) ; // add the listener to the browser $browser->addListener($wsse);
Tests
Unit tests are made with atoum.
composer install --dev ./vendor/bin/atoum
License
This plugin is licensed under the MIT License