JWT Logout: The Trick You Missed in Spring Security (Solved!)

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 35

  • @LearnWithIfte
    @LearnWithIfte  8 месяцев назад +3

    Storing every single JWT token in your database could have performance and storage implications. Here's how we can address this concern:
    1. Consider alternative blacklisting approaches:
    Cache-based blacklisting:
    Instead of storing tokens, store only the IDs or unique identifiers in a cache. This approach uses less storage and offers faster lookup times. You can use Redis for that.
    Short-lived tokens:
    Set shorter expiration times for JWTs. This reduces the number of tokens in circulation and minimizes the impact on your database even if you store them.
    2. Leverage database optimization techniques:
    Partitioning:
    Divide your data into smaller segments based on token issuance or expiration time. This improves query performance and reduces the overall impact on your database.
    Data deletion or archiving:
    Implement automated processes to remove expired tokens from your database periodically. This ensures you only store relevant information and optimize storage usage.
    3. Evaluate the trade-offs:
    While storing tokens might increase database load, it offers additional benefits like:
    Centralized revocation:
    You can easily revoke specific tokens if needed, even if they haven't expired yet.
    Auditing:
    You can track user activity and logout events by storing tokens.
    Ultimately, the best approach depends on your specific application's needs and resource constraints. You can experiment with different methods and analyze their impact on performance and security to find the optimal solution for your system.
    Feel free to reach out if you have any further questions!
    #springsecurity #jwt #authentication #springboot #security #devops

  • @tarunbalchandbhaimulchanda6929
    @tarunbalchandbhaimulchanda6929 8 месяцев назад +1

    Hey iftikhar I was someone who has already implemented it. Just came accross due to curiosity. I must say the way you teach is so good

    • @LearnWithIfte
      @LearnWithIfte  8 месяцев назад +1

      Thank you so much for your kind words! I'm glad you found the teaching helpful.

  • @عمارالإدريسي-ض2ع
    @عمارالإدريسي-ض2ع 3 месяца назад

    Thank you very much you helped me a lot. And please can you give us the name of the program you used at the beginning of the video

  • @kamilpraseej7065
    @kamilpraseej7065 8 месяцев назад +1

    Thank you for your in-depth teachings on Spring Security, which have been incredibly informative. I would like to make a request to incorporate OAuth2 concepts and implement database storage for user data. This enhancement would greatly benefit the platform's security and user experience.

    • @LearnWithIfte
      @LearnWithIfte  8 месяцев назад +1

      I'm glad you found the teachings informative! I'll definitely consider incorporating OAuth2 concepts and database storage for user data in future videos.

    • @surajmsd
      @surajmsd 8 месяцев назад

      I also would like that!! I want to learn Oauth2 next the series has been great so far!@@LearnWithIfte

  • @nhathaomai4293
    @nhathaomai4293 4 месяца назад

    Great lecture, very easy to understand, I'm grateful for it!

  • @krishankantsinghgautam5558
    @krishankantsinghgautam5558 8 месяцев назад

    Thank you for in-depth tutorial, I have a question:
    Considering the potential cost to our database, both in terms of storage and performance, what are the implications of storing JWT tokens for every login and logout, especially given that tokens expire within a set timeframe? How can we ensure that this approach is beneficial for our application in terms of security and functionality, while also minimizing the impact on our database?

    • @LearnWithIfte
      @LearnWithIfte  8 месяцев назад

      That's a great question! You're right, storing every single JWT token in your database could have performance and storage implications. Here's how we can address this concern:
      1. Consider alternative blacklisting approaches:
      Cache-based blacklisting:
      Instead of storing tokens, store only the IDs or unique identifiers in a cache. This approach uses less storage and offers faster lookup times. You can use Redis for that.
      Short-lived tokens:
      Set shorter expiration times for JWTs. This reduces the number of tokens in circulation and minimizes the impact on your database even if you store them.
      2. Leverage database optimization techniques:
      Partitioning:
      Divide your data into smaller segments based on token issuance or expiration time. This improves query performance and reduces the overall impact on your database.
      Data deletion or archiving:
      Implement automated processes to remove expired tokens from your database periodically. This ensures you only store relevant information and optimize storage usage.
      3. Evaluate the trade-offs:
      While storing tokens might increase database load, it offers additional benefits like:
      Centralized revocation:
      You can easily revoke specific tokens if needed, even if they haven't expired yet.
      Auditing:
      You can track user activity and logout events by storing tokens.
      Ultimately, the best approach depends on your specific application's needs and resource constraints. You can experiment with different methods and analyze their impact on performance and security to find the optimal solution for your system.
      Feel free to reach out if you have any further questions!
      #springsecurity #jwt #authentication #springboot #security #devops

    • @krishankantsinghgautam5558
      @krishankantsinghgautam5558 8 месяцев назад

      ​@@LearnWithIfte Thanks for the insightful information. I will consider one of these options for an optimized operation.

  • @alejo187
    @alejo187 6 месяцев назад

    wow bro this was excelent content, thank you very much, i look forward to a video on implementation of OAuth2!! ty!!

    • @LearnWithIfte
      @LearnWithIfte  6 месяцев назад +1

      Thank you for your suggestion! I'll definitely consider making a video on OAuth2. Stay tuned for future content!

  • @arisusantolie4486
    @arisusantolie4486 8 месяцев назад

    Hi, im just want to add something for improvement, instead of using regular database to store the token, its better using redis (in memory database) for faster read to improve latency.

  • @geybriyel2416
    @geybriyel2416 6 месяцев назад

    hi Iftekhar, I hope you can consider creating a tutorial for deploying a java-spring boot project 🙏 thank you

    • @LearnWithIfte
      @LearnWithIfte  6 месяцев назад

      Thank you for your suggestion! I'll definitely consider making a video on deploying a java-spring boot project. Stay tuned for future content!

  • @minhlequang2927
    @minhlequang2927 6 месяцев назад

    If I’m using Redis to store the tokens, would it be better if I just delete the token directly and not use the loggedOut attribute?

  • @CarlosGarcia-ll8zc
    @CarlosGarcia-ll8zc 8 месяцев назад

    Hello, thank you very much for creating this content, it has been very helpful to me in understanding this topic. Would it be possible for you to make a video on how to combine login using Oauth2 (third party applications like Facebook, Google etc) and login and registration using JWT? Thanks again

    • @LearnWithIfte
      @LearnWithIfte  8 месяцев назад +2

      Thank you for your kind words and suggestion! I'll definitely consider making a video on that topic in the future.

  • @De_Bryan
    @De_Bryan 4 месяца назад

    Good one. Thanks

  • @tarunbalchandbhaimulchanda6929
    @tarunbalchandbhaimulchanda6929 8 месяцев назад

    Siggested topics:
    You were too good with implementation part. It would be better if you elaborate the architectural need indeph. This video can be good for someone who needs a refrence but if someone needs detailed understanding this suggestion might help. Although the quick discussion in this video was also great

    • @LearnWithIfte
      @LearnWithIfte  7 месяцев назад

      Thank you for your suggestion. I'll definitely consider to make detailed indepth video in future

  • @geybriyel2416
    @geybriyel2416 6 месяцев назад

    Hi, how can I return a json response when the /logout is called?

  • @manoharanrajendiran568
    @manoharanrajendiran568 6 месяцев назад

    ❤❤❤❤thanks for the videos . Please make some Spring Webflux with security Jwt login logout with role based authentication.

  • @muhammedkerek9615
    @muhammedkerek9615 5 месяцев назад

    hello i am deleting the tokens each time when a new login token is generated and i haven't used the isLoggedOut approach , is there any other solution to make only the last token that was logged in with to be valid ?

  • @HllemMighty
    @HllemMighty 7 месяцев назад

    Can you do Oauth2 on Spring Boot on your next videos. Thanks

    • @LearnWithIfte
      @LearnWithIfte  7 месяцев назад

      Thank you for your suggestion! I'll definitely consider making a video on oauth2 and spring boot. Stay tuned for future content!

  • @LeetCodeUzbekistan
    @LeetCodeUzbekistan 8 месяцев назад

    let's make User post, just a simple post maybe with just some text

  • @_thanhxv14
    @_thanhxv14 2 месяца назад

    Thank you very much you helped me a lot. And please can you give us the name of the program you used at the beginning of the video