Skip to content

Commit 956de5f

Browse files
committed
Fix linting errors
1 parent 92e44aa commit 956de5f

17 files changed

+126
-126
lines changed

docs/en/authentication-component.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You can use the `AuthenticationComponent` to access the result of
44
authentication, get user identity and logout user. Load the component in your
55
`AppController::initialize()` like any other component:
66

7-
``` php
7+
```php
88
$this->loadComponent('Authentication.Authentication', [
99
'logoutRedirect' => '/users/login' // Default is false
1010
]);
@@ -14,7 +14,7 @@ Once loaded, the `AuthenticationComponent` will require that all actions have an
1414
authenticated user present, but perform no other access control checks. You can
1515
disable this check for specific actions using `allowUnauthenticated()`:
1616

17-
``` php
17+
```php
1818
// In your controller's beforeFilter method.
1919
$this->Authentication->allowUnauthenticated(['view']);
2020
```
@@ -24,13 +24,13 @@ $this->Authentication->allowUnauthenticated(['view']);
2424
You can get the authenticated user identity data using the authentication
2525
component:
2626

27-
``` php
27+
```php
2828
$user = $this->Authentication->getIdentity();
2929
```
3030

3131
You can also get the identity directly from the request instance:
3232

33-
``` php
33+
```php
3434
$user = $request->getAttribute('identity');
3535
```
3636

@@ -39,7 +39,7 @@ $user = $request->getAttribute('identity');
3939
You can check if the authentication process was successful by accessing the
4040
result object:
4141

42-
``` php
42+
```php
4343
// Using Authentication component
4444
$result = $this->Authentication->getResult();
4545

@@ -73,7 +73,7 @@ the included authenticators don't put anything in here.
7373

7474
To log an identity out just do:
7575

76-
``` php
76+
```php
7777
$this->Authentication->logout();
7878
```
7979

@@ -83,13 +83,13 @@ in either case.
8383

8484
Alternatively, instead of the component you can also use the service to log out:
8585

86-
``` php
86+
```php
8787
$return = $request->getAttribute('authentication')->clearIdentity($request, $response);
8888
```
8989

9090
The result returned will contain an array like this:
9191

92-
``` php
92+
```php
9393
[
9494
'response' => object(Cake\Http\Response) { ... },
9595
'request' => object(Cake\Http\ServerRequest) { ... },
@@ -108,7 +108,7 @@ By default `AuthenticationComponent` will automatically enforce an identity to
108108
be present during the `Controller.startup` event. You can have this check
109109
applied during the `Controller.initialize` event instead:
110110

111-
``` php
111+
```php
112112
// In your controller's initialize() method.
113113
$this->loadComponent('Authentication.Authentication', [
114114
'identityCheckEvent' => 'Controller.initialize',
@@ -118,6 +118,6 @@ $this->loadComponent('Authentication.Authentication', [
118118
You can also disable identity checks entirely with the `requireIdentity`
119119
option or by calling `disableIdentityCheck` from the controller's `beforeFilter()` method itself:
120120

121-
``` php
121+
```php
122122
$this->Authentication->disableIdentityCheck();
123123
```

docs/en/authenticators.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ With only the ID stored, the invalidation due to objects being modified will als
3030
A default `TokenIdentifier` is provided that looks up users by their `id` field,
3131
so minimal configuration is required:
3232

33-
``` php
33+
```php
3434
$service->loadAuthenticator('Authentication.PrimaryKeySession');
3535
```
3636

@@ -43,15 +43,15 @@ Configuration options:
4343
For custom lookup fields, the `idField` and `identifierKey` options propagate
4444
to the default identifier automatically:
4545

46-
``` php
46+
```php
4747
$service->loadAuthenticator('Authentication.PrimaryKeySession', [
4848
'idField' => 'uuid',
4949
]);
5050
```
5151

5252
You can also provide a fully custom identifier configuration if needed:
5353

