kernel/private/rest/classes/oauth/utility.php

Show: inherited
Table of Contents

File containing the ezpOuathUtility class

Copyright
Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.  
License
eZ Business Use License Agreement Version 2.0  
Package
kernel  
Version
4.6.0  

\ezpOauthUtility

Package: rest

Functionality for working against the draft 10 of the oauth2 spec.

Parent(s)
\ezpRestModel

Constants

Constant  AUTH_HEADER_NAME = 'Authorization'
Constant  AUTH_CGI_HEADER_NAME = 'HTTP_AUTHORIZATION'

Methods

methodpublicdoRefreshToken( string $clientId, string $clientSecret, string $refreshToken ) : \ezpRestToken
static

Handles a refresh_token request.

Returns the new token object as ezpRestToken

Parameters
Name Type Description
$clientId string

Client identifier

$clientSecret string

Client secret key

$refreshToken string

Refresh token

Returns
Type Description
\ezpRestToken
Throws
Exception Description
\ezpOauthInvalidRequestException
methodpublicdoRefreshTokenWithAuthorizationCode( string $clientId, string $clientSecret, string $authCode, string $redirectUri ) : \ezpRestToken
static

Generates a new token against an authorization_code Auth code is checked against clientId, clientSecret and redirectUri as registered for client in admin Auth code is for one-use only and will be removed once the access token generated

Parameters
Name Type Description
$clientId string

Client identifier

$clientSecret string

Client secret key

$authCode string

Authorization code provided by the client

$redirectUri string

Redirect URI. Must be the same as registered in admin

Returns
Type Description
\ezpRestToken
Throws
Exception Description
\ezpOauthInvalidRequestException
\ezpOauthInvalidTokenException
\ezpOauthExpiredTokenException
methodpublicgetToken(  $request ) : void
static

Retrieving token as per section 5 of draft-ietf-oauth-v2-10

Token can be present inside the Authorize header, inside a URI query parameter, or in the HTTP body.

According to section 5.1 the header is the preferred way, and the query component and HTTP body are only looked at if no such header can be found.

Parameters
Name Type Description
$request
Details
TODO
A configuration mechanism should alternatively let us select which method to use: 1. header, 2. query component, 3. http body, in other words to override the default behaviour according to spec.  
methodprotectedgetTokenFromAuthorizationHeader( ) : string
static

Extracts the OAuth token from the HTTP header, Authorization.

The token is transmitted via the OAuth Authentication scheme ref. Section 5.1.1.

PHP does not expose the Authorization header unless it uses the 'Basic' or 'Digest' schemes, and it is therefore extracted from the raw Apache headers.

On systems running CGI or Fast-CGI PHP makes this header available via the HTTP_AUTHORIZATION header.

Returns
Type Description
string The access token string.
Throws
Exception Description
\ezpOauthInvalidRequestException
Details
Link
http://php.net/manual/en/features.http-auth.php  
methodprotectedgetTokenFromHttpBody( \ezpRestRequest $request ) : string
static

Extracts OAuth token fro HTTP Post body.

For more information see section 5.1.3 oauth2.0 v10

Parameters
Name Type Description
$request \ezpRestRequest
Returns
Type Description
string The access token string
methodprotectedgetTokenFromQueryComponent( \ezcMvcRequest $request ) : string
static

Extracts OAuth token query component aka GET parameter.

For more information See section 5.1.2 of oauth2.0 v10

Parameters
Name Type Description
$request \ezcMvcRequest
Returns
Type Description
string The access token string
Throws
Exception Description
\ezpOauthInvalidRequestException
Documentation was generated by DocBlox 0.18.1.