@@ -37,23 +37,34 @@ It also helps to avoid session invalidation.
3737Session itself stores the entity object including nested objects like DateTime or enums.
3838With only the ID stored, the invalidation due to objects being modified will also dissolve.
3939
40- Make sure to match this with a Token identifier with ``key ``/``id `` keys::
40+ A default ``TokenIdentifier `` is provided that looks up users by their ``id `` field,
41+ so minimal configuration is required::
42+
43+ $service->loadAuthenticator('Authentication.PrimaryKeySession');
44+
45+ Configuration options:
46+
47+ - **idField **: The field in the database table to look up. Default is ``id ``.
48+ - **identifierKey **: The key used to store/retrieve the primary key from session data.
49+ Default is ``key ``.
50+
51+ For custom lookup fields, the ``idField `` and ``identifierKey `` options propagate
52+ to the default identifier automatically::
53+
54+ $service->loadAuthenticator('Authentication.PrimaryKeySession', [
55+ 'idField' => 'uuid',
56+ ]);
57+
58+ You can also provide a fully custom identifier configuration if needed::
4159
4260 $service->loadAuthenticator('Authentication.PrimaryKeySession', [
4361 'identifier' => [
4462 'Authentication.Token' => [
45- 'tokenField' => 'id', // lookup for resolver and DB table
46- 'dataField' => 'key', // incoming data from authenticator
63+ 'tokenField' => 'id',
64+ 'dataField' => 'key',
4765 'resolver' => 'Authentication.Orm',
4866 ],
4967 ],
50- 'urlChecker' => 'Authentication.CakeRouter',
51- 'loginUrl' => [
52- 'prefix' => false,
53- 'plugin' => false,
54- 'controller' => 'Users',
55- 'action' => 'login',
56- ],
5768 ]);
5869
5970Form
0 commit comments