mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-16 18:01:38 +00:00
Protect share with a CSRF token
This commit is contained in:
parent
eb8408b22f
commit
0d8429dfc7
4 changed files with 19 additions and 7 deletions
|
@ -543,12 +543,16 @@ class EntryController extends AbstractController
|
|||
/**
|
||||
* Get public URL for entry (and generate it if necessary).
|
||||
*
|
||||
* @Route("/share/{id}", requirements={"id" = "\d+"}, name="share")
|
||||
* @Route("/share/{id}", name="share", methods={"POST"}, requirements={"id" = "\d+"})
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function shareAction(Entry $entry)
|
||||
public function shareAction(Request $request, Entry $entry)
|
||||
{
|
||||
if (!$this->isCsrfTokenValid('share-entry', $request->request->get('token'))) {
|
||||
throw new BadRequestHttpException('Bad CSRF token.');
|
||||
}
|
||||
|
||||
$this->checkUserAction($entry);
|
||||
|
||||
if (null === $entry->getUid()) {
|
||||
|
@ -587,7 +591,7 @@ class EntryController extends AbstractController
|
|||
/**
|
||||
* Ability to view a content publicly.
|
||||
*
|
||||
* @Route("/share/{uid}", requirements={"uid" = ".+"}, name="share_entry")
|
||||
* @Route("/share/{uid}", name="share_entry", methods={"GET"}, requirements={"uid" = ".+"})
|
||||
* @Cache(maxage="25200", smaxage="25200", public=true)
|
||||
*
|
||||
* @return Response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue