Skip to content

Commit 751ed77

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: (24 commits) Fix Twig tests [Scheduler] Fix tests [TwigBridge] Add FormLayoutTestCase class Fix CS Allow sending scheduled messages through the slack API [TwigBridge] Add `AppVariable::getEnabledLocales()` to retrieve the enabled locales [RateLimiter] Add missing dependency [RateLimiter] Add SlidingWindowLimiter::reserve() [Messenger] Add WrappedExceptionsInterface for nested exceptions [Mime] Add `TemplatedEmail::locale()` to set the locale for the email rendering Fix CS [Messenger][Scheduler] Add AsCronTask & AsPeriodicTask attributes [Scheduler] Make debug:scheduler output more useful [Notifier] Tweak some phpdocs [FrameworkBundle] Change BrowserKitAssertionsTrait::getClient() to be protected Fix CS [FrameworkBundle] Allow BrowserKit relative URL redirect assert [Messenger] RejectRedeliveredMessageException should not be retried [Serializer] Make `ProblemNormalizer` give details about Messenger’s `ValidationFailedException` [WebProfilerBundle] Support `!` negation operator in url filter ...
2 parents 40af48a + 58534b6 commit 751ed77

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
---
1212

1313
* `UserValueResolver` no longer implements `ArgumentValueResolverInterface`
14+
* Deprecate calling the constructor of `DefaultLoginRateLimiter` with an empty secret
1415

1516
6.3
1617
---

Impersonate/ImpersonateUrlGenerator.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
1919

2020
/**
21-
* Provides generator functions for the impersonate url exit.
21+
* Provides generator functions for the impersonation urls.
2222
*
2323
* @author Amrouche Hamza <[email protected]>
2424
* @author Damien Fayet <[email protected]>
@@ -36,9 +36,14 @@ public function __construct(RequestStack $requestStack, FirewallMap $firewallMap
3636
$this->firewallMap = $firewallMap;
3737
}
3838

39+
public function generateImpersonationPath(string $identifier = null): string
40+
{
41+
return $this->buildPath(null, $identifier);
42+
}
43+
3944
public function generateExitPath(string $targetUri = null): string
4045
{
41-
return $this->buildExitPath($targetUri);
46+
return $this->buildPath($targetUri);
4247
}
4348

4449
public function generateExitUrl(string $targetUri = null): string
@@ -47,27 +52,31 @@ public function generateExitUrl(string $targetUri = null): string
4752
return '';
4853
}
4954

50-
return $request->getUriForPath($this->buildExitPath($targetUri));
55+
return $request->getUriForPath($this->buildPath($targetUri));
5156
}
5257

5358
private function isImpersonatedUser(): bool
5459
{
5560
return $this->tokenStorage->getToken() instanceof SwitchUserToken;
5661
}
5762

58-
private function buildExitPath(string $targetUri = null): string
63+
private function buildPath(string $targetUri = null, string $identifier = SwitchUserListener::EXIT_VALUE): string
5964
{
60-
if (null === ($request = $this->requestStack->getCurrentRequest()) || !$this->isImpersonatedUser()) {
65+
if (null === ($request = $this->requestStack->getCurrentRequest())) {
66+
return '';
67+
}
68+
69+
if (!$this->isImpersonatedUser() && SwitchUserListener::EXIT_VALUE == $identifier) {
6170
return '';
6271
}
6372

6473
if (null === $switchUserConfig = $this->firewallMap->getFirewallConfig($request)->getSwitchUser()) {
65-
throw new \LogicException('Unable to generate the impersonate exit URL without a firewall configured for the user switch.');
74+
throw new \LogicException('Unable to generate the impersonate URLs without a firewall configured for the user switch.');
6675
}
6776

6877
$targetUri ??= $request->getRequestUri();
6978

70-
$targetUri .= (parse_url($targetUri, \PHP_URL_QUERY) ? '&' : '?').http_build_query([$switchUserConfig['parameter'] => SwitchUserListener::EXIT_VALUE], '', '&');
79+
$targetUri .= (parse_url($targetUri, \PHP_URL_QUERY) ? '&' : '?').http_build_query([$switchUserConfig['parameter'] => $identifier], '', '&');
7180

7281
return $targetUri;
7382
}

0 commit comments

Comments
 (0)