Open Journal Systems  3.3.0
Guzzle\Plugin\Oauth\OauthPlugin Class Reference
Inheritance diagram for Guzzle\Plugin\Oauth\OauthPlugin:
Symfony\Component\EventDispatcher\EventSubscriberInterface

Public Member Functions

 __construct ($config)
 
 generateNonce (RequestInterface $request)
 
 getParamsToSign (RequestInterface $request, $timestamp, $nonce)
 
 getSignature (RequestInterface $request, $timestamp, $nonce)
 
 getStringToSign (RequestInterface $request, $timestamp, $nonce)
 
 getTimestamp (Event $event)
 
 onRequestBeforeSend (Event $event)
 
 shouldPostFieldsBeSigned ($request)
 

Static Public Member Functions

static getSubscribedEvents ()
 

Data Fields

const REQUEST_METHOD_HEADER = 'header'
 
const REQUEST_METHOD_QUERY = 'query'
 

Protected Member Functions

 getOauthParams ($timestamp, $nonce)
 
 prepareParameters ($data)
 

Protected Attributes

 $config
 

Detailed Description

OAuth signing plugin http://oauth.net/core/1.0/#rfc.section.9.1.1

Definition at line 17 of file OauthPlugin.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Plugin\Oauth\OauthPlugin::__construct (   $config)

Create a new OAuth 1.0 plugin

Parameters
array$configConfiguration array containing these parameters:
  • string 'request_method' Consumer request method. Use the class constants.
  • string 'callback' OAuth callback
  • string 'consumer_key' Consumer key
  • string 'consumer_secret' Consumer secret
  • string 'token' Token
  • string 'token_secret' Token secret
  • string 'verifier' OAuth verifier.
  • string 'version' OAuth version. Defaults to 1.0
  • string 'signature_method' Custom signature method
  • bool 'disable_post_params' Set to true to prevent POST parameters from being signed
  • array|Closure 'signature_callback' Custom signature callback that accepts a string to sign and a signing key

Definition at line 47 of file OauthPlugin.php.

References Guzzle\Plugin\Oauth\OauthPlugin\$config, and Guzzle\Common\Collection\fromConfig().

Member Function Documentation

◆ generateNonce()

Guzzle\Plugin\Oauth\OauthPlugin::generateNonce ( RequestInterface  $request)

Returns a Nonce Based on the unique id and URL. This will allow for multiple requests in parallel with the same exact timestamp to use separate nonce's.

Parameters
RequestInterface$requestRequest to generate a nonce for
Returns
string

Definition at line 266 of file OauthPlugin.php.

References Guzzle\Http\Message\RequestInterface\getUrl().

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\onRequestBeforeSend().

◆ getOauthParams()

Guzzle\Plugin\Oauth\OauthPlugin::getOauthParams (   $timestamp,
  $nonce 
)
protected

Get the oauth parameters as named by the oauth spec

Parameters
$timestamp
$nonce
Returns
Collection

Definition at line 178 of file OauthPlugin.php.

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\getParamsToSign(), and Guzzle\Plugin\Oauth\OauthPlugin\onRequestBeforeSend().

◆ getParamsToSign()

Guzzle\Plugin\Oauth\OauthPlugin::getParamsToSign ( RequestInterface  $request,
  $timestamp,
  $nonce 
)

Get all of the parameters required to sign a request including:

  • The oauth params
  • The request GET params
  • The params passed in the POST body (with a content-type of application/x-www-form-urlencoded)
Parameters
RequestInterface$requestRequest to generate a signature for
integer$timestampTimestamp to use for nonce
string$nonce
Returns
array

Definition at line 217 of file OauthPlugin.php.

References Guzzle\Plugin\Oauth\OauthPlugin\getOauthParams(), Guzzle\Http\Message\RequestInterface\getQuery(), and Guzzle\Plugin\Oauth\OauthPlugin\shouldPostFieldsBeSigned().

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\getStringToSign().

◆ getSignature()

