Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

auth/styles/oauth.php
Go to the documentation of this file.
1 <?php
12 class ezpRestOauthAuthenticationStyle extends ezpRestAuthenticationStyle implements ezpRestAuthenticationStyleInterface
13 {
14 // @TODO auth vars should probably be shared internally here.
15 public function setup( ezcMvcRequest $request )
16 {
17 // Setup for testing credentials
18 // Check for required components (fail if not present)
19 // Fail if too many components are required (according to spec, later)
20 // Validate components
21
22 $token = ezpOauthUtility::getToken( $request );
23 $cred = new ezcAuthenticationIdCredentials( $token );
24 $oauthFilter = new ezpOauthFilter();
25
26 $auth = new ezcAuthentication( $cred );
27 $auth->addFilter( $oauthFilter );
28 return $auth;
29 }
30
31 public function authenticate( ezcAuthentication $auth, ezcMvcRequest $request )
32 {
33 if ( !$auth->run() )
34 {
35 $aStatuses = $auth->getStatus();
36 $statusCode = null;
37 foreach ( $aStatuses as $status )
38 {
39 if ( key( $status ) === 'ezpOauthFilter' )
40 {
41 $statusCode = current( $status );
42 break;
43 }
44 }
45
46 $request->variables['ezpAuth_redirUrl'] = $request->uri;
47 $request->variables['ezpAuth_reason'] = $statusCode;
48 $request->uri = "{$this->prefix}/auth/oauth/login";
49 return new ezcMvcInternalRedirect( $request );
50 }
51 else
52 {
53 $user = eZUser::fetch( ezpOauthFilter::$tokenInfo->user_id );
54 if ( !$user instanceof eZUser )
55 {
56 throw new ezpUserNotFoundException( ezpOauthFilter::$tokenInfo->user_id );
57 }
58
59 return $user;
60 }
61 }
62
80 function processLoginRequired( ezcMvcResult $res, $reasons, $errorMap = null )
81 {
82 $reasonText = array();
83
84 if ( $errorMap === null )
85 {
86 $errorMap = array(
87 'ezpOauthFilter' => array(
88 ezpOauthFilter::STATUS_TOKEN_INVALID => 'Token has expired.',
89 ezpOauthFilter::STATUS_TOKEN_EXPIRED => 'Token has expired, please refresh it.',
90 ezpOauthFilter::STATUS_TOKEN_INSUFFICIENT_SCOPE => 'You do have do have sufficient scope to access this resource.',
91 ),
92 );
93 }
94
95 foreach ( $reasons as $line )
96 {
97 $reasonText[] = $errorMap[key( $line )][current( $line )];
98 }
99 $res->variables['ezcAuth_reasons'] = $reasonText;
100 }
101 }
102 ?>
$status
$status
Definition: bugedit.php:473
eZUser
Definition: ezuser.php:76
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\$tokenInfo
static $tokenInfo
Definition: oauth_filter.php:23
ezpOauthFilter\STATUS_TOKEN_INSUFFICIENT_SCOPE
const STATUS_TOKEN_INSUFFICIENT_SCOPE
Definition: oauth_filter.php:16
ezpOauthUtility\getToken
static getToken(ezcMvcRequest $request)
Definition: utility.php:38
ezpRestAuthenticationStyle
Definition: abstract_auth_style.php:12
ezpRestAuthenticationStyle\$user
$user
Definition: abstract_auth_style.php:17
ezpRestOauthAuthenticationStyle
Definition: auth/styles/oauth.php:13
ezpRestOauthAuthenticationStyle\authenticate
authenticate(ezcAuthentication $auth, ezcMvcRequest $request)
Definition: auth/styles/oauth.php:31
ezpRestOauthAuthenticationStyle\processLoginRequired
processLoginRequired(ezcMvcResult $res, $reasons, $errorMap=null)
Definition: auth/styles/oauth.php:80
ezpRestOauthAuthenticationStyle\setup
setup(ezcMvcRequest $request)
Definition: auth/styles/oauth.php:15
ezpUserNotFoundException
Definition: user_not_found.php:12
$res
$res
Definition: ezstats/admin/cron.php:45
ezpRestAuthenticationStyleInterface
Definition: auth_style.php:13
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.