Skip to content

Commit 72fcaa2

Browse files
authored
Merge pull request #1161 from CakeDC/improve-docs
Improve docs
2 parents f49e0f8 + 58ff09d commit 72fcaa2

17 files changed

+867
-254
lines changed

Docs/Documentation/Authentication.md

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,21 @@ The ``skipTwoFactorVerify`` option is used to skip the two factor flow for a giv
7777
Identifiers
7878
-----------
7979

80-
The identifiers are defined to work correctly with the default authenticators, we are using these identifiers:
80+
The identifiers are defined to work correctly with the default authenticators. We are using these identifiers:
8181

82-
- ``Authentication.Password``, for ``Form`` authenticator
83-
- ``CakeDC/Users.Social``, for ``Social`` and ``SocialPendingEmail`` authenticators
84-
- ``Authentication.Token``, for ``Token`` authenticator
82+
- `Authentication.Password`, for `Form` authenticator
83+
- `CakeDC/Users.Social`, for `Social` and `SocialPendingEmail` authenticators
84+
- `Authentication.Token`, for `Token` authenticator
8585

86-
As you add more authenticators you may also need to add other identifiers, please see [the identifiers available in the official CakePHP Authentication plugin documentation](https://book.cakephp.org/authentication/2/en/identifiers.html).
86+
As you add more authenticators you may also need to add other identifiers. Please see [the identifiers available in the official CakePHP Authentication plugin documentation](https://book.cakephp.org/authentication/3/en/identifiers.html).
8787

88-
The default list for ``Auth.Identifiers`` is:
88+
> **Note:** Configuring identifiers globally via `Auth.Identifiers` is deprecated. Please move each identifier's configuration into the `identifier` key within its specific authenticator under `Auth.Authenticators`.
89+
90+
The default list for `Auth.Authenticators.Form.identifier` is:
8991

9092
```php
91-
[
92-
'Password' => [
93+
'identifier' => [
94+
'Authentication.Password' => [
9395
'className' => 'Authentication.Password',
9496
'fields' => [
9597
'username' => ['username', 'email'],
@@ -100,49 +102,42 @@ The default list for ``Auth.Identifiers`` is:
100102
'finder' => 'active'
101103
],
102104
],
103-
"Social" => [
104-
'className' => 'CakeDC/Users.Social',
105-
'authFinder' => 'active'
106-
],
107-
'Token' => [
108-
'className' => 'Authentication.Token',
109-
'tokenField' => 'api_token',
110-
'resolver' => [
111-
'className' => 'Authentication.Orm',
112-
'finder' => 'active'
113-
],
114-
]
115105
]
116106
```
117107

118-
These identifiers are loaded by the ``\CakeDC\Users\Loader\AuthenticationServiceLoader`` class in the ``loadIdentifiers`` method. See [Authentication Service Loader](#authentication-service-loader) on how to adjust it to your needs.
108+
These identifiers are loaded by the `\CakeDC\Users\Loader\AuthenticationServiceLoader` class. See [Authentication Service Loader](#authentication-service-loader) on how to adjust it to your needs.
119109

120110
Account lockout policy
121111
----------------------
122112
Lock a users account after a number of failed password attempts in a certain time window.
123113

124-
To enable this updated your config/users.php file with:
114+
To enable this, update your `config/users.php` file with:
115+
125116
```php
126-
'Auth.Identifiers.Password.className' => 'CakeDC/Users.PasswordLockout',
127-
'Auth.PasswordRehash' => [
128-
'identifiers' => ['PasswordLockout'],
129-
],
130-
```
131-
Additionally, you can set number of attempts until lock, lockout time, time window and more, eg:
117+
'Auth.Authenticators.Form.identifier.Authentication.Password.className' => 'CakeDC/Users.PasswordLockout',
118+
'Auth.PasswordRehash' => [
119+
'identifiers' => ['PasswordLockout'],
120+
],
132121
```
133-
'Auth.Identifiers.Password.className' => 'CakeDC/Users.PasswordLockout',
134-
'Auth.PasswordRehash' => [
135-
'identifiers' => ['PasswordLockout'],
136-
],
137-
'Auth.Identifiers.Password.lockoutHandler' => [
138-
'timeWindowInSeconds' => 30 * 60,//30 minutes (default is 15 minutes)
139-
'lockoutTimeInSeconds' => 100 * 60,//100 minutes (default is 30 minutes)
122+
123+
Additionally, you can set the number of attempts until lock, lockout time, time window and more, e.g.:
124+
125+
```php
126+
'Auth.Authenticators.Form.identifier.Authentication.Password' => [
127+
'className' => 'CakeDC/Users.PasswordLockout',
128+
'lockoutHandler' => [
129+
'timeWindowInSeconds' => 30 * 60, // 30 minutes (default is 15 minutes)
130+
'lockoutTimeInSeconds' => 100 * 60, // 100 minutes (default is 30 minutes)
140131
'numberOfAttemptsFail' => 4, // default is 6 attempts
141132
'failedPasswordAttemptsModel' => 'CakeDC/Users.FailedPasswordAttempts',
142-
'userLockoutField' => 'lockout_time',//Field in user entity used to lock the user.
133+
'userLockoutField' => 'lockout_time', // Field in user entity used to lock the user.
143134
'usersModel' => 'Users',
144-
'userForeignKeyField' => 'user_id', //Field defined in the 'failed_password_attempts' table as foreignKey of the model Users.
135+
'userForeignKeyField' => 'user_id', // Field defined in the 'failed_password_attempts' table as foreignKey of the model Users.
145136
],
137+
],
138+
'Auth.PasswordRehash' => [
139+
'identifiers' => ['PasswordLockout'],
140+
],
146141
```
147142

148143

Docs/Documentation/Commands.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ bin/cake users activate_user the.target.username
1414

1515
add_superuser
1616
-------------
17-
This command create a user with field `$user->is_superuser = true;`.
17+
This command creates a user with field `$user->is_superuser = true;`.
1818

19-
Quick usage, add a superuser with autogenerated data:
19+
Quick usage: add a superuser with autogenerated data:
2020

2121
```
2222
bin/cake users add_superuser
@@ -32,9 +32,9 @@ bin/cake users add_superuser --username=my.new.superuser --email=some.email@exam
3232

3333
add_user
3434
--------
35-
This command create a user with field `$user->is_superuser = false;`.
35+
This command creates a user with field `$user->is_superuser = false;`.
3636

37-
Quick usage, add a user with autogenerated data:
37+
Quick usage: add a user with autogenerated data:
3838

3939
```
4040
bin/cake users add_user

0 commit comments

Comments
 (0)