Skip to content

Commit ff88904

Browse files
committed
feature #20905 [Routing] document UriSigner::verify() (kbond)
This PR was merged into the 7.3 branch. Discussion ---------- [Routing] document `UriSigner::verify()` Closes #20904 Commits ------- aa3b167 [Routing] document `UriSigner::verify()`
2 parents 7b77976 + aa3b167 commit ff88904

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Diff for: routing.rst

+22-2
Original file line numberDiff line numberDiff line change
@@ -2810,10 +2810,30 @@ argument of :method:`Symfony\\Component\\HttpFoundation\\UriSigner::sign`::
28102810

28112811
The feature to add an expiration date for a signed URI was introduced in Symfony 7.1.
28122812

2813+
If you need to know the reason why a signed URI is invalid, you can use the
2814+
``verify()`` method which throws exceptions on failure::
2815+
2816+
use Symfony\Component\HttpFoundation\Exception\ExpiredSignedUriException;
2817+
use Symfony\Component\HttpFoundation\Exception\UnsignedUriException;
2818+
use Symfony\Component\HttpFoundation\Exception\UnverifiedSignedUriException;
2819+
2820+
// ...
2821+
2822+
try {
2823+
$uriSigner->verify($uri); // $uri can be a string or Request object
2824+
2825+
// the URI is valid
2826+
} catch (UnsignedUriException) {
2827+
// the URI isn't signed
2828+
} catch (UnverifiedSignedUriException) {
2829+
// the URI is signed but the signature is invalid
2830+
} catch (ExpiredSignedUriException) {
2831+
// the URI is signed but expired
2832+
}
2833+
28132834
.. versionadded:: 7.3
28142835

2815-
Starting with Symfony 7.3, signed URI hashes no longer include the ``/`` or
2816-
``+`` characters, as these may cause issues with certain clients.
2836+
The ``verify()`` method was introduced in Symfony 7.3.
28172837

28182838
Troubleshooting
28192839
---------------

0 commit comments

Comments
 (0)