-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[HttpFoundation] Add UriSigner::verify()
that throws named exceptions
#60102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
UriSigner::signAndWrap(): SignedUri
and UriSigner::verify(): SignedUri
UriSigner::signAndWrap(): SignedUri
and UriSigner::verify(): SignedUri
UriSigner::signAndWrap(): SignedUri
and UriSigner::verify(): SignedUri
UriSigner::signAndWrap(): SignedUri
and UriSigner::verify(): SignedUri
UriSigner::signAndWrap(): SignedUri
and UriSigner::verify(): SignedUri
UriSigner::signAndWrap()
and UriSigner::verify()
I'm not a huge fan of |
ee8c09d
to
a627d43
Compare
UriSigner::signAndWrap()
and UriSigner::verify()
UriSigner::verify()
that throws named exceptions
I've updated this PR to just add |
src/Symfony/Component/HttpFoundation/Exception/UnverifiedSignedUriException.php
Show resolved
Hide resolved
src/Symfony/Component/HttpFoundation/Exception/UnSignedUriException.php
Outdated
Show resolved
Hide resolved
9a617d0
to
0a35de0
Compare
(rebase needed) |
493f298
to
60b8ba7
Compare
src/Symfony/Component/HttpFoundation/Exception/SignedUriException.php
Outdated
Show resolved
Hide resolved
ce0feb3
to
ac4de2c
Compare
Thank you @kbond. |
@kbond littel bit curious why are we not throwing a HttpException here? I must say as signed uris are verified in controllers 99% from requests I would expect a HttpException by default something like (400 or 403). As we are here in the http foundation component. |
The purpose of this feature is to distinguish between the different reasons for a signed url validation error. For example, you can redirect and add a flash message explaining the problem. Named exceptions felt the best. I get I could have used HTTP exceptions but wanted the user to be able to customize the response code. 60395 adds default http status codes but these can still be customized if desired. Also, in the future, we can add additional details to these exceptions if desired - like "when it expired" on |
@kbond I see your case. I definitly totally +1 for the own named exception here, I would have just extend from the HttpException with default status code of 403. As for me was a little bit unexpected to have per default for verify a server error (500) instead of a client error for a false signed URL. But looks like https://github.com/symfony/symfony/pull/60395/files#diff-d2b702ce5099ca6ea0823843d11127e01f37b33c5eeafb4463b8a2f5d4dbebbc catches this and convert them to a client error, so fine with that. Really thank you for your fast response. |
This adds
UriSigner::verify()
: Similar tocheck()
but throwsUnSignedUriException
,UnverifiedSignedUriException
orExpiredSignedUriException
if invalid (no return if valid).Usage example:
TODO