Guzzle\Plugin\Oauth\OauthPlugin::getSignature ( RequestInterface  $request,
  $timestamp,
  $nonce 
)

Calculate signature for request

Parameters
RequestInterface$requestRequest to generate a signature for
integer$timestampTimestamp to use for nonce
string$nonce
Returns
string

Definition at line 136 of file OauthPlugin.php.

References Guzzle\Plugin\Oauth\OauthPlugin\getStringToSign().

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\onRequestBeforeSend().

◆ getStringToSign()

Guzzle\Plugin\Oauth\OauthPlugin::getStringToSign ( RequestInterface  $request,
  $timestamp,
  $nonce 
)

Calculate string to sign

Parameters
RequestInterface$requestRequest to generate a signature for
int$timestampTimestamp to use for nonce
string$nonce
Returns
string

Definition at line 153 of file OauthPlugin.php.

References Guzzle\Http\Url\factory(), Guzzle\Http\Message\RequestInterface\getMethod(), Guzzle\Plugin\Oauth\OauthPlugin\getParamsToSign(), Guzzle\Http\Message\RequestInterface\getQuery(), Guzzle\Http\Message\RequestInterface\getUrl(), and Guzzle\Plugin\Oauth\OauthPlugin\prepareParameters().

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\getSignature().

◆ getSubscribedEvents()

static Guzzle\Plugin\Oauth\OauthPlugin::getSubscribedEvents ( )
static

Returns an array of event names this subscriber wants to listen to.

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • array('eventName' => 'methodName')
  • array('eventName' => array('methodName', $priority))
  • array('eventName' => array(array('methodName1', $priority), array('methodName2')))
Returns
array The event names to listen to

Implements Symfony\Component\EventDispatcher\EventSubscriberInterface.

Definition at line 64 of file OauthPlugin.php.

Referenced by Guzzle\Tests\Plugin\Oauth\OauthPluginTest\testSubscribesToEvents().

◆ getTimestamp()

Guzzle\Plugin\Oauth\OauthPlugin::getTimestamp ( Event  $event)

Gets timestamp from event or create new timestamp

Parameters
Event$eventEvent containing contextual information
Returns
int

Definition at line 278 of file OauthPlugin.php.

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\onRequestBeforeSend().

◆ onRequestBeforeSend()

◆ prepareParameters()

Guzzle\Plugin\Oauth\OauthPlugin::prepareParameters (   $data)
protected

Convert booleans to strings, removed unset parameters, and sorts the array

Parameters
array$dataData array
Returns
array

Definition at line 290 of file OauthPlugin.php.

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\getStringToSign().

◆ shouldPostFieldsBeSigned()

Guzzle\Plugin\Oauth\OauthPlugin::shouldPostFieldsBeSigned (   $request)

Decide whether the post fields should be added to the base string that Oauth signs. This implementation is correct. Non-conformant APIs may require that this method be overwritten e.g. the Flickr API incorrectly adds the post fields when the Content-Type is 'application/x-www-form-urlencoded'

Parameters
$request
Returns
bool Whether the post fields should be signed or not

Definition at line 246 of file OauthPlugin.php.

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\getParamsToSign().

Field Documentation

◆ $config

Collection Guzzle\Plugin\Oauth\OauthPlugin::$config
protected

Configuration settings

Definition at line 29 of file OauthPlugin.php.

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\__construct().

◆ REQUEST_METHOD_HEADER

const Guzzle\Plugin\Oauth\OauthPlugin::REQUEST_METHOD_HEADER = 'header'

Consumer request method constants. See http://oauth.net/core/1.0/#consumer_req_param

Definition at line 22 of file OauthPlugin.php.

Referenced by Guzzle\Plugin\Oauth\OauthPlugin\onRequestBeforeSend().

◆ REQUEST_METHOD_QUERY

const Guzzle\Plugin\Oauth\OauthPlugin::REQUEST_METHOD_QUERY = 'query'

The documentation for this class was generated from the following file: