Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

oauth_filter.php
Go to the documentation of this file.
1 <?php
12 class ezpOauthFilter extends ezcAuthenticationFilter
13 {
14 const STATUS_TOKEN_INVALID = 1;
15 const STATUS_TOKEN_EXPIRED = 2;
16 const STATUS_TOKEN_INSUFFICIENT_SCOPE = 3;
17 const STATUS_TOKEN_UNAVAILABLE = 4;
18
23 public static $tokenInfo;
24
25 // @TODO Need to setup status codes for oauth
26 public function run( $credentials )
27 {
28 $status = self::STATUS_TOKEN_INVALID; // Assume invalid token as a default, safer
29 if ( !isset( $credentials->id ) )
30 {
31 return self::STATUS_TOKEN_UNAVAILABLE;
32 }
33 else
34 {
35 // Fetch and validate token for validity and optionally scope.
36 // Either let the request pass, or immediately bail with 401.
37 // Section 5.2.1 for error handling.
38 //
39 // invalid_request missing required params -> 400
40 //
41 // invalid_token Expired token which cannot be refreshed -> 401
42 //
43 // expired_token Token has expired -> 401
44 //
45 // insufficient_scope The requested scope is outside scope associated with token -> 403
46 //
47 // Do not include error info for requests which did not contain auth details.ref. 5.2.1
48
49 // Checking for existance of token
50 // Query made below will check if user's access grant is still valid
51 $tokenInfo = ezpRestToken::fetch( $credentials->id );
52 if ( !$tokenInfo instanceof ezpRestToken )
53 {
54 return self::STATUS_TOKEN_INVALID;
55 //throw new ezpOauthInvalidTokenException( "Specified token does not exist." );
56 }
57
58 // Check expiry of token
59 if ( $tokenInfo->expirytime > 0 )
60 {
61 if ( $tokenInfo->expirytime < time() )
62 {
63 $d = date( "c", $tokenInfo->expirytime );
64 return self::STATUS_TOKEN_EXPIRED;
65 //throw new ezpOauthExpiredTokenException( "Token expired on {$d}" );
66 }
67 }
68
69 self::$tokenInfo = $tokenInfo;
70
71 // Scope checking to be implemented.
72 // Currently some hooks ought to be added to eZP to maximise the
73 // benefit to this field.
74
75 $status = self::STATUS_OK;
76 }
77
78 return $status;
79 }
80 }
81 ?>
$status
$status
Definition: bugedit.php:473
ezpOauthFilter
Definition: oauth_filter.php:13
ezpOauthFilter\STATUS_TOKEN_EXPIRED
const STATUS_TOKEN_EXPIRED
Definition: oauth_filter.php:15
ezpOauthFilter\STATUS_TOKEN_INVALID
const STATUS_TOKEN_INVALID
Definition: oauth_filter.php:14
ezpOauthFilter\STATUS_TOKEN_UNAVAILABLE
const STATUS_TOKEN_UNAVAILABLE
Definition: oauth_filter.php:17
ezpOauthFilter\run
run( $credentials)
Definition: oauth_filter.php:26
ezpOauthFilter\$tokenInfo
static $tokenInfo
Definition: oauth_filter.php:23
ezpOauthFilter\STATUS_TOKEN_INSUFFICIENT_SCOPE
const STATUS_TOKEN_INSUFFICIENT_SCOPE
Definition: oauth_filter.php:16
ezpRestToken
Definition: ezprest_token.php:17
ezpRestToken\fetch
static fetch( $accessToken, $authCheck=true)
Definition: ezprest_token.php:110
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.