Skip to content

jshiherlis/symfony2-secured-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Symfony2 Rest Api secured with Json Web Token

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published