Skip to content

Commit 669672a

Browse files
committed
Adding doc blocks.
1 parent d5f5ae3 commit 669672a

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

cake/libs/controller/components/auth/basic_authenticate.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,32 @@
1313
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1414
*/
1515
App::import('Component', 'auth/base_authenticate');
16-
App::import('Core', 'String');
17-
1816

17+
/**
18+
* Basic Authentication adapter for AuthComponent.
19+
*
20+
* Provides Basic HTTP authentication support for AuthComponent. Basic Auth will authenticate users
21+
* against the configured userModel and verify the username and passwords match. Clients using Basic Authentication
22+
* must support cookies. Since AuthComponent identifies users based on Session contents, clients using Basic
23+
* Auth must support cookies.
24+
*
25+
* ### Using Basic auth
26+
*
27+
* In your controller's components array, add auth + the required settings.
28+
* {{{
29+
* var $components = array(
30+
* 'Auth' => array(
31+
* 'authenticate' => array('Basic')
32+
* )
33+
* );
34+
* }}}
35+
*
36+
* In your login function just call `$this->Auth->login()` without any checks for POST data. This
37+
* will send the authentication headers, and trigger the login dialog in the browser/client.
38+
*
39+
* @package cake.libs.controller.components.auth
40+
* @since 2.0
41+
*/
1942
class BasicAuthenticate extends BaseAuthenticate {
2043
/**
2144
* Settings for this object.
@@ -24,6 +47,7 @@ class BasicAuthenticate extends BaseAuthenticate {
2447
* - `userModel` The model name of the User, defaults to User.
2548
* - `scope` Additional conditions to use when looking up and authenticating users,
2649
* i.e. `array('User.is_active' => 1).`
50+
* - `realm` The realm authentication is for. Defaults the server name.
2751
*
2852
* @var array
2953
*/
@@ -40,6 +64,7 @@ class BasicAuthenticate extends BaseAuthenticate {
4064
/**
4165
* Constructor, completes configuration for basic authentication.
4266
*
67+
* @param array $settings An array of settings.
4368
* @return void
4469
*/
4570
public function __construct($settings) {
@@ -48,6 +73,7 @@ public function __construct($settings) {
4873
$this->settings['realm'] = env('SERVER_NAME');
4974
}
5075
}
76+
5177
/**
5278
* Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a
5379
* login using basic HTTP auth.

cake/libs/controller/components/auth/digest_authenticate.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,45 @@
1515
App::import('Component', 'auth/base_authenticate');
1616
App::import('Core', 'String');
1717

18-
18+
/**
19+
* Digest Authentication adapter for AuthComponent.
20+
*
21+
* Provides Digest HTTP authentication support for AuthComponent. Unlike most AuthComponent adapters,
22+
* DigestAuthenticate requires a special password hash that conforms to RFC2617. You can create this
23+
* password using `DigestAuthenticate::password()`. If you wish to use digest authentication alongside other
24+
* authentication methods, its recommended that you store the digest authentication separately.
25+
*
26+
* Clients using Digest Authentication must support cookies. Since AuthComponent identifies users based
27+
* on Session contents, clients without support for cookies will not function properly.
28+
*
29+
* ### Using Digest auth
30+
*
31+
* In your controller's components array, add auth + the required settings.
32+
* {{{
33+
* var $components = array(
34+
* 'Auth' => array(
35+
* 'authenticate' => array('Digest')
36+
* )
37+
* );
38+
* }}}
39+
*
40+
* In your login function just call `$this->Auth->login()` without any checks for POST data. This
41+
* will send the authentication headers, and trigger the login dialog in the browser/client.
42+
*
43+
* ### Generating passwords compatible with Digest authentication.
44+
*
45+
* Due to the Digest authentication specification, digest auth requires a special password value. You
46+
* can generate this password using `DigestAuthenticate::password()`
47+
*
48+
* `$digestPass = DigestAuthenticate::password($username, env('SERVER_NAME'), $password);`
49+
*
50+
* Its recommended that you store this digest auth only password separate from password hashes used for other
51+
* login methods. For example `User.digest_pass` could be used for a digest password, while `User.password` would
52+
* store the password hash for use with other methods like Basic or Form.
53+
*
54+
* @package cake.libs.controller.components.auth
55+
* @since 2.0
56+
*/
1957
class DigestAuthenticate extends BaseAuthenticate {
2058
/**
2159
* Settings for this object.
@@ -24,6 +62,10 @@ class DigestAuthenticate extends BaseAuthenticate {
2462
* - `userModel` The model name of the User, defaults to User.
2563
* - `scope` Additional conditions to use when looking up and authenticating users,
2664
* i.e. `array('User.is_active' => 1).`
65+
* - `realm` The realm authentication is for, Defaults to the servername.
66+
* - `nonce` A nonce used for authentication. Defaults to `uniqid()`.
67+
* - `qop` Defaults to auth, no other values are supported at this time.
68+
* - `opaque` A string that must be returned unchanged by clients. Defaults to `md5($settings['realm'])`
2769
*
2870
* @var array
2971
*/
@@ -43,6 +85,7 @@ class DigestAuthenticate extends BaseAuthenticate {
4385
/**
4486
* Constructor, completes configuration for digest authentication.
4587
*
88+
* @param array $settings An array of settings.
4689
* @return void
4790
*/
4891
public function __construct($settings) {

0 commit comments

Comments
 (0)