54-
``` php
54+
```php
5555
$service->loadAuthenticator('Authentication.PrimaryKeySession', [
5656
'identifier' => [
5757
'Authentication.Token' => [
@@ -109,7 +109,7 @@ Configuration options:
109109

110110
An example of getting a token from a header, or query string would be:
111111

112-
``` php
112+
```php
113113
$service->loadAuthenticator('Authentication.Token', [
114114
'queryParam' => 'token',
115115
'header' => 'Authorization',
@@ -122,7 +122,7 @@ as long as the token was preceded by `Token` and a space.
122122

123123
The token will always be passed to the configured identifier as follows:
124124

125-
``` php
125+
```php
126126
[
127127
'token' => '{token-value}',
128128
]
@@ -158,7 +158,7 @@ the value of `Cake\Utility\Security::salt()` as encryption key.
158158
For enhanced security one can instead use the `RS256` asymmetric key algorithm.
159159
You can generate the required keys for that as follows:
160160

161-
``` text
161+
```text
162162
# generate private key
163163
openssl genrsa -out config/jwt.key 1024
164164
# generate public key
@@ -175,7 +175,7 @@ for token verification.
175175

176176
Add the following to your `Application` class:
177177

178-
``` php
178+
```php
179179
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
180180
{
181181
$service = new AuthenticationService();
@@ -193,7 +193,7 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
193193

194194
In your `UsersController`:
195195

196-
``` php
196+
```php
197197
use Firebase\JWT\JWT;
198198

199199
public function login()
@@ -221,7 +221,7 @@ public function login()
221221

222222
Using a JWKS fetched from an external JWKS endpoint is supported as well:
223223

224-
``` php
224+
```php
225225
// Application.php
226226
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
227227
{
@@ -257,7 +257,7 @@ prepared to handle signing key rotations.
257257
Beside from sharing the public key file to external application, you can
258258
distribute it via a JWKS endpoint by configuring your app as follows:
259259

260-
``` php
260+
```php
261261
// config/routes.php
262262
$builder->setExtensions('json');
263263
$builder->connect('/.well-known/:controller/*', [
@@ -372,7 +372,7 @@ after their session expires for as long as the cookie is valid. If a user is
372372
explicity logged out via `AuthenticationComponent::logout()` the
373373
authentication cookie is **also destroyed**. An example configuration would be:
374374

375-
``` php
375+
```php
376376
// In Application::getAuthenticationService()
377377

378378
// Reuse fields in multiple authenticators.
@@ -403,7 +403,7 @@ $service->loadAuthenticator('Authentication.Cookie', [
403403

404404
You'll also need to add a checkbox to your login form to have cookies created:
405405

406-
``` php
406+
```php
407407
// In your login view
408408
<?= $this->Form->control('remember_me', ['type' => 'checkbox']);
409409
```
@@ -419,7 +419,7 @@ environment variables exposed by the webserver. This enables authentication via
419419
[Shibboleth](https://shibboleth.atlassian.net/wiki/spaces/CONCEPT/overview)
420420
and similar SAML 1.1 implementations. An example configuration is:
421421

422-
``` php
422+
```php
423423
// Configure a token identifier that maps `USER_ID` to the
424424
// username column
425425
$identifier = [
@@ -507,7 +507,7 @@ page](url-checkers).
507507
After a user has been authenticated you may want to inspect or interact with the
508508
Authenticator that successfully authenticated the user:
509509

510-
``` php
510+
```php
511511
// In a controller action
512512
$service = $this->request->getAttribute('authentication');
513513

@@ -517,7 +517,7 @@ $authenticator = $service->getAuthenticationProvider();
517517

518518
You can also get the identifier that identified the user as well:
519519

520-
``` php
520+
```php
521521
// In a controller action
522522
$service = $this->request->getAttribute('authentication');
523523

@@ -532,7 +532,7 @@ you should remember that these authenticators will halt the request when
532532
authentication credentials are missing or invalid. This is necessary as these
533533
authenticators must send specific challenge headers in the response:
534534

535-
``` php
535+
```php
536536
use Authentication\AuthenticationService;
537537

538538
// Instantiate the service
@@ -573,7 +573,7 @@ authenticated. You can convert this exception into a redirect using the
573573
You can also pass the current request target URI as a query parameter
574574
using the `queryParam` option:
575575

576-
``` php
576+
```php
577577
// In the getAuthenticationService() method of your src/Application.php
578578

579579
$service = new AuthenticationService();
@@ -588,7 +588,7 @@ $service->setConfig([
588588
Then in your controller's login method you can use `getLoginRedirect()` to get
589589
the redirect target safely from the query string parameter:
590590

591-
``` php
591+
```php
592592
public function login()
593593
{
594594
$result = $this->Authentication->getResult();
@@ -614,7 +614,7 @@ authentication for your API, but sessions for your web interface. To support
614614
this flow you can return different authentication services based on the URL
615615
path, or any other request attribute:
616616

617-
``` php
617+
```php
618618
public function getAuthenticationService(
619619
ServerRequestInterface $request
620620
): AuthenticationServiceInterface {

docs/en/contents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contents
22

3-
### CakePHP Authentication
3+
## CakePHP Authentication
44

55
- [Quick Start](index)
66
- [Authenticators](authenticators)

docs/en/identifiers.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ that was extracted from the request by the authenticators. Identifiers
55
can take options in the `loadIdentifier` method. A holistic example of
66
using the Password Identifier looks like:
77

8-
``` php
8+
```php
99
$identifier = [
1010
'Authentication.Password' => [
1111
'fields' => [
@@ -119,7 +119,7 @@ Configuration options:
119119

120120
Callback identifiers can either return `null|ArrayAccess` for simple results, or an `Authentication\Authenticator\Result` if you want to forward error messages:
121121

122-
``` php
122+
```php
123123
// A simple callback identifier
124124
$identifier = [
125125
'Authentication.Callback' => [
@@ -186,7 +186,7 @@ reside under `App\Identifier\Resolver` namespace.
186186

187187
Resolver can be configured using `resolver` config option:
188188

189-
``` php
189+
```php
190190
$identifier = [
191191
'Authentication.Password' => [
192192
'resolver' => [
@@ -201,15 +201,15 @@ $identifier = [
201201

202202
Or injected using a setter:
203203

204-
``` php
204+
```php
205205
$resolver = new \App\Identifier\Resolver\CustomResolver();
206206
$identifier = $service->loadIdentifier('Authentication.Password');
207207
$identifier->setResolver($resolver);
208208
```
209209

210210
As of 3.3.0, you should pass the constructed resolver into the identifier:
211211

212-
``` php
212+
```php
213213
$resolver = new \App\Identifier\Resolver\CustomResolver();
214214
$identifier = [
215215
'Authentication.Password' => [

docs/en/identity-object.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ called to get the primary id value of the current log in identity.
77
The reason this object exists is to provide an interface that makes it
88
implementations/sources:
99

10-
``` php
10+
```php
1111
// Service
1212
$authenticationService
1313
->getIdentity()
@@ -28,7 +28,7 @@ The identity object provides ArrayAccess but as well a `get()` method to
2828
access data. It is strongly recommended to use the `get()` method over array
2929
access because the get method is aware of the field mapping:
3030

31-
``` php
31+
```php
3232
$identity->get('email');
3333
$identity->get('username');
3434
```
@@ -38,7 +38,7 @@ The `get()` method can also be type-hinted via IDE meta file, e.g. through
3838

3939
If you want, you can use property access, however:
4040

41-
``` text
41+
```text
4242
$identity->email;
4343
$identity->username;
4444
```
@@ -48,7 +48,7 @@ is pretty useful if the identifier of the identity is a non-conventional
4848
`id` field or if you want to map other fields to more generic and
4949
common names:
5050

51-
``` php
51+
```php
5252
$identity = new Identity($data, [
5353
'fieldMap' => [
5454
'id' => 'uid',
@@ -69,7 +69,7 @@ create your own identity object, your object must implement the
6969
If you’d like to continue using your existing User class with this
7070
plugin you can implement the `Authentication\IdentityInterface`:
7171

72-
``` php
72+
```php
7373
namespace App\Model\Entity;
7474

7575
use Authentication\IdentityInterface;
@@ -103,7 +103,7 @@ If your identifiers cannot have their resulting objects modified to
103103
implement the `IdentityInterface` you can implement a custom decorator
104104
that implements the required interface:
105105

106-
``` php
106+
```php
107107
// You can use a callable...
108108
$identityResolver = function ($data) {
109109
return new MyCustomIdentity($data);

docs/en/impersonation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To impersonate another user you can use the `impersonate()` method on the
1414
`AuthenticationComponent`. To impersonate a user you first need to load that
1515
user from your application's database:
1616

17-
``` php
17+
```php
1818
// In a controller
1919
public function impersonate()
2020
{
@@ -48,7 +48,7 @@ Once you have started to impersonate a user, all subsequent requests will have
4848
Once you are done impersonating a user, you can then end impersonation and revert
4949
back to your previous identity using `AuthenticationComponent`:
5050

51-
``` php
51+
```php
5252
// In a controller
5353
public function revertIdentity()
5454
{
@@ -66,6 +66,6 @@ public function revertIdentity()
6666

6767
There are a few limitations to impersonation.
6868

69-
1. Your application must be using the `Session` authenticator.
70-
2. You cannot impersonate another user while impersonation is active. Instead
69+
1. Your application must be using the `Session` authenticator.
70+
2. You cannot impersonate another user while impersonation is active. Instead
7171
you must `stopImpersonation()` and then start it again.

0 commit comments

Comments
 (0)