CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • BasicAuthentication
  • DigestAuthentication
  • HttpResponse
  • HttpSocket
 1: <?php
 2: /**
 3:  * Basic authentication
 4:  *
 5:  * PHP 5
 6:  *
 7:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 8:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 9:  *
10:  * Licensed under The MIT License
11:  * Redistributions of files must retain the above copyright notice.
12:  *
13:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
14:  * @link          http://cakephp.org CakePHP(tm) Project
15:  * @package       Cake.Network.Http
16:  * @since         CakePHP(tm) v 2.0.0
17:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
18:  */
19: 
20: /**
21:  * Basic authentication
22:  *
23:  * @package       Cake.Network.Http
24:  */
25: class BasicAuthentication {
26: 
27: /**
28:  * Authentication
29:  *
30:  * @param HttpSocket $http
31:  * @param array $authInfo
32:  * @return void
33:  * @see http://www.ietf.org/rfc/rfc2617.txt
34:  */
35:     public static function authentication(HttpSocket $http, &$authInfo) {
36:         if (isset($authInfo['user'], $authInfo['pass'])) {
37:             $http->request['header']['Authorization'] = self::_generateHeader($authInfo['user'], $authInfo['pass']);
38:         }
39:     }
40: 
41: /**
42:  * Proxy Authentication
43:  *
44:  * @param HttpSocket $http
45:  * @param array $proxyInfo
46:  * @return void
47:  * @see http://www.ietf.org/rfc/rfc2617.txt
48:  */
49:     public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) {
50:         if (isset($proxyInfo['user'], $proxyInfo['pass'])) {
51:             $http->request['header']['Proxy-Authorization'] = self::_generateHeader($proxyInfo['user'], $proxyInfo['pass']);
52:         }
53:     }
54: 
55: /**
56:  * Generate basic [proxy] authentication header
57:  *
58:  * @param string $user
59:  * @param string $pass
60:  * @return string
61:  */
62:     protected static function _generateHeader($user, $pass) {
63:         return 'Basic ' . base64_encode($user . ':' . $pass);
64:     }
65: 
66: }
67: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs