How to Logout from Spring Security - JWT

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

КОМЕНТАРІ • 300

  • @BoualiAli
    @BoualiAli  Рік тому +6

    COUPON Code: *EARLYBIRD20* => Spring Data J PA course: aliboucoding.com/p/the-full-guide-to-master-spring-boot-data-jpa

  • @michealjohn5288
    @michealjohn5288 Рік тому +3

    He is the best Teacher on spring security. i will recommend you anytime and anywhere

    • @BoualiAli
      @BoualiAli  Рік тому

      Thank you 🙏. Really appreciate that

  • @khanghoang3289
    @khanghoang3289 Місяць тому

    Thanks for this lecture. With this lecture, I can understand how JWT and Spring Security combines together in order to build the security's structure in Spring Boot. Finally, you are the best teachers, you are a lifesaver with me

  • @mfarooqwasi
    @mfarooqwasi 8 місяців тому +1

    Great teacher with clear voice and content, making the life easier for the spring boot developers, great contribution and highly appreciated. Thank you so much
    🥰

  • @MohitSharma-uq2vm
    @MohitSharma-uq2vm Місяць тому

    You saved me from my boss's anger.thankyou very much🙏

  • @saqib-fi4bd
    @saqib-fi4bd 5 місяців тому +1

    Thank you so much for these updated videos. You have no idea how frustrated I got due to the out dated ones when working with Spring boot 3.
    you're helping me in both my full time job and in my freelance projects especially when it came to security of APIs.
    Bundle of Thanks

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

      Glad I could help!

  • @Michaeljamieson10
    @Michaeljamieson10 Рік тому +14

    These are amazing! Refresh tokens would be very useful !

    • @BoualiAli
      @BoualiAli  Рік тому +8

      Thanks.
      I will create a video about that fir sure

  • @flyh21c
    @flyh21c 11 місяців тому +1

    You are the best!
    Thanks a lot!
    Mentions every side of the JWT.
    Basics, logout, refresh token, password change etc...

    • @BoualiAli
      @BoualiAli  11 місяців тому

      Happy you liked it!

  • @aziztolearn
    @aziztolearn Рік тому +2

    Excellent videos and playlist! 👍👍👍👍

  • @MarkSatin1
    @MarkSatin1 Рік тому +3

    Thank you so much for this and your other Spring Security videos! You break down overwhelming concepts into clear smaller pieces so easily. I learned so much from just going through a couple of your videos. Looking forward to watching more!

    • @BoualiAli
      @BoualiAli  Рік тому

      Glad you like them!
      This motivates me

  • @FilipPolitowski
    @FilipPolitowski 7 місяців тому

    This is the best video about Spring Security and JWT. Thanks a lot for this lesson, it helped me incredibly :)

  • @yosr.
    @yosr. Рік тому

    tbarkallah 3la weld bledi
    thank you so much Ali you're a lifesaver

    • @BoualiAli
      @BoualiAli  Рік тому

      Thank youu 🙏
      My pleasure

  • @soukainaj
    @soukainaj 2 місяці тому

    Thank you for the amazing tutorial

  • @sandeepkumar-yz6lw
    @sandeepkumar-yz6lw Рік тому

    Thankyou Sir for sharing your knowledge.

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

    Thanks, your video goes at a very good pace with clear explanations. Apart from a couple of deprecated codes, it was great. Thanks for your help!

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

      deprecations are inevitable. I always release new videos for the updates.
      check the playlists or search in the channel

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

    you have saved the IT Industry, Sir!!

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

      Glad you liked it!

  • @anirudh514
    @anirudh514 8 місяців тому +1

    Thank you so much, very well explained!

  • @AmineCch2t
    @AmineCch2t Рік тому

    Hi from Morocco, ur spring security tutorial are perfect, thank you for ur help.

  • @pateldharmesh1361
    @pateldharmesh1361 Рік тому

    It really cool and superb content.

  • @mohammadobeidat5685
    @mohammadobeidat5685 Рік тому

    Mashallah, thank you my brother for the clear step-by-step tutorial. Keep it up!

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

    it was really a great tutorial. Thanks for sharing your knowledge with us

  • @dipak-t6v
    @dipak-t6v 10 місяців тому

    wonderfull !!! what a enrgy sir. Appriciated....

  • @hasanfarooqui2250
    @hasanfarooqui2250 3 місяці тому

    1) What is the use of revoking and expiring all tokens during JWT creation ( you have already done it in LogoutService class) Why doing twice ?
    2)In this application user can not simultaneously login from two device ? (As soon as he login on another device, you are simply revoking all its previous tokens).
    Is above questions are valid or am I missing anything ?
    btw lecture is very helpful. Thank you.

  • @mrpipiskin4
    @mrpipiskin4 Рік тому

    Thaks for your job. These guides save a lot of time for beginners

  • @mohamednaitmoussa2600
    @mohamednaitmoussa2600 Рік тому

    the best one teaching spring 🔥🔥

  • @mukhammadnajimov8440
    @mukhammadnajimov8440 8 місяців тому +2

    That's soo coool, that you provide such really helpful videos and contents
    Thank you so much Sir

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

      Glad you like them!

  • @JasmineTrader-mw8ru
    @JasmineTrader-mw8ru Рік тому +1

    Awesome tutorial. I have one big doubt, I've seen lots of peopke saying its not secure to store tokens in the database. I am wondering the reason why you are doing this?

    • @BoualiAli
      @BoualiAli  Рік тому

      As I mentioned, there is no implicit implementation for logout (jwt) and that is one simple solution.
      You can performa a daily cleanup for revoked / invalid tokens from the database

    • @JasmineTrader-mw8ru
      @JasmineTrader-mw8ru Рік тому

      @@BoualiAli yes i understand that. But i do not want to store the valid tokens in database either for security reasons. Can you suggest me a way to revoke a token in the backend? Id there anyway we can remove the jwt from security context holder?

  • @HYR0720
    @HYR0720 Рік тому

    You are so wonderful! you teaching is very easy to understand. I watched your video 4 about spring security and i added more to watch them later!

  • @sharathkumar2018
    @sharathkumar2018 Рік тому

    A lot of videos out there which rarely explain about logout! thanks a lot for this amazing video 🙏

  • @michaelroyf4766
    @michaelroyf4766 Рік тому +1

    Thanks for the video!
    I just didn't understand why we need to create a token during registration. and what about the refresh token?

    • @BoualiAli
      @BoualiAli  Рік тому +1

      The token in the registration is just to avoid re logging
      Refresh token will come soon

  • @devynlab
    @devynlab Рік тому +1

    Just finished watching the previous video implementing JWT, and adding this on top of that I've learnt a lot. Super thanks man 🔥.

    • @BoualiAli
      @BoualiAli  Рік тому

      Happy to know that.
      Happy you liked it

  • @thapelomusic1209
    @thapelomusic1209 23 дні тому

    Good tutorial. I have a question. the way in which this is implemented does it mean a user cant log in many devices ? Because the way I see it every time you log into another device all the other devices are logged out automatically

  • @behzadfazelasl9581
    @behzadfazelasl9581 Рік тому

    Very useful and clear explanation. Thanks Ali

  • @sekharjamallamudi9531
    @sekharjamallamudi9531 11 місяців тому

    so much thankful to you sir giving this videos very useful for me. Sir pls do video on forgot reset password

    • @BoualiAli
      @BoualiAli  11 місяців тому

      Already done.
      Subscribe and enable the notifications and you won't miss any of my new videos

  • @mmge3967
    @mmge3967 Рік тому +2

    Thanks for your effort in jwt.
    But i want to ask you a simple question
    Should we delete the previous tokens for specific user so we don't have alot of rows that we don't need in the database or not?
    Thanks in advance.

    • @BoualiAli
      @BoualiAli  Рік тому +1

      This also can be an option if you don’t need the already revoked token

    • @mmge3967
      @mmge3967 Рік тому

      @@BoualiAli ok thanks

  • @shraddhaparajuli7531
    @shraddhaparajuli7531 Рік тому +1

    Applause to your effort. Need to say this video is really informative and helped me extremely for implementing logout with jwt tokens. It would be really helpful if you could start a youtube series on implementing the microservices with all the features provided by spring cloud.

    • @BoualiAli
      @BoualiAli  Рік тому +1

      I already started preparing for such course.
      Preparation take really long time

  • @ismailforeveryone6889
    @ismailforeveryone6889 Рік тому

    Amazing please keep going this topic of security is very rare, specially with this updates of spring security 6

  • @vadimsirenko6966
    @vadimsirenko6966 Рік тому

    Hello from Russia, man. Thanks for your very helpful videos.

    • @BoualiAli
      @BoualiAli  Рік тому +1

      Greetings from Tunisia 🇹🇳
      Happy you like my content

  • @VitaliiSmahlenko-i5h
    @VitaliiSmahlenko-i5h 9 місяців тому

    Very cool explained everything thank you!!!
    One question. Isn't it more logical to just delete tokens so as not to store a bunch of invalid tokens in the database?

    • @medAmineRg
      @medAmineRg 8 місяців тому

      i guess you can do it. it just a matter of history

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

    Thank you for the video!
    I have a question. When I log out, Are the tokens just left permanently in the database?
    I am curious about what processing is common in a practical environment.

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

      you can create a script to clean the DB.
      By the way, Better use keycloak
      I will release a new video next week

  • @alifka6815
    @alifka6815 8 місяців тому

    Thanks for the informative video, the only thing I did not understand is why we do the same checks in LogoutHandler as in the filter, because if there is no Authorization header or it does not start with Bearer, then the filter will not skip this request, and if the filter missed us in EndPoint /logout, it means that the Authorization header is there and the token starts with Bearer and it is also not zero, am I right?

  • @kdvamja
    @kdvamja Рік тому +2

    Such amazing and useful content and a better way to explain it in an easy way. We love your work and efforts.
    Thank you for such amazing content like this ❤.

  • @sheldonlawrence8798
    @sheldonlawrence8798 Рік тому +1

    Excellent, a video on refresh token would help

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

    Hello Bouali! Great tutorial as always, thank you!
    Quick question: doesn't revoking the user's token on every authentication forbids them to log in to the application in different devices at the same time?

  • @DurgeshChaubey-o2k
    @DurgeshChaubey-o2k Рік тому

    Thank you so much loved the video. I was stuck and looking for a resource. It helped me alot. Love from India

    • @BoualiAli
      @BoualiAli  Рік тому

      Happy to have you here.
      Happy you like my content

  • @amirkenesbay1615
    @amirkenesbay1615 Рік тому

    Wow broooo u r amazing. This tutorial helped me to solve my problem in my project))

  • @НорбертТовт
    @НорбертТовт Рік тому

    Helpful and useful video , but it could be in easier way, you could create a new method called logout , then decode jwt , then change it date and it is all . Your explaining is very clear . Thank you

    • @BoualiAli
      @BoualiAli  Рік тому

      Thanks for the comment.
      Just one question regarding you way of doing it. How would you for the user to update the token? (Token is stored on client side)

  • @bartosztoropolski8191
    @bartosztoropolski8191 Рік тому

    Great tutorial! Will you create video about refresh token?

    • @BoualiAli
      @BoualiAli  Рік тому

      Happy you like it.
      I will soon

  • @migolovach1371
    @migolovach1371 Рік тому

    Very helpful video. I have only one question, maybe I don’t understand something, but why store expired tokens.

    • @BoualiAli
      @BoualiAli  Рік тому

      You remove expired token.
      In a different context. You might use them for auditing and tracing (maybe)

  • @mustafasametsonmez7034
    @mustafasametsonmez7034 Рік тому

    These videos are amazing thanks a lot. I searched many videos about jwt security in java spring boot but they wasn't easy to understand but I can learn easily and clearly with your videos thanks. access and refresh token would be great

    • @BoualiAli
      @BoualiAli  Рік тому

      Thank you for the good feedback.
      I will make a video about refresh token

  • @kevinameda2711
    @kevinameda2711 Рік тому +2

    Thank you brother, this is inspiring and realy helped me a lot thank you. Can you pls help create a lecture for messaging queues like kafka or rabbitMQ? Stay blessed

    • @BoualiAli
      @BoualiAli  Рік тому

      Thank you for the feedback.
      MQ is coming soon

  • @manospat1066
    @manospat1066 Рік тому

    Amazing work! Just a question, why we generate jwt token both in register and the authenticate methods? In my understanding, in register the token is generated and then in each coming request user must pass the jwt token. Also, I thought that one user has only one token associated with him, so the relationship between user-token should be one-to-one and not one-to-many? Thanks

    • @BoualiAli
      @BoualiAli  Рік тому +1

      Totally true what you said.
      Just as I mentioned in the video, it is just for the tutorial to have a token after registration.
      But in real life no need for it.
      Feel free to adjust ass you need

  • @mouradeljayi584
    @mouradeljayi584 Рік тому +1

    Amazing, Thank you and please keep uploading videos like this cause we really learn a lot from you .

    • @BoualiAli
      @BoualiAli  Рік тому +2

      Thanks 🙏
      I will absolutely continue uploading.
      You’re my source of motivation

  • @augustinegoat
    @augustinegoat 3 місяці тому

    Thank you for your tutorial, I have a question that if every time the user authenticates and logs out, the token will be set revoked to false and expired is also false, but if that is the case, the database will contain corrupted fields. It's redundant and makes the database bigger when having to store the data. Can I clean up that extra data?

  • @hamidoubalde2517
    @hamidoubalde2517 Рік тому

    great video @Ali Bouali. I have a question. For you what is best for implementing jwt between custom jwt like you did or use Oath2 resource server which hold jwt implementation. In the last case how to implement logout?
    Thanks

    • @BoualiAli
      @BoualiAli  Рік тому +1

      Both of them are jwt based.
      You can use both of them
      I’m working on a new course that covers both, jwt and oauth 2 with a frontend built with angular.
      I will publish the a waiting list soon enough so you can register and get discount

    • @hamidoubalde2517
      @hamidoubalde2517 Рік тому

      @@BoualiAli thanks

  • @serdarsen6099
    @serdarsen6099 Рік тому

    Thank you so much for this and your other Spring Security videos! Your work is truly wonderful; please keep it up!

  • @balazsvarga4216
    @balazsvarga4216 Рік тому

    I watched also the prev video about JWT. This videos are very straightforward and to the point. Just a little bit remark: why do you use var declaration instead of naming the proper type?

    • @BoualiAli
      @BoualiAli  Рік тому

      It is just shorter to write 😅

  • @adilhanoun975
    @adilhanoun975 2 місяці тому

    Bonjour Mr Bouali j'ai cru comprendre que stocker le JWT en Bdd pouvais être vu comme une mauvaise pratique pour des soucis de performance comment contré cette argument ? MERCI A VOUS

  • @sovannborithyun5205
    @sovannborithyun5205 Рік тому

    Excellence video.
    Would you create a video using Angular to logout?

  • @ramakrishnamogilipuri1647
    @ramakrishnamogilipuri1647 Рік тому

    nice content.thank you

  • @bartdiako1
    @bartdiako1 Рік тому +1

    Thanks Bouali ! this Security vids have been a great help ❤. You are awsome!!! Just wondering if you're going to do a change password vid to? forgotten password and e mail verification ?

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

    Thanks for this video Ali !

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

    i think that in the LogoutService before clearing the SecurityContextHolder, in addition to checking for the existence of the token in our database, we should also check that it's not been revoked or expired.

  • @meetsamseen
    @meetsamseen Рік тому

    Awesome tutorial man! 48:20 was spot on, you got me right there.

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

    16:50 The query will return the tokens for the user that are either not expired or not revoked which means that will include tokens that are expired but not revoked, as well as tokens that are revoked but not expired. Was that the intention or we should return tokens that are neither expired nor revoked?
    For example instead of:
    ```
    where u.id =:userId and (t.expired = false or t.revoked = false)
    ```
    We can return non-expired and non-revoked tokens:
    ```
    where u.id = :userId and t.expired = false and t.revoked = false
    ```

  • @poojabondkar4983
    @poojabondkar4983 7 місяців тому

    Thank you so much AliBou !! This is very helpful. can you make video of logout from Keycloak auth server generating jwt token ?

  • @iivailo94
    @iivailo94 Рік тому

    really useful videos, keep going! I appreciate your course videos

    • @BoualiAli
      @BoualiAli  Рік тому

      I’m really happy that you like my content. This motivates me to create more

  • @usounitedsouls2174
    @usounitedsouls2174 Рік тому

    Amazing video ,it was so helpful,
    My question is why we don't delete the old token instead of setting it expired

    • @BoualiAli
      @BoualiAli  Рік тому

      Thank you.
      You can set a bash script to cleanup the database every period of time.

  • @erichhc9698
    @erichhc9698 Рік тому

    excellent Ali, I don't miss any video I learn a lot from you 😎

    • @BoualiAli
      @BoualiAli  Рік тому

      Happy to know that.
      This motivates me

  • @arohawrami8132
    @arohawrami8132 Рік тому

    Thanks a lot Bouali. It was very beneficial as always. I really admire your high quality work and please continue creating more content.

  • @MuhammadAli-rp9cz
    @MuhammadAli-rp9cz Рік тому

    Hi Bouali - Thanks for the amazing videos on Jwt.
    My question - in the first video, why are you only checking that token belongs to the user and does not expire during validation? Where does the secret key and the signature plays a role during validation?
    Can't i just create my own token and map to a valid and it will still be marked as valid?

    • @BoualiAli
      @BoualiAli  Рік тому +1

      Decoding the token uses the secret that you generated. And it should be a secret of course 😁
      To have your answer, I would ask you to generate a random token with a different secret ( you can use jwt.io website for that) and pass it to the backend and then you will see if it passes or not.
      Reply to this comment with your feedback.
      Looking forward for the result 🤛

    • @MuhammadAli-rp9cz
      @MuhammadAli-rp9cz Рік тому

      @@BoualiAli
      Tested an i got the error io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted.
      It seems like during decoding - it is not base64 decoding the payload - rather decrypting the signature and extracting the subject from their - Thanks, exactly as you said

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

    Thanks for the video!
    Why do you have expired and revoked flags? From my point of view expired flag is useless and confuses, cause token might not be expired but only revoked. It's two independent states.

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

      I mentioned in the video that these flags might be helpful in the future. Maybe not in this tutorial

  • @ElFozter
    @ElFozter Рік тому

    Please create a video of how to implement the refresh token, thanks for your work.

  • @khalilelemam1349
    @khalilelemam1349 8 місяців тому

    why did you use inner join when trying to fetch the tokens in 16.56 ? you can do it without making use of joins !!
    also you said you want the expired and revoked should equal to false and then using or how that?

  • @arsalansarwer
    @arsalansarwer Рік тому

    great tutorial, and code works fine

  • @osekagorska2330
    @osekagorska2330 Рік тому

    Well done, keep up the amazing work!

  • @antoniodevic8704
    @antoniodevic8704 Рік тому

    Thanks for the video, a lot of useful info in it! One question though, is with JWT tokens since they are stateless logout part on backend really necessary? Can it present any security issue or is it just enough to stop user from accessing secured resources if it is handled on frontend, invalidated there or deleted from local storage?

    • @BoualiAli
      @BoualiAli  Рік тому +1

      It is also enough to delete it from local storage in the frontend.
      But this a double check and total logout and revoking the token.
      Many have request such functionality, so I answered the call 😁

    • @antoniodevic8704
      @antoniodevic8704 Рік тому

      @@BoualiAli Thanks for the quick answer! Sure, double check can't definitely hurt :D

  • @sidof8065
    @sidof8065 Рік тому

    Thanks for the tutorial. i have some question
    How allow access to another resource like /api/v1/course when we already been logged (api/v1/auth/) with token. so we will not provide a token any time to another resource ?

    • @BoualiAli
      @BoualiAli  Рік тому

      For secured resources, you need to always pass the token

    • @sidof8065
      @sidof8065 Рік тому

      @@BoualiAli okay sir i noticed

  • @codingsavid6509
    @codingsavid6509 Рік тому

    I have a question, in 43:11 why do you inyect the logouthandler as LogoutHandler and not as the LogoutService?

    • @BoualiAli
      @BoualiAli  Рік тому

      Using the service is safe and make the app loosely coupled.

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

    before watch this video ,after doing the login process and using in my react project and user registre and login ,i save the token in storage to use for others api ,this is good or no ? and when he choose to logout i distroy the token storage.clean()

  • @dinobulja
    @dinobulja Рік тому

    Hello and thank you for your video. In terms of JWT logout, you are assuming we are doing authentication against a database where we record JWT and have a flag indicating if token is revoked meaning user has logged out.
    But more often than not do we use database to record that. Often we authenticate against LDAP, for example. There, we don't have such luxury. How do you logout if we don't have user in a database table or we don't have luxury to touch database and add these fields for tracking JWT revocation?

    • @BoualiAli
      @BoualiAli  Рік тому

      You can use a caching mechanism (redis maybe or even system cache) to store and invalidate tokens.
      But don’t forget to invalidate the token when the application stops (this is the down side of using cache).
      Otherwise you can have a case where a token is still valid for the user but not existing in your cache, you need also to take care of that use case.
      I hope I guided you through what you need

    • @dinobulja
      @dinobulja Рік тому

      I never used redis.
      Is it implemented in the API or client side?
      What if API (or client) is restarted? Does user has to log in again?

    • @BoualiAli
      @BoualiAli  Рік тому

      @@dinobulja redis is also backend
      Q2: depends on your logic, i would say yes user needs to relogin

  • @nikitaalekseev991
    @nikitaalekseev991 Рік тому

    Great tutorial!
    But what is the usage of expired flag in token if we never used it?
    Can't we just get away with revoked flag?

    • @BoualiAli
      @BoualiAli  Рік тому

      It is just for you for maybe some future needs and different logical implementations, otherwise you can rely on one of them

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

    Perfection !!!! 👍

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

      Glad you like it!

  • @GoncaloSilva137
    @GoncaloSilva137 Рік тому +1

    Hi, are we updating the database accessToken expired parameter when the accessTokenExpiration time finish ?

    • @BoualiAli
      @BoualiAli  Рік тому

      I didn’t get your question can you please elaborate more?

  • @MYYJOURNEYS
    @MYYJOURNEYS Рік тому

    How can I implement the same in microservice context..
    Sir.. please do single microservice projects event driven approach ( kafka or saga axon serve)

    • @BoualiAli
      @BoualiAli  Рік тому

      You can implement the security on the gatway level.
      I recommend using OAuth 2 provider like Keycloak (free, open source)
      Regarding event driven approach, it is coming (working on it)

  • @boubacarbarry222
    @boubacarbarry222 Рік тому

    Thank you again, it's very clear !

  • @hafedhbaazouzi3617
    @hafedhbaazouzi3617 Рік тому

    Good Job Thanks

  • @jeanmorisanato6458
    @jeanmorisanato6458 Рік тому

    Thanks for his sweet video

  • @KhalilChargui-jm1fj
    @KhalilChargui-jm1fj 7 місяців тому

    Amazing, Thank you

  • @gabrielmoreno7482
    @gabrielmoreno7482 Рік тому

    Great video! could i replace token with jti?

  • @programming97
    @programming97 7 місяців тому

    great

  • @developers1081
    @developers1081 Рік тому

    Thax Sir Realy Helped

  • @ngozikalu6938
    @ngozikalu6938 Рік тому

    Great great video.
    Quick Question: can't we delete the tokens instead of setting revoked and expired to true? i'm saying this because the table will grow tremendously and that's going to be so much unneeded data. any concern with doing this?

    • @BoualiAli
      @BoualiAli  Рік тому +1

      It is also possible. You can adopt this as solution

    • @khalilmarzouki636
      @khalilmarzouki636 Рік тому

      i think it can be useful if you create a scheduled task that runs every month for example that clear that data .

    • @BoualiAli
      @BoualiAli  Рік тому

      @@khalilmarzouki636 also a good idea 👍

    • @ngozikalu6938
      @ngozikalu6938 Рік тому

      @@khalilmarzouki636 really? But why not immediately? Why do you think we should not remove the token immediately?

    • @khalilmarzouki636
      @khalilmarzouki636 Рік тому

      @@ngozikalu6938 you can do whatever you want, maybe it's good to clear that data immediately, but i think you can find other use for it , maybe use it for keeping trace of users ( when exactly they logged in )

  • @inderpreetsingh5126
    @inderpreetsingh5126 Рік тому

    Thanks and Keep It Up Bro

  • @khalilmarzouki636
    @khalilmarzouki636 Рік тому

    good job, keep going ali 🤩🤩

  • @mdbits
    @mdbits Рік тому

    This was a great add on to the Spring Security with JWT video! Thanks so much! This works great when testing in Postman, but when I test it from a browser (using axios in React) I cannot seem to avoid CORS violations. I can use @CrossOrigin on my REST controllers. Is there a proper way to configure the logout CORS policy?

    • @EagleT869
      @EagleT869 Рік тому +2

      maybe can add this in your security config
      http.csrf().disable().cors().configurationSource(new CorsConfigurationSource() {
      @Override
      public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
      CorsConfiguration config = new CorsConfiguration();
      config.setAllowCredentials(true);
      config.setAllowedOrigins(Collections.singletonList("*"));
      config.setAllowedMethods(Collections.singletonList("*"));
      config.setAllowedHeaders(Collections.singletonList("*"));
      config.setExposedHeaders(Arrays.asList(
      "Authorization", "X-Total-Count", "Link",
      "Access-Control-Allow-Origin",
      "Access-Control-Allow-Credentials"
      ));
      return config;
      }}).and()

    • @BoualiAli
      @BoualiAli  Рік тому +1

      You just need to add a cors bean

  • @monkeybrotha855
    @monkeybrotha855 11 місяців тому

    Thank you very much Bouali for your tutorials, I'm a big fan and they helped me a lot in the past. I have a question though, i've implemented the logout like you did in the tutorial and I'm using an angular client but I'm having trouble to make the post request to /api/auth/logout. Do I need to add thist in my controller? I can not invalidate the usertoken calling from the frontend. Does anyone else had this Problem and can help me out here?

    • @BoualiAli
      @BoualiAli  11 місяців тому

      Can you give more dettails. How you call the endpoint?

  • @coralie5093
    @coralie5093 8 місяців тому

    Thank you. Good job!

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

      Glad it was helpful!

  • @cristiangomez7227
    @cristiangomez7227 Рік тому

    Hello Bouali, Incredible explanation and as always very useful content. So, I have a question: this implementation is solving the Multiple concurrent sessions problem, isn´t it? because I had an ethical hack just a couple of weeks ago and that was one of the problems to solve.

    • @BoualiAli
      @BoualiAli  Рік тому

      Really happy you liked it
      Yes it should

  • @دردشةفيالهوى
    @دردشةفيالهوى 2 місяці тому

    thank you so much