@@ -2763,6 +2763,11 @@ service, which you can inject in your services or controllers::
2763
2763
}
2764
2764
}
2765
2765
2766
+ .. versionadded :: 7.3
2767
+
2768
+ Signed URI hashes no longer include the ``/ `` or ``+ `` characters, as these
2769
+ may cause issues with certain clients, since Symfony 7.3.
2770
+
2766
2771
For security reasons, it's common to make signed URIs expire after some time
2767
2772
(e.g. when using them to reset user credentials). By default, signed URIs don't
2768
2773
expire, but you can define an expiration date/time using the ``$expiration ``
@@ -2810,10 +2815,30 @@ argument of :method:`Symfony\\Component\\HttpFoundation\\UriSigner::sign`::
2810
2815
2811
2816
The feature to add an expiration date for a signed URI was introduced in Symfony 7.1.
2812
2817
2818
+ If you need to know the reason why a signed URI is invalid, you can use the
2819
+ ``verify() `` method which throws exceptions on failure::
2820
+
2821
+ use Symfony\Component\HttpFoundation\Exception\ExpiredSignedUriException;
2822
+ use Symfony\Component\HttpFoundation\Exception\UnsignedUriException;
2823
+ use Symfony\Component\HttpFoundation\Exception\UnverifiedSignedUriException;
2824
+
2825
+ // ...
2826
+
2827
+ try {
2828
+ $uriSigner->verify($uri); // $uri can be a string or Request object
2829
+
2830
+ // the URI is valid
2831
+ } catch (UnsignedUriException) {
2832
+ // the URI isn't signed
2833
+ } catch (UnverifiedSignedUriException) {
2834
+ // the URI is signed but the signature is invalid
2835
+ } catch (ExpiredSignedUriException) {
2836
+ // the URI is signed but expired
2837
+ }
2838
+
2813
2839
.. versionadded :: 7.3
2814
2840
2815
- Starting with Symfony 7.3, signed URI hashes no longer include the ``/ `` or
2816
- ``+ `` characters, as these may cause issues with certain clients.
2841
+ The ``verify() `` method was introduced in Symfony 7.3.
2817
2842
2818
2843
Troubleshooting
2819
2844
---------------
0 commit comments