devster / guzzle-wsse-plugin
Guzzle plugin to manage WSSE authentication
Installs: 29 409
Dependents: 4
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- guzzlehttp/guzzle: 4.*
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-10-29 01:56:58 UTC
README
Guzzle Plugin to manage WSSE Authentication
More informations on WSSE authentication http://www.xml.com/pub/a/2003/12/17/dive.html
- Guzzle 3: install
1.*
version - Guzzle 4: install
2.*
version
Installation
Install via composer
# Install Composer curl -sS https://getcomposer.org/installer | php # Add the plugin as a dependency php composer.phar require devster/guzzle-wsse-plugin:~2.0
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Basic usage
require 'vendor/autoload.php'; use GuzzleHttp\Client; use Devster\GuzzleHttp\Subscriber\WsseAuth; // Create a Guzzle client $client new Client(['base_url' => 'http://example.com']); // and add it the plugin (new WsseAuth('username', 'pass****'))->attach($client); // Or $client->getEmitter()->attach(new WsseAuth('username', '********')); // Now the plugin will add the correct WSSE headers to your guzzle request $response = $client->get('/data')->send();
Customization
You can customize:
- The nonce generation
- The digest generation
- And the date format
use GuzzleHttp\Client; use GuzzleHttp\Message\RequestInterface; use Devster\GuzzleHttp\Subscriber\WsseAuth; $client = new Client; $plugin = new WsseAuth('username', 'pass****'); $plugin ->attach($client) ->setNonce(function (RequestInterface $request) { return uniqid('my_nonce', true); }) ->setDigest(function ($nonce, $createdAt, $password) { return $nonce.$createdAt.$password; }) ->setDateFormat('Y-m-d') // PHP format. Default: c (ISO 8601) // Process a behavior (like hashing) on the password before it pass to the digest generator ->setPasswordProcessor(function ($password) { return sha1($password); }) ;
Tests
composer install && vendor/bin/phpunit
License
This plugin is licensed under the MIT License