Skip to content

Commit f28314f

Browse files
committed
Merge branch '3.x' into 3.next
2 parents ece8c84 + 6f4553e commit f28314f

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

.gitattributes

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
.editorconfig export-ignore
88
.gitattributes export-ignore
99
.gitignore export-ignore
10-
.stickler.yml export-ignore
1110
CONTRIBUTING.md export-ignore
1211
docs.Dockerfile export-ignore
1312
phpunit.xml export-ignore
1413
phpcs.xml export-ignore
1514
/.github export-ignore
1615
/tests export-ignore
16+
phpstan.neon export-ignore
17+
phpstan-baseline.neon export-ignore
18+
psalm.xml export-ignore
19+
psalm-baseline.xml export-ignore

.stickler.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/en/authenticators.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Token
6262

6363
The token authenticator can authenticate a request based on a token that
6464
comes along with the request in the headers or in the request
65-
parameters.
65+
parameters. This requires a token column in the Users table, so comparison can be made between the received token and stored token.
6666

6767
Configuration options:
6868

docs/en/impersonation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ user from your application's database::
3535

3636
// Enable impersonation.
3737
$this->Authentication->impersonate($targetUser);
38-
$this->redirect($this->referer());
38+
39+
return $this->redirect($this->referer());
3940
}
4041

4142
Once you have started to impersonate a user, all subsequent requests will have

src/Controller/Component/AuthenticationComponent.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ public function stopImpersonating()
445445
*/
446446
public function isImpersonating(): bool
447447
{
448+
if (!$this->getIdentity()) {
449+
return false;
450+
}
451+
448452
$service = $this->getImpersonationAuthenticationService();
449453
$controller = $this->getController();
450454

tests/TestCase/Controller/Component/AuthenticationComponentTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,17 @@ public function testIsImpersonating()
731731
$this->request->getSession()->write('AuthImpersonate', $impersonator);
732732
$this->service->authenticate($this->request);
733733
$request = $this->request
734-
->withAttribute('authentication', $this->service);
734+
->withAttribute('authentication', $this->service)
735+
->withAttribute('identity', new Identity($impersonated));
735736
$controller = new Controller($request, $this->response);
736737
$registry = new ComponentRegistry($controller);
737738
$component = new AuthenticationComponent($registry);
738739

739740
$result = $component->isImpersonating();
740741
$this->assertTrue($result);
742+
743+
$component->logout();
744+
$this->assertFalse($component->isImpersonating());
741745
}
742746

743747
/**
@@ -749,10 +753,13 @@ public function testGetImpersonationAuthenticationServiceFailure()
749753
{
750754
$service = $this->getMockBuilder(AuthenticationServiceInterface::class)->getMock();
751755

752-
$component = $this->createPartialMock(AuthenticationComponent::class, ['getAuthenticationService']);
753-
$component->expects($this->once())
754-
->method('getAuthenticationService')
755-
->willReturn($service);
756+
$user = new ArrayObject(['username' => 'mariano']);
757+
$request = $this->request
758+
->withAttribute('authentication', $service)
759+
->withAttribute('identity', new Identity($user));
760+
$controller = new Controller($request, $this->response);
761+
$registry = new ComponentRegistry($controller);
762+
$component = new AuthenticationComponent($registry);
756763

757764
$this->expectException(InvalidArgumentException::class);
758765
$classname = get_class($service);

0 commit comments

Comments
 (0)