-
Notifications
You must be signed in to change notification settings - Fork 19
Home
Ala Eddine khefifi edited this page Sep 26, 2013
·
3 revisions
The NzoUrlEncryptorBundle is a Symfony2 Bundle used to Encrypt and Decrypt the variables passed variables through url and links and to provide more security in term of access to your project. It prevent users from reading and modifying sensitive data sent through the url.
Features include:
- Url Variables Encryption
- Url Variables Decryption
- Access from Twig by ease
- Flexible configuration
Add the following lines in your composer.json
file:
"require": {
"nzo/url-encryptor-bundle": "dev-master"
}
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Nzo\UrlEncryptorBundle\NzoUrlEncryptorBundle(),
);
}
The secret option in the configuration must contain a random key string of maximum 8 caracters and minimum of one caracter.
# app/config/config.yml
nzo_url_encryptor:
secret: YourSecretEncryptionKey
In your twig template use the filter to encrypt the variable in the url:
<a href="{{path('my-path-in-the-routing', {'id': MyId | urlencrypt } )}}"> My link </a>
# if it needed you can use the twig decryption filter:
<a href="{{path('my-path-in-the-routing', {'id': MyId | urldecrypt } )}}"> My link </a>
In the controller use the decrypt service on the encrypted 'variable' comming from the routing:
public function indexAction($encrypted_id)
{
$Id = $this->get('nzo_url_encryptor')->decrypt($encrypted_id);
//....
}
This bundle is under the MIT license. See the complete license in the bundle: