Merge branch '5.2' into 5.x

* 5.2:
  [SecurityBundle] add missing type-hint
  [SecurityBundle] Remove invalid unused service
  [Security] [DataCollector] Remove allows anonymous information in datacollector
  [Workflow] Remove dead call to `Defnition#addTag()`
  add chinese translation
This commit is contained in:
Nicolas Grekas 2021-05-19 12:09:36 +02:00
commit 5ad6f6934b
9 changed files with 35 additions and 15 deletions

View File

@ -832,10 +832,6 @@ class FrameworkExtension extends Extension
$definitionDefinition->addArgument($transitions);
$definitionDefinition->addArgument($initialMarking);
$definitionDefinition->addArgument(new Reference(sprintf('%s.metadata_store', $workflowId)));
$definitionDefinition->addTag('workflow.definition', [
'name' => $name,
'type' => $type,
]);
// Create MarkingStore
if (isset($workflow['marking_store']['type'])) {

View File

@ -44,8 +44,9 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
private $firewallMap;
private $firewall;
private $hasVarDumper;
private $authenticatorManagerEnabled;
public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null)
public function __construct(TokenStorageInterface $tokenStorage = null, RoleHierarchyInterface $roleHierarchy = null, LogoutUrlGenerator $logoutUrlGenerator = null, AccessDecisionManagerInterface $accessDecisionManager = null, FirewallMapInterface $firewallMap = null, TraceableFirewallListener $firewall = null, bool $authenticatorManagerEnabled = false)
{
$this->tokenStorage = $tokenStorage;
$this->roleHierarchy = $roleHierarchy;
@ -54,6 +55,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
$this->firewallMap = $firewallMap;
$this->firewall = $firewall;
$this->hasVarDumper = class_exists(ClassStub::class);
$this->authenticatorManagerEnabled = $authenticatorManagerEnabled;
}
/**
@ -207,6 +209,8 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
if ($this->firewall) {
$this->data['listeners'] = $this->firewall->getWrappedListeners();
}
$this->data['authenticator_manager_enabled'] = $this->authenticatorManagerEnabled;
}
/**
@ -392,4 +396,9 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
{
return 'security';
}
public function isAuthenticatorManagerEnabled(): bool
{
return $this->data['authenticator_manager_enabled'];
}
}

View File

@ -142,6 +142,8 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
$loader->load('collectors.php');
$loader->load('guard.php');
$container->getDefinition('data_collector.security')->addArgument($this->authenticatorManagerEnabled);
if ($container->hasParameter('kernel.debug') && $container->getParameter('kernel.debug')) {
$loader->load('security_debug.php');
}

View File

@ -66,13 +66,5 @@ return static function (ContainerConfigurator $container) {
service('request_stack'),
])
->alias(LoginLinkHandlerInterface::class, 'security.authenticator.firewall_aware_login_link_handler')
->set('security.authenticator.entity_login_link_user_handler', EntityLoginLinkUserHandler::class)
->abstract()
->args([
service('doctrine'),
abstract_arg('user entity class name'),
])
->deprecate('symfony/security-bundle', '5.3', 'The "%service_id%" service is deprecated, use the new authenticator system instead.')
;
};

View File

@ -159,10 +159,12 @@
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.stateless ? 'yes' : 'no') ~ '.svg') }}</span>
<span class="label">Stateless</span>
</div>
{% if collector.authenticatorManagerEnabled == false %}
<div class="metric">
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.allows_anonymous ? 'yes' : 'no') ~ '.svg') }}</span>
<span class="label">Allows anonymous</span>
</div>
{% endif %}
</div>
{% if collector.firewall.security_enabled %}

View File

@ -71,6 +71,7 @@ class SecurityDataCollectorTest extends TestCase
$this->assertCount(0, $collector->getInheritedRoles());
$this->assertEmpty($collector->getUser());
$this->assertNull($collector->getFirewall());
$this->assertFalse($collector->isAuthenticatorManagerEnabled());
}
/** @dataProvider provideRoles */
@ -93,6 +94,7 @@ class SecurityDataCollectorTest extends TestCase
$this->assertSame($normalizedRoles, $collector->getRoles()->getValue(true));
$this->assertSame($inheritedRoles, $collector->getInheritedRoles()->getValue(true));
$this->assertSame('hhamon', $collector->getUser());
$this->assertFalse($collector->isAuthenticatorManagerEnabled());
}
public function testCollectSwitchUserToken()
@ -132,7 +134,7 @@ class SecurityDataCollectorTest extends TestCase
->with($request)
->willReturn($firewallConfig);
$collector = new SecurityDataCollector(null, null, null, null, $firewallMap, new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator()));
$collector = new SecurityDataCollector(null, null, null, null, $firewallMap, new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator()), true);
$collector->collect($request, new Response());
$collector->lateCollect();
$collected = $collector->getFirewall();
@ -149,6 +151,7 @@ class SecurityDataCollectorTest extends TestCase
$this->assertSame($firewallConfig->getAccessDeniedUrl(), $collected['access_denied_url']);
$this->assertSame($firewallConfig->getUserChecker(), $collected['user_checker']);
$this->assertSame($firewallConfig->getListeners(), $collected['listeners']->getValue());
$this->assertTrue($collector->isAuthenticatorManagerEnabled());
}
public function testGetFirewallReturnsNull()

View File

@ -70,6 +70,14 @@
<source>Invalid or expired login link.</source>
<target>失效或过期的登入链接。</target>
</trans-unit>
<trans-unit id="19">
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
<target>登入失败的次数过多,请在%minutes%分钟后再试。</target>
</trans-unit>
<trans-unit id="20">
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
<target>登入失败的次数过多,请在%minutes%分钟后再试。</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -70,6 +70,14 @@
<source>Invalid or expired login link.</source>
<target>失效或過期的登入鏈接。</target>
</trans-unit>
<trans-unit id="19">
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
<target>登錄失敗的次數過多,請在%minutes%分鐘後再試。</target>
</trans-unit>
<trans-unit id="20">
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
<target>登錄失敗的次數過多,請在%minutes%分鐘後再試。</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -17,7 +17,7 @@ namespace Symfony\Component\Security\Http\Authenticator;
*
* Interactive login requires explicit user action (e.g. a login
* form or HTTP basic authentication). Implementing this interface
* will dispatcher the InteractiveLoginEvent upon successful login.
* will dispatch the InteractiveLoginEvent upon successful login.
*
* @author Wouter de Jong <wouter@wouterj.nl>
*/