File tree 2 files changed +30
-2
lines changed
src/Symfony/Component/Security/Http
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,12 @@ public function consumeLoginLink(Request $request): UserInterface
97
97
throw new InvalidLoginLinkException ('User not found. ' , 0 , $ exception );
98
98
}
99
99
100
- $ hash = $ request ->get ('hash ' );
101
- $ expires = $ request ->get ('expires ' );
100
+ if (!$ hash = $ request ->get ('hash ' )) {
101
+ throw new InvalidLoginLinkException ('Missing "hash" parameter. ' );
102
+ }
103
+ if (!$ expires = $ request ->get ('expires ' )) {
104
+ throw new InvalidLoginLinkException ('Missing "expires" parameter. ' );
105
+ }
102
106
103
107
try {
104
108
$ this ->signatureHasher ->verifySignatureHash ($ user , $ expires , $ hash );
Original file line number Diff line number Diff line change @@ -182,6 +182,30 @@ public function testConsumeLoginLinkExceedsMaxUsage()
182
182
$ linker ->consumeLoginLink ($ request );
183
183
}
184
184
185
+ public function testConsumeLoginLinkWithMissingHash ()
186
+ {
187
+ $ user = new TestLoginLinkHandlerUser ('weaverryan ' , 'ryan@symfonycasts.com ' , 'pwhash ' );
188
+ $ this ->userProvider ->createUser ($ user );
189
+
190
+ $ this ->expectException (InvalidLoginLinkException::class);
191
+ $ request = Request::create ('/login/verify?user=weaverryan&expires=10000 ' );
192
+
193
+ $ linker = $ this ->createLinker ();
194
+ $ linker ->consumeLoginLink ($ request );
195
+ }
196
+
197
+ public function testConsumeLoginLinkWithMissingExpiration ()
198
+ {
199
+ $ user = new TestLoginLinkHandlerUser ('weaverryan ' , 'ryan@symfonycasts.com ' , 'pwhash ' );
200
+ $ this ->userProvider ->createUser ($ user );
201
+
202
+ $ this ->expectException (InvalidLoginLinkException::class);
203
+ $ request = Request::create ('/login/verify?user=weaverryan&hash=thehash ' );
204
+
205
+ $ linker = $ this ->createLinker ();
206
+ $ linker ->consumeLoginLink ($ request );
207
+ }
208
+
185
209
private function createSignatureHash (string $ username , int $ expires , array $ extraFields ): string
186
210
{
187
211
$ fields = [base64_encode ($ username ), $ expires ];
You can’t perform that action at this time.
0 commit comments