Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Add temporary URI signed#51502
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[HttpKernel] Add temporary URI signed#51502
Uh oh!
There was an error while loading.Please reload this page.
Conversation
95835c6 to9f88d63CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
9f88d63 to1084142CompareBaptisteContreras commentedAug 29, 2023
PR updated :) |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
OskarStark commentedOct 10, 2023
Can you please rebase? Thanks |
1084142 to76e4625Compare910ee02 to4614ba2Compare
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM with some comments thanks
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| privatefunctionisExpired(int$expiration):bool | ||
| { | ||
| returntime() >=$expiration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Maybe using Clock component optionally would be better with fallback, to allow using mock clock in tests for devs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It will create a dependency between HttpFoundation and the Clock component. How would you do it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Require-dev? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Mmmh I see, and in thecheck method I should get the current time like that ?
if (class_exists(\Symfony\Component\Clock\Clock::class)) {$time = \Symfony\Component\Clock\Clock::get()->now()->format('U'); }else {$time =time(); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Probably. Or via DI, not sure what maintainers would prefer
nicolas-grekasNov 23, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I wouldn't use the Clock component in this PR. Let's use time() for now and discuss for Clock applied to HttpFoundation separately
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fb3fb80 tob2bec43Compareb2bec43 to391443cCompareBaptisteContreras commentedFeb 23, 2024
@nicolas-grekas if this PR is OK for you, can we have this in 7.1 ? |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedMar 17, 2024
@BaptisteContreras Are you still interested in finishing this PR? |
BaptisteContreras commentedMar 17, 2024
@fabpot , yes ! I'm on it :) |
391443c toc1156a2Comparec1156a2 to59ca1ebCompare59ca1eb tof0c2cfbComparesrc/Symfony/Component/HttpFoundation/Exception/ExceptionInterface.php.orig OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Exception/ExceptionInterface.php.rej OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Exception/LogicException.php.orig OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpFoundation/Exception/LogicException.php.rej OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedMar 17, 2024
Thank you@BaptisteContreras. |
| * The expiration is added as a query string parameter. | ||
| */ | ||
| publicfunctionsign(string$uri):string | ||
| publicfunctionsign(string$uri,\DateTimeInterface|\DateInterval|int|null$expiration =null):string |
nicolas-grekasMar 25, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I missed that this is a BC break. Instead, we should comment the argument on the signature and read it with func_get_arg (see on 6.4 for similar new arguments).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is it a BC even if the default value does not change the old behavior of the method ?
Do you want another PR linked to a new issue to fix this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It's a BC break for classes that extend this class. Yes, it'd be great to fix it, PR welcome :)
…8.0 (xabbuh)This PR was merged into the 7.1 branch.Discussion----------[HttpFoundation] defer addition of new method argument to 8.0| Q | A| ------------- | ---| Branch? | 7.1| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fix#51502 (comment)| License | MITCommits-------8fadaca defer addition of new method argument to 8.0
Uh oh!
There was an error while loading.Please reload this page.
This feature add the possibilty to create a temporary URI signed as mentionned in#51501.
Few things about this implementation :
UriSigner. I'm not sure if it can be considered as aBC ?a LogicalException. In fact, the
checkmethod will test the presence of the expiration query parameter to determine if it must (or not) verify the expiration.A problem can arise in this case : Lets say you want to sign this URI : "/demo?_expiration=foo" and you don't want a temporary URL. The URI is signed without problem but when you try to call
check, the method will notice thepresence of "_expiration" and try to determine if it has expired, considering the value "foo" as a timestamp.