forked from schmittjoh/JMSPaymentCoreBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/larger-decimals
* develop: Remove paypal plugin dependency (schmittjoh#220) Replace abandoned project by most advanced fork Test for symfony 3.3 No longer build for HHVM Avoid reliance on kernel version Prepare release 1.3.0 Deprecate usage of mcrypt (schmittjoh#200) Add command for generating encryption keys (schmittjoh#208) Make defuse the default encryption provider (schmittjoh#207) Add encryption provider for defuse/php-encryption (schmittjoh#206) Allow custom encryption providers (schmittjoh#205) Make encryption optional (schmittjoh#204) Deprecate payment.encryption_service in favor of payment.crypto.mcrypt (schmittjoh#203) Refactor ExtendedDataType (schmittjoh#202) Fix tests (schmittjoh#199)
- Loading branch information
Showing
57 changed files
with
924 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\Command; | ||
|
||
use Defuse\Crypto\Key; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class GenerateKeyCommand extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('jms_payment_core:generate-key') | ||
->setDescription('Generate an encryption key') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$output->writeln(Key::createNewRandomKey()->saveToAsciiSafeString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\Cryptography; | ||
|
||
use Defuse\Crypto\Crypto; | ||
use Defuse\Crypto\Key; | ||
|
||
class DefusePhpEncryptionService implements EncryptionServiceInterface | ||
{ | ||
private $key; | ||
|
||
public function __construct($secret) | ||
{ | ||
$this->key = Key::loadFromAsciiSafeString($secret); | ||
} | ||
|
||
public function decrypt($encryptedValue) | ||
{ | ||
return Crypto::decrypt($encryptedValue, $this->key); | ||
} | ||
|
||
public function encrypt($rawValue) | ||
{ | ||
return Crypto::encrypt($rawValue, $this->key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class ConfigureEncryptionPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->getParameter('payment.encryption.enabled')) { | ||
return; | ||
} | ||
|
||
$providers = array(); | ||
|
||
foreach ($container->findTaggedServiceIds('payment.encryption') as $id => $attrs) { | ||
if (!isset($attrs[0]['alias'])) { | ||
throw new \RuntimeException("Please define an alias attribute for tag 'payment.encryption' of service '$id'"); | ||
} | ||
|
||
$providers[$attrs[0]['alias']] = $id; | ||
} | ||
|
||
$configuredProvider = $container->getParameter('payment.encryption'); | ||
|
||
if (!array_key_exists($configuredProvider, $providers)) { | ||
throw new \RuntimeException("The configured encryption provider ($configuredProvider) must match the alias of one of the services tagged with 'payment.encryption'"); | ||
} | ||
|
||
$container->setAlias('payment.encryption', $providers[$configuredProvider]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace JMS\Payment\CoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* The service `payment.encryption_service` has been deprecated in favor of | ||
* `payment.encryption.mcrypt`. This compiler pass makes sure parameters specified | ||
* for `payment.encryption_service` are instead set for `payment.encryption.mcrypt`. | ||
* | ||
* @deprecated 1.3 Will be removed in 2.0 | ||
*/ | ||
class LegacyEncryptionPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->has('payment.encryption_service')) { | ||
return; | ||
} | ||
|
||
if (!$container->has('payment.encryption.mcrypt')) { | ||
return; | ||
} | ||
|
||
$parameters = array( | ||
'class' => 'JMS\Payment\CoreBundle\Cryptography\MCryptEncryptionService', | ||
'secret' => '', | ||
'cipher' => 'rijndael-256', | ||
'mode' => 'ctr', | ||
); | ||
|
||
foreach ($parameters as $parameter => $defaultValue) { | ||
if (!$container->hasParameter('payment.encryption_service.'.$parameter)) { | ||
continue; | ||
} | ||
|
||
if (!$container->hasParameter('payment.encryption.mcrypt.'.$parameter)) { | ||
continue; | ||
} | ||
|
||
$legacyValue = $container->getParameter('payment.encryption_service.'.$parameter); | ||
$modernValue = $container->getParameter('payment.encryption.mcrypt.'.$parameter); | ||
|
||
// Parameters set for payment.encryption.mcrypt take precedence over | ||
// ones set for payment.encryption_service | ||
if ($modernValue !== $defaultValue) { | ||
$container->setParameter('payment.encryption.mcrypt.'.$parameter, $modernValue); | ||
} elseif ($legacyValue !== $defaultValue) { | ||
$container->setParameter('payment.encryption.mcrypt.'.$parameter, $legacyValue); | ||
@trigger_error('payment.encryption_service.'.$parameter.' has been deprecated in favor of payment.encryption.mcrypt.'.$parameter.' and will be removed in 2.0', E_USER_DEPRECATED); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.