2023-02-12 04:27:54 error: [InvalidArgumentException] The Authentication\Authenticator\CookieAuthenticator Provider must implement ImpersonationInterface in order to use impersonation. in …/vendor/cakephp/authentication/src/AuthenticationService.php on line 496
I’m having trouble to impersonate users when I change my Session Authenticator configuration. If I keep ‘identify’ as false, the error goes away. Is this functionality intended?
Thanks in advance.
The cookie authenticator intentionally doesn’t support impersonation, as this is supposed to be a session bound feature, meaning once the session expires, the impersonation should stop. The cookie authenticator does “extend” the session so to speak, which would extend the impersonation accordingly.
I haven’t used that feature yet, so I’m not sure whether what you’re seeing is expected. You may want to elaborate on the exact circumstances in which the error is happening, ie explain how one can reliably reproduce the problem, for example where exactly you do trigger impersonation, whether the error happens only when you log in, does it always happen on every request, does it happen only on requests where the session expires and the cookie authenticator logs you in again, etc…
Technically there should be no difference for the session authenticator between identify being true or false, except when something has changed in the data storage so that the identification fails, which is usually a rather rare circumstance.
I created a new Bitbucket project with the bare minimum to reproduce the problem.
Keeping the identify option to true will throw “The Authentication\Authenticator\CookieAuthenticator Provider must implement ImpersonationInterface in order to use impersonation”.
I can’t test it right now, but I’ve just noticed that you don’t map the username field for the session authenticator, which will likely cause it to always fail to identify the identity, as you’re using a non-default username column.