Fr3nch13/CakePHP Utilities

Oauth
in package

Oauth 1 authentication strategy for Cake\Http\Client

This object does not handle getting Oauth access tokens from the service provider. It only handles make client requests after you have obtained the Oauth tokens.

Generally not directly constructed, but instead used by when $options['auth']['type'] is 'oauth'

Table of Contents

Methods

authentication()  : Request
Add headers for Oauth authorization.
baseString()  : string
Generate the Oauth basestring
_buildAuth()  : string
Builds the Oauth Authorization header value.
_encode()  : string
URL Encodes a value based on rules of rfc3986
_hmacSha1()  : string
Use HMAC-SHA1 signing.
_normalizeData()  : array<string|int, mixed>
Recursively convert request data into the normalized form.
_normalizedParams()  : string
Sorts and normalizes request data and oauthValues
_normalizedUrl()  : string
Builds a normalized URL
_plaintext()  : string
Plaintext signing
_rsaSha1()  : string
Use RSA-SHA1 signing.
checkSslError()  : void
Check for SSL errors and raise if one is encountered.

Methods

authentication()

Add headers for Oauth authorization.

public authentication(Request $request, array<string|int, mixed> $credentials) : Request
Parameters
$request : Request

The request object.

$credentials : array<string|int, mixed>

Authentication credentials.

Tags
throws
CakeException

On invalid signature types.

Return values
Request

The updated request.

baseString()

Generate the Oauth basestring

public baseString(Request $request, array<string|int, mixed> $oauthValues) : string
  • Querystring, request data and oauth_* parameters are combined.
  • Values are sorted by name and then value.
  • Request values are concatenated and urlencoded.
  • The request URL (without querystring) is normalized.
  • The HTTP method, URL and request parameters are concatenated and returned.
Parameters
$request : Request

The request object.

$oauthValues : array<string|int, mixed>

Oauth values.

Return values
string

_buildAuth()

Builds the Oauth Authorization header value.

protected _buildAuth(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

The oauth_* values to build

Return values
string

_encode()

URL Encodes a value based on rules of rfc3986

protected _encode(string $value) : string
Parameters
$value : string

Value to encode.

Return values
string

_hmacSha1()

Use HMAC-SHA1 signing.

protected _hmacSha1(Request $request, array<string|int, mixed> $credentials) : string

This method is suitable for plain HTTP or HTTPS.

Parameters
$request : Request

The request object.

$credentials : array<string|int, mixed>

Authentication credentials.

Return values
string

_normalizeData()

Recursively convert request data into the normalized form.

protected _normalizeData(array<string|int, mixed> $args[, string $path = '' ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed>

The arguments to normalize.

$path : string = ''

The current path being converted.

Tags
see
https://tools.ietf.org/html/rfc5849#section-3.4.1.3.2
Return values
array<string|int, mixed>

_normalizedParams()

Sorts and normalizes request data and oauthValues

protected _normalizedParams(Request $request, array<string|int, mixed> $oauthValues) : string

Section 9.1.1 of Oauth spec.

  • URL encode keys + values.
  • Sort keys & values by byte value.
Parameters
$request : Request

The request object.

$oauthValues : array<string|int, mixed>

Oauth values.

Return values
string

sorted and normalized values

_normalizedUrl()

Builds a normalized URL

protected _normalizedUrl(UriInterface $uri) : string

Section 9.1.2. of the Oauth spec

Parameters
$uri : UriInterface

Uri object to build a normalized version of.

Return values
string

Normalized URL

_plaintext()

Plaintext signing

protected _plaintext(Request $request, array<string|int, mixed> $credentials) : string

This method is not suitable for plain HTTP. You should only ever use PLAINTEXT when dealing with SSL services.

Parameters
$request : Request

The request object.

$credentials : array<string|int, mixed>

Authentication credentials.

Return values
string

Authorization header.

_rsaSha1()

Use RSA-SHA1 signing.

protected _rsaSha1(Request $request, array<string|int, mixed> $credentials) : string

This method is suitable for plain HTTP or HTTPS.

Parameters
$request : Request

The request object.

$credentials : array<string|int, mixed>

Authentication credentials.

Tags
throws
RuntimeException
Return values
string

checkSslError()

Check for SSL errors and raise if one is encountered.

protected checkSslError() : void

        
On this page

Search results