Skip to content

Commit

Permalink
Presenter: signal must be sent from the same origin unless they have …
Browse files Browse the repository at this point in the history
…annotation @crossorigin (BC break)

Experimental
  • Loading branch information
dg committed Feb 13, 2019
1 parent 86b92fe commit e6c5c4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Application/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ protected function tryCall(string $method, array $params): bool
*/
public function checkRequirements($element): void
{
if (
$element instanceof \ReflectionMethod
&& substr($element->getName(), 0, 6) === 'handle'
&& !ComponentReflection::parseAnnotation($element, 'crossOrigin')
&& !$this->getPresenter()->getHttpRequest()->isSameSite()
) {
throw new Nette\Application\ForbiddenRequestException('The signal was not sent from the same domain. It can be allowed using @crossOrigin annotation.');
}
}


Expand Down
1 change: 1 addition & 0 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ protected function shutdown(Application\IResponse $response)
*/
public function checkRequirements($element): void
{
parent::checkRequirements($element);
$user = (array) ComponentReflection::parseAnnotation($element, 'User');
if (in_array('loggedIn', $user, true)) {
trigger_error(__METHOD__ . '() annotation @User is deprecated', E_USER_DEPRECATED);
Expand Down

0 comments on commit e6c5c4f

Please sign in to comment.