Skip to content

Commit

Permalink
Fixes problem with signing url with expiration time. It won't be part…
Browse files Browse the repository at this point in the history
… of signature
  • Loading branch information
butschster committed Jun 23, 2022
1 parent 3644416 commit af1865c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function signedUrl(

return $uri->withQuery(\http_build_query(
\array_merge($parameters, [
'signature' => $this->signature->generate($this->prepareUri($uri)),
'signature' => $this->signature->generate($this->prepareUri($uri->withQuery(\http_build_query($parameters))))
])
));
}
Expand Down
7 changes: 5 additions & 2 deletions tests/src/UrlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function testSignUrlWithExpiration(): void
{
$expiration = new \DateTime('2011-01-01T15:03:01.012345Z');

$this->signature->shouldReceive('generate')->once()->with('/category/1?bar=baz')
$this->signature->shouldReceive('generate')->once()
->with('/category/1?bar=baz&expires='.$expiration->getTimestamp())
->andReturn('hashed_string');

$uri = $this->generator->signedUrl(new Uri('http://site.com/category/1?bar=baz'), $expiration);
Expand Down Expand Up @@ -77,7 +78,9 @@ public function testSignedRouteWithExpiration(): void
->with('foo', ['bar' => 'baz', 'zoo' => 'zaz'])
->andReturn(new Uri('http://site.com/category/1?bar=baz'));

$this->signature->shouldReceive('generate')->once()->with('/category/1?bar=baz')
$this->signature->shouldReceive('generate')
->once()
->with('/category/1?bar=baz&expires='.$expiration->getTimestamp())
->andReturn('hashed_string');

$uri = $this->generator->signedRoute('foo', ['zoo' => 'zaz', 'bar' => 'baz'], $expiration);
Expand Down

0 comments on commit af1865c

Please sign in to comment.