mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 23:43:12 +00:00
Replaced key variable with token
This commit is contained in:
@@ -31,10 +31,10 @@ class Permalink extends AbstractDelivery
|
|||||||
|
|
||||||
$that = $this;
|
$that = $this;
|
||||||
|
|
||||||
$deliverPermaview = function($sbas_id, $record_id, $key, $subdef, PhraseaApplication $app) {
|
$deliverPermaview = function($sbas_id, $record_id, $token, $subdef, PhraseaApplication $app) {
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
|
|
||||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
|
||||||
|
|
||||||
if (!$record instanceof \record_adapter) {
|
if (!$record instanceof \record_adapter) {
|
||||||
throw new \Exception_NotFound('bad luck');
|
throw new \Exception_NotFound('bad luck');
|
||||||
@@ -51,9 +51,9 @@ class Permalink extends AbstractDelivery
|
|||||||
return $app['twig']->render('overview.html.twig', $params);
|
return $app['twig']->render('overview.html.twig', $params);
|
||||||
};
|
};
|
||||||
|
|
||||||
$deliverPermalink = function(PhraseaApplication $app, $sbas_id, $record_id, $key, $subdef) use ($that) {
|
$deliverPermalink = function(PhraseaApplication $app, $sbas_id, $record_id, $token, $subdef) use ($that) {
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
|
||||||
|
|
||||||
if (!($record instanceof \record_adapter)) {
|
if (!($record instanceof \record_adapter)) {
|
||||||
throw new \Exception_NotFound('bad luck');
|
throw new \Exception_NotFound('bad luck');
|
||||||
@@ -78,7 +78,7 @@ class Permalink extends AbstractDelivery
|
|||||||
}
|
}
|
||||||
$response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
$response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||||
|
|
||||||
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'key' => $key));
|
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token));
|
||||||
$response->headers->set('Link', $linkToCaption);
|
$response->headers->set('Link', $linkToCaption);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@@ -100,18 +100,18 @@ class Permalink extends AbstractDelivery
|
|||||||
|
|
||||||
$response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
$response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||||
|
|
||||||
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'key' => $key));
|
$linkToCaption = $app->path("view_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token));
|
||||||
$response->headers->set('Link', $linkToCaption);
|
$response->headers->set('Link', $linkToCaption);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
};
|
};
|
||||||
|
|
||||||
$controllers->get('/v1/{sbas_id}/{record_id}/caption/', function(PhraseaApplication $app, Request $request, $sbas_id, $record_id) {
|
$controllers->get('/v1/{sbas_id}/{record_id}/caption/', function(PhraseaApplication $app, Request $request, $sbas_id, $record_id) {
|
||||||
$key = $request->query->get('token');
|
$token = $request->query->get('token');
|
||||||
|
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
|
|
||||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, 'thumbnail');
|
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, 'thumbnail');
|
||||||
if (null === $record) {
|
if (null === $record) {
|
||||||
throw new NotFoundHttpException("Caption not found");
|
throw new NotFoundHttpException("Caption not found");
|
||||||
}
|
}
|
||||||
@@ -123,23 +123,23 @@ class Permalink extends AbstractDelivery
|
|||||||
->bind('view_caption');
|
->bind('view_caption');
|
||||||
|
|
||||||
$controllers->get('/v1/{sbas_id}/{record_id}/{subdef}/', function (PhraseaApplication $app, Request $request, $sbas_id, $record_id, $subdef) use ($deliverPermaview) {
|
$controllers->get('/v1/{sbas_id}/{record_id}/{subdef}/', function (PhraseaApplication $app, Request $request, $sbas_id, $record_id, $subdef) use ($deliverPermaview) {
|
||||||
$key = $request->query->get('token');
|
$token = $request->query->get('token');
|
||||||
|
|
||||||
return $deliverPermaview($sbas_id, $record_id, $key, $subdef, $app);
|
return $deliverPermaview($sbas_id, $record_id, $token, $subdef, $app);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $key, $subdef) use ($deliverPermaview) {
|
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $token, $subdef) use ($deliverPermaview) {
|
||||||
return $deliverPermaview($sbas_id, $record_id, $key, $subdef, $app);
|
return $deliverPermaview($sbas_id, $record_id, $token, $subdef, $app);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->get('/v1/{sbas_id}/{record_id}/{subdef}/{label}', function (PhraseaApplication $app, Request $request, $sbas_id, $record_id, $subdef, $label) use ($deliverPermalink) {
|
$controllers->get('/v1/{sbas_id}/{record_id}/{subdef}/{label}', function (PhraseaApplication $app, Request $request, $sbas_id, $record_id, $subdef, $label) use ($deliverPermalink) {
|
||||||
$key = $request->query->get('token');
|
$token = $request->query->get('token');
|
||||||
|
|
||||||
return $deliverPermalink($app, $sbas_id, $record_id, $key, $subdef);
|
return $deliverPermalink($app, $sbas_id, $record_id, $token, $subdef);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $key, $subdef) use ($deliverPermalink) {
|
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/', function(PhraseaApplication $app, $label, $sbas_id, $record_id, $token, $subdef) use ($deliverPermalink) {
|
||||||
return $deliverPermalink($app, $sbas_id, $record_id, $key, $subdef);
|
return $deliverPermalink($app, $sbas_id, $record_id, $token, $subdef);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
|
@@ -185,7 +185,7 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
|||||||
$this->assertEquals($response->headers->get($name), $value);
|
$this->assertEquals($response->headers->get($name), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?key=".$token);
|
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
|||||||
$this->assertEquals($response->headers->get($name), $value);
|
$this->assertEquals($response->headers->get($name), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?key=".$token);
|
$this->assertEquals($response->headers->get("Link"), "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user