Giter Site home page Giter Site logo

symfony2-secured-rest-api's Introduction

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

symfony2-secured-rest-api's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

symfony2-secured-rest-api's Issues

Add custom data to token

Thanks very much for your work!
I would like to add more data to the token, such as userId. I have follow https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/2-data-customization.md and add in config.yml:

services:
uaw_rest.event.jwt_created_listener:
class: UAW\Bundle\RestBundle\EventListener\JWTCreatedListener
tags:
- { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }

but class JWTCreatedListener.php is not executed. Any idea?

Thanks!

[Insight] Dependencies not installable

SensioLabsInsight was not able to install your Composer dependencies. If you need to customize files or run commands to make it work, you can edit your SensioLabsInsight project configuration to override the default "pre_composer_script" and/or "post_composer_script" settings.

Loading composer repositories with package information
Installing dependencies (including require-dev)
Writing lock file
Generating optimized autoload files
Creating the "app/config/parameters.yml" file



  [RuntimeException]                        
  The configuration tree has no root node.  



Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception



  [RuntimeException]                                                         
  An error occurred when executing the "'cache:clear --no-warmup'" command.  



install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]




Posted from SensioLabsInsight

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.