Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP and JWT for angular

  • 05-11-2016 10:55pm
    #1
    Registered Users, Registered Users 2 Posts: 212 ✭✭


    Hi

    I am exploring the Angularjs + PHP for the first time and wanted to create a crud spa driven by php rest api. Looking in to JWT for authentication.

    Could someone with experience tell me what to do with the generated token. Should i store it as session in php as well or not and how to handle a logout. e.g if user has logged out then how to invalidate a jwt. I am looking in to https://github.com/lcobucci/jwt/blob/3.2/README.md
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 104 ✭✭justjustin


    You could take a look at THIS.

    I have built a couple of small angular2 starter apps which rely on a custom built c#/sql backend but I have not yet taken any steps to authenticate requests.


  • Registered Users, Registered Users 2 Posts: 2,032 ✭✭✭colm_c


    JWT should be stateless, as in it should not need to be tracked on the server, otherwise you may as well use sessions.

    When you create a JWT, you should include any info you need on it, e.g. user_id, user_type, expiry etc. so that the frontend can read it and the backend can validate all the requests.

    Any invalid JWT's will not allow the requests, while correctly signed ones will.

    I would use some PHP framework that supports JWT like laravel, doing it from scratch is possible but kinda annoying.


  • Registered Users, Registered Users 2 Posts: 212 ✭✭iwantthat


    Thanks for the detailed info.

    I looked in to likes of symfony and laravel and it seemed too much just for the sake of JWT. So went ahead with a custom library.

    It is exciting stuff...

    Will update more once i have deep dived into it.


    colm_c wrote: »
    JWT should be stateless, as in it should not need to be tracked on the server, otherwise you may as well use sessions.

    When you create a JWT, you should include any info you need on it, e.g. user_id, user_type, expiry etc. so that the frontend can read it and the backend can validate all the requests.

    Any invalid JWT's will not allow the requests, while correctly signed ones will.

    I would use some PHP framework that supports JWT like laravel, doing it from scratch is possible but kinda annoying.


Advertisement