Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

basic_auth.php
Go to the documentation of this file.
1 <?php
12 class ezpRestBasicAuthStyle extends ezpRestAuthenticationStyle implements ezpRestAuthenticationStyleInterface
13 {
14 public function setup( ezcMvcRequest $request )
15 {
16 if ( $request->authentication === null )
17 {
18 $authRequest = clone $request;
19 $authRequest->uri = "{$this->prefix}/auth/http-basic-auth";
20 $authRequest->protocol = "http-get";
21
22 return new ezcMvcInternalRedirect( $authRequest );
23 }
24
25 $cred = new ezcAuthenticationPasswordCredentials( $request->authentication->identifier,
26 md5( "{$request->authentication->identifier}\n{$request->authentication->password}" ) );
27 $authDbInfo = new ezcAuthenticationDatabaseInfo( ezcDbInstance::get(), 'ezuser', array( 'login', 'password_hash' ) );
28
29 $auth = new ezcAuthentication( $cred );
30 $auth->addFilter( new ezcAuthenticationDatabaseFilter( $authDbInfo ) );
31 return $auth;
32 }
33
34 public function authenticate( ezcAuthentication $auth, ezcMvcRequest $request )
35 {
36 if ( !$auth->run() )
37 {
38 $request->uri = "{$this->prefix}/auth/http-basic-auth";
39 return new ezcMvcInternalRedirect( $request );
40 }
41 else
42 {
43 // We're in. Get the ezp user and return it
44 return eZUser::fetchByName( $auth->credentials->id );
45 }
46 }
47 }
48 ?>
ezpRestAuthenticationStyle
Definition: abstract_auth_style.php:12
ezpRestBasicAuthStyle
Definition: basic_auth.php:13
ezpRestBasicAuthStyle\authenticate
authenticate(ezcAuthentication $auth, ezcMvcRequest $request)
Definition: basic_auth.php:34
ezpRestBasicAuthStyle\setup
setup(ezcMvcRequest $request)
Definition: basic_auth.php:14
ezpRestAuthenticationStyleInterface
Definition: auth_style.php:13
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.