Skip to content

Latest commit

 

History

History
76 lines (51 loc) · 2.35 KB

README.md

File metadata and controls

76 lines (51 loc) · 2.35 KB

Symfony2 Secured REST API

Symfony2 Rest Api secured with Json Web Token

SensioLabsInsight

This project is a secured Restful API template for Symfony2 using lexik/LexikJWTAuthenticationBundle FriendsOfSymfony/FOSRestBundle and FriendsOfSymfony/FOSUserBundle

Create your REST API in 5 minutes

  1. Clone or fork this repository bash $ git clone https://github.com/unautreweb/symfony2-secured-rest-api.git

  2. Install vendors with Composer: bash $ composer update

  3. Generate the SSH keys :

    $ openssl genrsa -out app/var/jwt/private.pem -aes256 4096
    $ openssl rsa -pubout -in app/var/jwt/private.pem -out app/var/jwt/public.pem
  4. Configure the SSH keys path in your config.yml :

    lexik_jwt_authentication:
        private_key_path: %kernel.root_dir%/var/jwt/private.pem   # ssh private key path
        public_key_path:  %kernel.root_dir%/var/jwt/public.pem    # ssh public key path
        pass_phrase:      ''                                      # ssh key pass phrase
        token_ttl:        86400                                   # token ttl - defaults to 86400

Demonstration

Here is an example of the API rest.unautreweb.net:

Testing

Setup the test suite using Composer:

$ composer install --dev

Run it using PHPUnit:

$ vendor/bin/phpunit

Credits

License

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

LICENSE