Crawler API now checks token.
This commit is contained in:
parent
f9f1072bbd
commit
b5007fceec
|
@ -22,3 +22,6 @@ parameters:
|
|||
|
||||
# A secret key that's used to generate certain security-related tokens
|
||||
secret: ThisTokenIsNotSoSecretChangeIt
|
||||
|
||||
# Token for Go crawler https://bitbucket.org/skobkin/point-tools-crawler
|
||||
crawler_token: test_token
|
|
@ -4,12 +4,19 @@ namespace Skobkin\Bundle\PointToolsBundle\Controller\Api;
|
|||
|
||||
use Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CrawlerController extends AbstractApiController
|
||||
{
|
||||
public function receiveAllPageAction(Request $request)
|
||||
{
|
||||
$token = $request->request->get('token');
|
||||
$remoteToken = $request->request->get('token');
|
||||
$localToken = $this->getParameter('crawler_token');
|
||||
|
||||
if (!$localToken || ($localToken !== $remoteToken)) {
|
||||
return $this->createErrorResponse('Token error. Please check it in crawler and API parameters.', Response::HTTP_FORBIDDEN);
|
||||
}
|
||||
|
||||
$json = $request->request->get('json');
|
||||
|
||||
$serializer = $this->get('jms_serializer');
|
||||
|
|
Loading…
Reference in a new issue