mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
PHRAS-3375 port download validity link
This commit is contained in:
@@ -127,6 +127,7 @@ class RegistryFormManipulator
|
||||
'enable-push-authentication' => false,
|
||||
'force-push-authentication' => false,
|
||||
'enable-feed-notification' => true,
|
||||
'download-link-validity' => 24,
|
||||
],
|
||||
'ftp' => [
|
||||
'ftp-enabled' => false,
|
||||
|
@@ -57,7 +57,8 @@ class ManipulatorServiceProvider implements ServiceProviderInterface
|
||||
$app['orm.em'],
|
||||
$app['random.medium'],
|
||||
$app['repo.tokens'],
|
||||
$app['tmp.download.path']
|
||||
$app['tmp.download.path'],
|
||||
$app['conf']
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -57,6 +57,9 @@ class ActionsFormType extends AbstractType
|
||||
$builder->add('enable-feed-notification', 'checkbox', [
|
||||
'label' => 'Enable possibility to notify users when publishing a new feed entry',
|
||||
]);
|
||||
$builder->add('download-link-validity', 'integer', [
|
||||
'label' => 'Validity period of the download links',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Model\Manipulator;
|
||||
|
||||
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
||||
use Alchemy\Phrasea\Model\Entities\Token;
|
||||
@@ -41,6 +42,7 @@ class TokenManipulator implements ManipulatorInterface
|
||||
private $om;
|
||||
private $random;
|
||||
private $repository;
|
||||
private $conf;
|
||||
|
||||
private $temporaryDownloadPath;
|
||||
|
||||
@@ -48,12 +50,14 @@ class TokenManipulator implements ManipulatorInterface
|
||||
ObjectManager $om,
|
||||
Generator $random,
|
||||
TokenRepository $repository,
|
||||
$temporaryDownloadPath)
|
||||
$temporaryDownloadPath,
|
||||
PropertyAccess $configuration)
|
||||
{
|
||||
$this->om = $om;
|
||||
$this->random = $random;
|
||||
$this->repository = $repository;
|
||||
$this->temporaryDownloadPath = $temporaryDownloadPath;
|
||||
$this->conf = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +172,9 @@ class TokenManipulator implements ManipulatorInterface
|
||||
*/
|
||||
public function createDownloadToken(User $user, $data)
|
||||
{
|
||||
return $this->create($user, self::TYPE_DOWNLOAD, new DateTime('+3 hours'), $data);
|
||||
$downloadLinkValidity = (int) $this->conf->get(['registry', 'actions', 'download-link-validity'], 24);
|
||||
|
||||
return $this->create($user, self::TYPE_DOWNLOAD, new DateTime("+{$downloadLinkValidity} hours"), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +184,9 @@ class TokenManipulator implements ManipulatorInterface
|
||||
*/
|
||||
public function createEmailExportToken($data)
|
||||
{
|
||||
return $this->create(null, self::TYPE_EMAIL, new DateTime('+1 day'), $data);
|
||||
$downloadLinkValidity = (int) $this->conf->get(['registry', 'actions', 'download-link-validity'], 24);
|
||||
|
||||
return $this->create(null, self::TYPE_EMAIL, new DateTime("+{$downloadLinkValidity} hours"), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
|
||||
<file date="2021-02-09T15:07:53Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
|
||||
<file date="2021-02-18T14:54:58Z" source-language="en" target-language="de" datatype="plaintext" original="not.available">
|
||||
<header>
|
||||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
|
||||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
|
||||
@@ -9,9 +9,9 @@
|
||||
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes">
|
||||
<source>Please provide the same passwords.</source>
|
||||
<target state="translated">Bitte geben Sie diesselbe Passwörter ein.</target>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
<jms:reference-file line="44">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="36">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
</trans-unit>
|
||||
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes">
|
||||
<source>The token provided is not valid anymore</source>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
|
||||
<file date="2021-02-09T15:08:37Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
|
||||
<file date="2021-02-18T14:55:38Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
|
||||
<header>
|
||||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
|
||||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
|
||||
@@ -9,9 +9,9 @@
|
||||
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes">
|
||||
<source>Please provide the same passwords.</source>
|
||||
<target state="translated">Please provide the same passwords.</target>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
<jms:reference-file line="44">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="36">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
</trans-unit>
|
||||
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes">
|
||||
<source>The token provided is not valid anymore</source>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
|
||||
<file date="2021-02-09T15:09:25Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
|
||||
<file date="2021-02-18T14:56:19Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
|
||||
<header>
|
||||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
|
||||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
|
||||
@@ -9,9 +9,9 @@
|
||||
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords." approved="yes">
|
||||
<source>Please provide the same passwords.</source>
|
||||
<target state="translated">Veuillez indiquer des mots de passe identiques.</target>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
<jms:reference-file line="44">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="36">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
</trans-unit>
|
||||
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore" approved="yes">
|
||||
<source>The token provided is not valid anymore</source>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
|
||||
<file date="2021-02-09T15:10:15Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
|
||||
<file date="2021-02-18T14:57:02Z" source-language="en" target-language="nl" datatype="plaintext" original="not.available">
|
||||
<header>
|
||||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
|
||||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
|
||||
@@ -9,9 +9,9 @@
|
||||
<trans-unit id="96f0767cb7ea65a7f86c8c9432e80d16cf9d8680" resname="Please provide the same passwords.">
|
||||
<source>Please provide the same passwords.</source>
|
||||
<target state="new">Please provide the same passwords.</target>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
<jms:reference-file line="44">Form/Login/PhraseaRecoverPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="36">Form/Login/PhraseaRenewPasswordForm.php</jms:reference-file>
|
||||
<jms:reference-file line="49">Form/Login/PhraseaRegisterForm.php</jms:reference-file>
|
||||
</trans-unit>
|
||||
<trans-unit id="90b8c9717bb7ed061dbf20fe1986c8b8593d43d4" resname="The token provided is not valid anymore">
|
||||
<source>The token provided is not valid anymore</source>
|
||||
|
@@ -19,7 +19,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
$user = $user ? self::$DI['user'] : null;
|
||||
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->create($user, $type, $expiration, $data);
|
||||
|
||||
$this->assertSame($user, $token->getUser());
|
||||
@@ -42,7 +42,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateBasketValidationToken()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$expire = new DateTime('+10 days');
|
||||
$token = $manipulator->createBasketValidationToken(self::$DI['basket_4'], self::$DI['user_1'], $expire);
|
||||
|
||||
@@ -54,7 +54,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateBasketValidationTokenWithoutExpiration()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createBasketValidationToken(self::$DI['basket_4'], self::$DI['user_1'], null);
|
||||
|
||||
$this->assertSame(self::$DI['basket_4']->getId(), $token->getData());
|
||||
@@ -65,14 +65,14 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateBasketValidationTokenWithInvalidBasket()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$this->setExpectedException('InvalidArgumentException', 'A validation token requires a validation basket.');
|
||||
$manipulator->createBasketValidationToken(self::$DI['basket_1'], self::$DI['user_1'], null);
|
||||
}
|
||||
|
||||
public function testCreateBasketAccessToken()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createBasketAccessToken(self::$DI['basket_4'], self::$DI['user']);
|
||||
|
||||
$this->assertSame(self::$DI['basket_4']->getId(), $token->getData());
|
||||
@@ -83,7 +83,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateFeedEntryToken()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createFeedEntryToken(self::$DI['user'], self::$DI['feed_public_entry']);
|
||||
|
||||
$this->assertSame(self::$DI['feed_public_entry']->getId(), $token->getData());
|
||||
@@ -95,7 +95,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
public function testCreateDownloadToken()
|
||||
{
|
||||
$data = serialize(['some' => 'data']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createDownloadToken(self::$DI['user'], $data);
|
||||
|
||||
$this->assertSame($data, $token->getData());
|
||||
@@ -107,7 +107,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
public function testCreateEmailExportToken()
|
||||
{
|
||||
$data = serialize(['some' => 'data']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createEmailExportToken($data);
|
||||
|
||||
$this->assertSame($data, $token->getData());
|
||||
@@ -118,7 +118,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateResetEmailToken()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createResetEmailToken(self::$DI['user'], 'newemail@phraseanet.com');
|
||||
|
||||
$this->assertSame('newemail@phraseanet.com', $token->getData());
|
||||
@@ -129,7 +129,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateAccountUnlockToken()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createAccountUnlockToken(self::$DI['user']);
|
||||
|
||||
$this->assertNull($token->getData());
|
||||
@@ -140,7 +140,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
|
||||
public function testCreateResetPasswordToken()
|
||||
{
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$token = $manipulator->createResetPasswordToken(self::$DI['user']);
|
||||
|
||||
$this->assertNull($token->getData());
|
||||
@@ -160,7 +160,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
$em->expects($this->once())
|
||||
->method('flush');
|
||||
|
||||
$manipulator = new TokenManipulator($em, self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator($em, self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$manipulator->update($token);
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
$em->expects($this->once())
|
||||
->method('flush');
|
||||
|
||||
$manipulator = new TokenManipulator($em, self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator($em, self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$manipulator->delete($token);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ class TokenManipulatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
$this->assertCount(4, self::$DI['app']['repo.tokens']->findAll());
|
||||
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['tmp.download.path']);
|
||||
$manipulator = new TokenManipulator(self::$DI['app']['orm.em'], self::$DI['app']['random.low'], self::$DI['app']['repo.tokens'], self::$DI['app']['tmp.download.path'], self::$DI['app']['conf']);
|
||||
$manipulator->removeExpiredTokens();
|
||||
|
||||
$this->assertCount(3, self::$DI['app']['repo.tokens']->findAll());
|
||||
|
Reference in New Issue
Block a user