PHP Class Imbo\EventListener\AccessToken

This event listener will listen to all GET and HEAD requests and make sure that they include a valid access token. The official PHP-based imbo client (https://github.com/imbo/imboclient-php) appends this token to all such requests by default. If the access token is missing or invalid the event listener will throw an exception resulting in a HTTP response with 400 Bad Request.
Author: Christer Edvartsen ([email protected])
Inheritance: implements Imbo\EventListener\ListenerInterface
Show file Open project: imbo/imbo Class Usage Examples

Public Methods

Method Description
__construct ( array $params = null ) Class constructor
checkAccessToken ( Imbo\EventManager\EventInterface $event )
getSubscribedEvents ( )

Protected Methods

Method Description
getAlternativeURL ( string $url, integer $encoding = PHP_QUERY_RFC3986 ) : string Helper method to generate an alternative form of an URL, where array indices have either been added or removed. foo[] is transformed into foo[0], while foo[0] is transformed into foo[].
getEscapedAlternativeURL ( $url ) : string Generate an escaped, alternative version of an url.
getUnescapedAlternativeURL ( $url ) : string Generate an unescaped, alternative version of an url.

Private Methods

Method Description
isWhitelisted ( Request $request ) : boolean Check if the request is whitelisted

Method Details

__construct() public method

Class constructor
public __construct ( array $params = null )
$params array Parameters for the listener

checkAccessToken() public method

public checkAccessToken ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface

getAlternativeURL() protected method

The result for URLs with both formats is undefined, or for URLs that intermingle their parameters, i.e. t[]=foo&b[]=bar&t[]=baz This was introduced because of differences between the URLs generated by the different clients, and because Facebook (at least) generates URLs were []s in URL arguments are expanded to [0] when requested from the backend. Since we sign our URLs, this breaks the token generation and thus breaks URLs when Facebook attempts to retrieve them.
protected getAlternativeURL ( string $url, integer $encoding = PHP_QUERY_RFC3986 ) : string
$url string The URL to generate the alternative form of
$encoding integer The encoding to use - from GuzzleHttp\Psr7
return string

getEscapedAlternativeURL() protected method

Generate an escaped, alternative version of an url.
See also: AccessToken::getAlternativeURL()
protected getEscapedAlternativeURL ( $url ) : string
$url string The URL to generate the alternative version of
return string

getSubscribedEvents() public static method

public static getSubscribedEvents ( )

getUnescapedAlternativeURL() protected method

Generate an unescaped, alternative version of an url.
See also: AccessToken::getAlternativeURL()
protected getUnescapedAlternativeURL ( $url ) : string
$url string The URL to generate the alternative version of
return string