Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7f8277e
Remove deprecations, fix up MultiChecker.
dereuromark Nov 6, 2025
1db4473
Remove deprecations, fix up MultiChecker.
dereuromark Nov 6, 2025
24acd57
Fix up docs.
dereuromark Nov 6, 2025
5b62daf
Fix up docs.
dereuromark Nov 6, 2025
242b12a
Fix up identifier defaulting.
dereuromark Nov 6, 2025
f6dab98
Update src/Authenticator/EnvironmentAuthenticator.php
dereuromark Nov 6, 2025
6480113
Update src/Authenticator/JwtAuthenticator.php
dereuromark Nov 6, 2025
d5ee52b
Update src/Authenticator/TokenAuthenticator.php
dereuromark Nov 6, 2025
4325675
Fix up Url Checker defaulting.
Nov 7, 2025
2ba7ed9
Merge branch '3.x' into 4.x
dereuromark Nov 29, 2025
5105cdd
Apply suggestions from code review
dereuromark Nov 29, 2025
2ac8fd5
Fix syntax.
dereuromark Nov 29, 2025
f4f9a63
Fix up for cake only use. (#756)
dereuromark Dec 13, 2025
e46b456
Merge branch '3.x' into 4.x
dereuromark Jan 3, 2026
85076bf
Update version references from 3 to 4
dereuromark Jan 11, 2026
d172a6f
Merge branch '3.x' into 4.x
ADmad Jan 13, 2026
740b68d
Bump up firebase/php-jwt to ^7.0 (#760)
ADmad Jan 13, 2026
680525a
Update docs (#761)
ADmad Jan 13, 2026
1efa12b
Drop deprecated Plugin.php for 4.x (#762)
josbeir Jan 13, 2026
7aa5be8
Update readme
ADmad Jan 13, 2026
cfc37d6
Add default TokenIdentifier for PrimaryKeySessionAuthenticator
dereuromark Jan 14, 2026
a7fc297
Fix code style - use import instead of FQCN
dereuromark Jan 14, 2026
ef15407
Update docs for PrimaryKeySession default identifier
dereuromark Jan 21, 2026
1c8bd69
Merge pull request #764 from cakephp/feature/primary-key-session-defa…
markstory Jan 27, 2026
f49d9ba
Allow using dot separated field names for Identity::get()
ADmad Jan 29, 2026
462ff6a
Add IdentityHelper::getIdentity()
ADmad Jan 30, 2026
19df42a
Update docblock
ADmad Jan 30, 2026
d3ab4fe
Update docblock
ADmad Jan 30, 2026
50e6f78
Use the _identity property
ADmad Jan 30, 2026
cbc12d3
Initial plan
Copilot Jan 30, 2026
c52efc2
Add test for getIdentity() returning null without identity
Copilot Jan 30, 2026
79c784a
Merge pull request #768 from cakephp/copilot/sub-pr-767
ADmad Jan 30, 2026
95215e4
Merge pull request #766 from cakephp/identity-get
markstory Feb 1, 2026
e559c80
Merge pull request #767 from cakephp/identity-helper
markstory Feb 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"issues": "https://github.com/cakephp/authentication/issues",
"forum": "https://discourse.cakephp.org/",
"source": "https://github.com/cakephp/authentication",
"docs": "https://book.cakephp.org/authentication/3/en/"
"docs": "https://book.cakephp.org/authentication/4/en/"
},
"require": {
"php": ">=8.1",
"cakephp/http": "^5.0",
"cakephp/utility": "^5.0",
"laminas/laminas-diactoros": "^3.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
Expand All @@ -34,7 +35,7 @@
"require-dev": {
"cakephp/cakephp": "^5.1.0",
"cakephp/cakephp-codesniffer": "^5.0",
"firebase/php-jwt": "^6.2",
"firebase/php-jwt": "^7.0",
"phpunit/phpunit": "^10.5.58 || ^11.5.3 || ^12.4"
},
"suggest": {
Expand Down
35 changes: 23 additions & 12 deletions docs/en/authenticators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,34 @@ It also helps to avoid session invalidation.
Session itself stores the entity object including nested objects like DateTime or enums.
With only the ID stored, the invalidation due to objects being modified will also dissolve.

Make sure to match this with a Token identifier with ``key``/``id`` keys::
A default ``TokenIdentifier`` is provided that looks up users by their ``id`` field,
so minimal configuration is required::

$service->loadAuthenticator('Authentication.PrimaryKeySession');

Configuration options:

- **idField**: The field in the database table to look up. Default is ``id``.
- **identifierKey**: The key used to store/retrieve the primary key from session data.
Default is ``key``.

For custom lookup fields, the ``idField`` and ``identifierKey`` options propagate
to the default identifier automatically::

$service->loadAuthenticator('Authentication.PrimaryKeySession', [
'idField' => 'uuid',
]);

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

$service->loadAuthenticator('Authentication.PrimaryKeySession', [
'identifier' => [
'Authentication.Token' => [
'tokenField' => 'id', // lookup for resolver and DB table
'dataField' => 'key', // incoming data from authenticator
'tokenField' => 'id',
'dataField' => 'key',
'resolver' => 'Authentication.Orm',
],
],
'urlChecker' => 'Authentication.CakeRouter',
'loginUrl' => [
'prefix' => false,
'plugin' => false,
'controller' => 'Users',
'action' => 'login',
],
]);

Form
Expand Down Expand Up @@ -143,7 +154,7 @@ example.
If provided will be used instead of the secret key.

You need to add the lib `firebase/php-jwt <https://github.com/firebase/php-jwt>`_
v6.2 or above to your app to use the ``JwtAuthenticator``.
v7.0 or above to your app to use the ``JwtAuthenticator``.

By default the ``JwtAuthenticator`` uses ``HS256`` symmetric key algorithm and uses
the value of ``Cake\Utility\Security::salt()`` as encryption key.
Expand Down Expand Up @@ -430,7 +441,7 @@ There is only one event that is fired by authentication:
``Authentication.afterIdentify``.

If you don’t know what events are and how to use them `check the
documentation <https://book.cakephp.org/4/en/core-libraries/events.html>`__.
documentation <https://book.cakephp.org/5/en/core-libraries/events.html>`__.

The ``Authentication.afterIdentify`` event is fired by the
``AuthenticationComponent`` after an identity was successfully
Expand Down
2 changes: 1 addition & 1 deletion docs/en/identifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Configuration options:
- **userModel**: The user model identities are located in. Default is
``Users``.
- **finder**: The finder to use with the model. Default is ``all``.
You can read more about model finders `here <https://book.cakephp.org/4/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods>`__.
You can read more about model finders `here <https://book.cakephp.org/5/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods>`__.

In order to use ORM resolver you must require ``cakephp/orm`` in your
``composer.json`` file (if you are not already using the full CakePHP framework).
Expand Down
14 changes: 5 additions & 9 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ Project's ROOT directory (where the **composer.json** file is located)

php composer.phar require cakephp/authentication

Version 3 of the Authentication Plugin is compatible with CakePHP 5.
Version 4 of the Authentication Plugin is compatible with CakePHP 5.

Load the plugin by adding the following statement in your project's ``src/Application.php``::
Load the plugin using the following command::

public function bootstrap(): void
{
parent::bootstrap();

$this->addPlugin('Authentication');
}
.. code-block:: shell

bin/cake plugin load Authentication

Getting Started
===============

The authentication plugin integrates with your application as a `middleware <https://book.cakephp.org/4/en/controllers/middleware.html>`_. It can also
The authentication plugin integrates with your application as a `middleware <https://book.cakephp.org/5/en/controllers/middleware.html>`_. It can also
be used as a component to make unauthenticated access simpler. First, let's
apply the middleware. In **src/Application.php**, add the following to the class
imports::
Expand Down
Loading
Loading