PHP + Json Web Token (JWT) Tutorial

Поділитися
Вставка
  • Опубліковано 18 вер 2024

КОМЕНТАРІ • 14

  • @themonster4759
    @themonster4759 10 місяців тому +1

    you are The King Of PHP

  • @unknownunknown8573
    @unknownunknown8573 10 місяців тому +1

    As always, great content! Thanks Gary!

  • @truthteachers
    @truthteachers 10 місяців тому

    Hi Gary, I was excited about the topic and then got disappointed when i realized too soon that it was linked into TDD and Pest. I was expecting a course JWT on its own with the test dependency. 😢

  • @Anthony99
    @Anthony99 5 місяців тому

    Great video, thank you!! :-) Exceptional work... I gave a like & subscribed.

    • @GaryClarkeTech
      @GaryClarkeTech  5 місяців тому

      Awesome, thank you!

    • @Anthony99
      @Anthony99 5 місяців тому

      No problems at all... hopefully it helps! 🙂
      I was about to get to work writing JWT's into one of my web apps, although now I'm not sure what the advantage of using JWT is over sessions in PHP?
      I was originally going to do it because I'm having trouble with cookies expiring after 15 mins unattended (think its the web server)... then I read people say don't store JWT in local storage, only in cookies... but my cookies are expiring anyway, so JWT would die with the expired cookie.
      What do you think the key advantage to using a JWT is?
      Thanks for your time... :-)

  • @niknt
    @niknt 9 місяців тому

    Thank you for this useful video. We can use JWT token to get an access to the API endpoint. Adding HTTP Header: "Authorization: Bearer " will help us. But what is a correct way of storing this access token in the application? Should we store it in the Database? Or maybe we should store this token in the cache (Redis, Memached)?

    • @GaryClarkeTech
      @GaryClarkeTech  9 місяців тому +1

      It's a long answer which really depends on your application but memory or DB would be ok for server-side applications. For mobile or desktop, you'll more likely need to rely on something else...Keychain / Keystore / CredsLocker

  • @sliceem88
    @sliceem88 10 місяців тому

    Tnx ! Perfect content !

  • @jmmmmmmmmmk
    @jmmmmmmmmmk 6 місяців тому

    Hello Does not https transfer data in encrypted form between client and sever
    Do we still need JWT?
    Can you elaborate on this please?

    • @GaryClarkeTech
      @GaryClarkeTech  6 місяців тому +1

      JWT is used for authentication, not encryption.

    • @jmmmmmmmmmk
      @jmmmmmmmmmk 6 місяців тому

      @@GaryClarkeTech thank you nice video

  • @devfahim5933
    @devfahim5933 9 місяців тому

    Hey Gary great content. I was trying to generate a secret base64 encoding (verify signature ). Can shortly give me an idea about that . How can i generate that.

    • @GaryClarkeTech
      @GaryClarkeTech  9 місяців тому +1

      In php you can do something like this...this is a little simplified but you should get the idea
      // Your data and secret key
      $data = "Your data here";
      $secret_key = "your_secret_key";
      // Create a signature using a cryptographic hash function, e.g., SHA-256
      $signature = hash_hmac('sha256', $data, $secret_key, true);
      // Encode the signature in Base64
      $encoded_signature = base64_encode($signature);
      echo $encoded_signature;