File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Tests/DependencyInjection Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -848,7 +848,10 @@ private function createHasher(array $config)
848
848
{
849
849
// a custom hasher service
850
850
if (isset ($ config ['id ' ])) {
851
- return new Reference ($ config ['id ' ]);
851
+ return $ config ['migrate_from ' ] ?? false ? [
852
+ 'instance ' => new Reference ($ config ['id ' ]),
853
+ 'migrate_from ' => $ config ['migrate_from ' ],
854
+ ] : new Reference ($ config ['id ' ]);
852
855
}
853
856
854
857
if ($ config ['migrate_from ' ] ?? false ) {
Original file line number Diff line number Diff line change @@ -881,6 +881,33 @@ public function testLegacyAuthorizationManagerSignature()
881
881
$ this ->assertEquals ('%security.access.always_authenticate_before_granting% ' , (string ) $ args [3 ]);
882
882
}
883
883
884
+ public function testCustomHasherWithMigrateFrom ()
885
+ {
886
+ $ container = $ this ->getRawContainer ();
887
+
888
+ $ container ->loadFromExtension ('security ' , [
889
+ 'enable_authenticator_manager ' => true ,
890
+ 'password_hashers ' => [
891
+ 'legacy ' => 'md5 ' ,
892
+ 'App\User ' => [
893
+ 'id ' => 'App\Security\CustomHasher ' ,
894
+ 'migrate_from ' => 'legacy ' ,
895
+ ],
896
+ ],
897
+ 'firewalls ' => ['main ' => ['http_basic ' => true ]],
898
+ ]);
899
+
900
+ $ container ->compile ();
901
+
902
+ $ hashersMap = $ container ->getDefinition ('security.password_hasher_factory ' )->getArgument (0 );
903
+
904
+ $ this ->assertArrayHasKey ('App\User ' , $ hashersMap );
905
+ $ this ->assertEquals ($ hashersMap ['App\User ' ], [
906
+ 'instance ' => new Reference ('App\Security\CustomHasher ' ),
907
+ 'migrate_from ' => ['legacy ' ],
908
+ ]);
909
+ }
910
+
884
911
protected function getRawContainer ()
885
912
{
886
913
$ container = new ContainerBuilder ();
You can’t perform that action at this time.
0 commit comments