Developed with love by KnpLabs Hire us for your project!
23

NzoUrlEncryptorBundle

by NAYZO

Symfony2 Bundle used to Encrypt and Decrypt data and variables in the Web application

NzoUrlEncryptorBundle

Build Status

The NzoUrlEncryptorBundle is a Symfony2 Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through the URL to provide more security to the project.
Also it prevent users from reading and modifying sensitive data sent through the URL.

Features include:

  • Url Data & parameters Encryption
  • Url Data & parameters Decryption
  • Access from Twig by ease
  • Flexible configuration

Installation

Through Composer:

Add the following lines in your composer.json file:

"require": {
    "nzo/url-encryptor-bundle": "~1.0"
}

Install the bundle:

$ composer update

Register the bundle in app/AppKernel.php:

// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Nzo\UrlEncryptorBundle\NzoUrlEncryptorBundle(),
    );
}

Configure your application's config.yml:

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 

Usage

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>

Also you can encrypt and decrypt variables and data using the Twig filter:

// Encrypt data:

        {{MyVar | urlencrypt }}

 // Decrypt data:

         {{MyVar | urldecrypt }}

In the routing.yml:

# routing.yml

my-path-in-the-routing:    
    path: /my-url/{id}
    defaults: {_controller: MyBundle:MyController:MyFunction}

In the controller use the decrypt function of the service on the encrypted id:

     public function indexAction($id) 
    {
        $MyId = $this->get('nzo_url_encryptor')->decrypt($id);

        //....

    }    

You can also use the encrypt function of the service to encrypt your data:

     public function indexAction() 
    {   
        //....

        $Encrypted = $this->get('nzo_url_encryptor')->encrypt($data);

        //....

    }    

License

This bundle is under the MIT license. See the complete license in the bundle:

See Resources/doc/LICENSE

The MIT License (MIT)

Copyright (c) 2014 Ala Eddine khefifi

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
nzo_url_encryptor:
secret:
  • Update composer.json
    By NAYZO, 1 year ago
  • Update composer.json
    By NAYZO, 1 year ago
  • Update README
    By NAYZO, 1 year ago
  • update README
    By NAYZO, 2 years ago
  • update README
    By NAYZO, 2 years ago
  • Update namespace call
    By NAYZO, 2 years ago
  • Refactor code
    By NAYZO, 2 years ago
  • Update Composer.json
    By NAYZO, 2 years ago
  • Update README
    By NAYZO, 2 years ago
  • fix typo
    By NAYZO, 2 years ago
  • fix typo
    By NAYZO, 2 years ago
  • Update README
    By NAYZO, 2 years ago
  • fix typos
    By NAYZO, 2 years ago
  • Update typos
    By NAYZO, 2 years ago
  • Update typos
    By NAYZO, 2 years ago
  • Update test
    By NAYZO, 2 years ago
  • Update travis
    By NAYZO, 2 years ago
  • Update travis
    By NAYZO, 2 years ago
  • Update travis
    By NAYZO, 2 years ago
  • Update travis
    By NAYZO, 2 years ago
  • Update README and release
    By NAYZO, 2 years ago
  • Update composer.json
    By NAYZO, 2 years ago
  • Update index.rst
    By NAYZO, 2 years ago
  • Update composer.json
    By NAYZO, 2 years ago
  • Update by Nayzo 10
    By nayzo, 2 years ago
  • Update by Nayzo 10
    By nayzo, 2 years ago
  • Update
    By nayzo, 3 years ago
  • Update
    By nayzo, 3 years ago
  • Update
    By nayzo, 3 years ago
  • Update
    By nayzo, 3 years ago