This project is a secured Restful API template for Symfony2
using lexik/LexikJWTAuthenticationBundle
FriendsOfSymfony/FOSRestBundle
and
FriendsOfSymfony/FOSUserBundle
-
Clone or fork this repository
bash $ git clone https://github.com/unautreweb/symfony2-secured-rest-api.git
-
Install vendors with Composer:
bash $ composer update
-
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
-
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
Here is an example of the API rest.unautreweb.net:
- List of items http://rest.unautreweb.net/v1/items
- Show an item http://rest.unautreweb.net/v1/items/1
- Authentication http://rest.unautreweb.net/v1/user/security/login_check (demo / 123456)
Setup the test suite using Composer:
$ composer install --dev
Run it using PHPUnit:
$ vendor/bin/phpunit
- Julien Reynaud hi@unautreweb.com
This project is under the MIT license. See the complete license in the bundle:
LICENSE