Skip to content

Commit 87b5489

Browse files
committed
Fix additional documentation issues (2nd pass)
- Remove CONFIG double slash (CONFIG . '/jwt.key' -> CONFIG . 'jwt.key') - Fix 'explicity' typo -> 'explicitly' - Remove trailing comma from nonce default value - Update route syntax to CakePHP 5 ({controller} instead of :controller) - Remove Session authenticator identifier config (Session doesn't use identifiers) - Remove outdated loadIdentifier() references (removed in 4.x) - Fix grammar: 'an user' -> 'a user' - Add return types to IdentityInterface method examples - Update IdentifierCollection reference to reflect 4.x architecture - Remove outdated ResponseInterface from docblock - Use named arguments for finder: find('byToken', token: $token) - Use string instead of array for request->is('post')
1 parent 8be769c commit 87b5489

File tree

5 files changed

+18
-31
lines changed

5 files changed

+18
-31
lines changed

docs/en/authenticators.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
182182
// ...
183183
$service->loadAuthenticator('Authentication.Jwt', [
184184
'identifier' => 'Authentication.JwtSubject',
185-
'secretKey' => file_get_contents(CONFIG . '/jwt.key'),
185+
'secretKey' => file_get_contents(CONFIG . 'jwt.key'),
186186
'algorithm' => 'RS256',
187187
'returnPayload' => false
188188
]);
@@ -200,7 +200,7 @@ public function login()
200200
{
201201
$result = $this->Authentication->getResult();
202202
if ($result->isValid()) {
203-
$privateKey = file_get_contents(CONFIG . '/jwt.key');
203+
$privateKey = file_get_contents(CONFIG . 'jwt.key');
204204
$user = $result->getData();
205205
$payload = [
206206
'iss' => 'myapp',
@@ -260,18 +260,19 @@ distribute it via a JWKS endpoint by configuring your app as follows:
260260
``` php
261261
// config/routes.php
262262
$builder->setExtensions('json');
263-
$builder->connect('/.well-known/:controller/*', [
263+
$builder->connect('/.well-known/{controller}', [
264264
'action' => 'index',
265265
], [
266-
'controller' => '(jwks)',
266+
'controller' => 'jwks',
267+
'pass' => [],
267268
]); // connect /.well-known/jwks.json to JwksController
268269

269270
// controller/JwksController.php
270271
use Firebase\JWT\JWT;
271272

272273
public function index()
273274
{
274-
$pubKey = file_get_contents(CONFIG . '/jwt.pem');
275+
$pubKey = file_get_contents(CONFIG . 'jwt.pem');
275276
$res = openssl_pkey_get_public($pubKey);
276277
$detail = openssl_pkey_get_details($res);
277278
$key = [
@@ -315,7 +316,7 @@ Configuration options:
315316

316317
- **realm**: Default is `null`
317318
- **qop**: Default is `auth`
318-
- **nonce**: Default is `uniqid(''),`
319+
- **nonce**: Default is `uniqid('')`
319320
- **opaque**: Default is `null`
320321

321322
## Cookie Authenticator aka "Remember Me"
@@ -371,7 +372,7 @@ Configuration options:
371372
The cookie authenticator can be added to a Form & Session based
372373
authentication system. Cookie authentication will automatically re-login users
373374
after their session expires for as long as the cookie is valid. If a user is
374-
explicity logged out via `AuthenticationComponent::logout()` the
375+
explicitly logged out via `AuthenticationComponent::logout()` the
375376
authentication cookie is **also destroyed**. An example configuration would be:
376377

377378
``` php

docs/en/identifiers.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Identifiers
22

3-
Identifiers will identify an user or service based on the information
4-
that was extracted from the request by the authenticators. Identifiers
5-
can take options in the `loadIdentifier` method. A holistic example of
3+
Identifiers will identify a user or service based on the information
4+
that was extracted from the request by the authenticators. A holistic example of
65
using the Password Identifier looks like:
76

87
``` php
@@ -199,15 +198,7 @@ $identifier = [
199198
];
200199
```
201200

202-
Or injected using a setter:
203-
204-
``` php
205-
$resolver = new \App\Identifier\Resolver\CustomResolver();
206-
$identifier = $service->loadIdentifier('Authentication.Password');
207-
$identifier->setResolver($resolver);
208-
```
209-
210-
As of 3.3.0, you should pass the constructed resolver into the identifier:
201+
Or pass the constructed resolver directly into the identifier configuration:
211202

212203
``` php
213204
$resolver = new \App\Identifier\Resolver\CustomResolver();

docs/en/identity-object.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ class User extends Entity implements IdentityInterface
8080
/**
8181
* Authentication\IdentityInterface method
8282
*/
83-
public function getIdentifier()
83+
public function getIdentifier(): array|string|int|null
8484
{
8585
return $this->id;
8686
}
8787

8888
/**
8989
* Authentication\IdentityInterface method
9090
*/
91-
public function getOriginalData()
91+
public function getOriginalData(): \ArrayAccess|array
9292
{
9393
return $this;
9494
}

docs/en/middleware.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
4848

4949
// Web authentication
5050
// Support sessions and form login.
51-
$service->loadAuthenticator('Authentication.Session', [
52-
'identifier' => 'Authentication.Password',
53-
]);
51+
$service->loadAuthenticator('Authentication.Session');
5452
$service->loadAuthenticator('Authentication.Form', [
5553
'identifier' => 'Authentication.Password',
5654
]);

docs/en/migration-from-the-authcomponent.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ authenticators.
3838

3939
- **Authenticators** take the incoming request and try to extract
4040
identification credentials from it. If credentials are found, they
41-
are passed to a collection of identifiers where the user is located.
42-
For that reason authenticators take an IdentifierCollection as first
43-
constructor argument.
41+
are passed to an identifier where the user is located.
4442
- **Identifiers** verify identification credentials against a storage
4543
system. eg. (ORM tables, LDAP etc) and return identified user data.
4644

@@ -84,10 +82,9 @@ class Application extends BaseApplication implements AuthenticationServiceProvid
8482
* Returns a service provider instance.
8583
*
8684
* @param \Psr\Http\Message\ServerRequestInterface $request Request
87-
* @param \Psr\Http\Message\ResponseInterface $response Response
8885
* @return \Authentication\AuthenticationServiceInterface
8986
*/
90-
public function getAuthenticationService(ServerRequestInterface $request) : AuthenticationServiceInterface
87+
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
9188
{
9289
$service = new AuthenticationService();
9390
// Configure the service. (see below for more details)
@@ -198,7 +195,7 @@ public function login()
198195
}
199196

200197
// display error if user submitted and authentication failed
201-
if ($this->request->is(['post'])) {
198+
if ($this->request->is('post')) {
202199
$this->Flash->error('Invalid username or password');
203200
}
204201
}
@@ -235,7 +232,7 @@ use `setIdentity()`:
235232

236233
``` php
237234
// Assume you need to read a user by access token
238-
$user = $this->Users->find('byToken', ['token' => $token])->first();
235+
$user = $this->Users->find('byToken', token: $token)->first();
239236

240237
// Persist the user into configured authenticators.
241238
$this->Authentication->setIdentity($user);

0 commit comments

Comments
 (0)