How To Build Your Own JWT Authentication With Spring WebFlux And Spring Security

  Рет қаралды 7,752

Alex Gutjahr

Alex Gutjahr

Күн бұрын

Пікірлер: 36
@alexgutjahr
@alexgutjahr Жыл бұрын
Grab the code here axgr.dev/posts/spring-security-jwt/?
@felipeserrano9173
@felipeserrano9173 2 жыл бұрын
Like somebody would said: "Work like a charm" -Thank you a lot Alex!
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Thanks Felipe, happy to hear that!
@ridhopratama9639
@ridhopratama9639 Жыл бұрын
Your /login implementation is great♥👍. Whats your opinion about handle /login in different way??. It goes to Manager (to validate username & password) and then going to Provider (to forming jwt). So no need to define /login in controller. That is how I am doing right now but not sure it is good or bad implementation. Because AFAIK in non-webflux security, there is no controller /login needed. So I think it should have same flow with non-webflux.
@alexgutjahr
@alexgutjahr Жыл бұрын
Hey there, good question! If I were to do it again, I probably would do as you suggested: route all authentication matters to the AuthenticationManager and have a specific AuthenticationProvider since this is the correct way of doing it. In this video you can also see this flow kzbin.info/www/bejne/f2iVnYeYZ7RrotU
@jirivrba3800
@jirivrba3800 2 жыл бұрын
Thanks Alex, really educative and well presented content, helped me a lot
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Thanks Jiří, appreciate the feedback!
@ismaild.7766
@ismaild.7766 2 жыл бұрын
Thank you for the amazing job. I also want to see you coding spring webflux security using graphql and explaining how to react when the jwt token expires. Thank you.
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Thanks İsmail, noted! I have tutorials on GraphQL coming up and will also certainly record a follow-up to JWT authentication!
@borispliss3238
@borispliss3238 2 жыл бұрын
Hi Alex. Thank you so much for such a clear example. I have some trouble with your code example. When an exception happens while a token is analyzed I receive a 401 HTTP error with the header "WWW-Authorization=Basic realm ...". How can I cause to it to send me the www-autorization=bearer?
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Thank you for watching and sharing your feedback, Boris!
@guruprashanth_k
@guruprashanth_k 3 жыл бұрын
@Alex - This is useful to get started. It would be helpful you had covered Oauth2 - Authorization Server, Oauth2 - Resource Server and Oauth2 protected REST resources seperately. If this is too much of asking then ignore :)
@alexgutjahr
@alexgutjahr 3 жыл бұрын
Thanks mate, I'll definitely cover it in a dedicated video!
@faithfulolaleru7255
@faithfulolaleru7255 2 жыл бұрын
are you using record or something new from java 17? Coz the syntax was throwing me off
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Yeah, I am not using Java at all - this tutorial makes use of Kotlin for the programming language.
@Trigoter
@Trigoter 3 жыл бұрын
Hello, when I add firebase auth, the library does not appear. When I add storage, the library appears. Am auth does not appear. Help
@alexgutjahr
@alexgutjahr 3 жыл бұрын
Thanks for your comment! Please note that Firebase is a different matter to what I have done in this video since Firebase is providing and validating the tokens. It goes beyond of this tutorial, but I will record a dedicated video showing how to make use of Firebase in Spring Boot.
@awaisrashid1479
@awaisrashid1479 2 жыл бұрын
how can we throw custom exception when we get token-expired or invalid-signature
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Hey Muhammad, you can define your own exception like I have done here github.com/alexgutjahr/yt/blob/4308e482193e6f26573937a5474224b5459e440f/spring-jwt-auth/src/main/kotlin/com/alexgutjahr/Authentication.kt#L54
@josemendoza7317
@josemendoza7317 Жыл бұрын
hello alex, can you please do it for java
@alexgutjahr
@alexgutjahr Жыл бұрын
Hey man, sorry, but I stopped writing Java code a long time ago and will only focus on Kotlin whenever I do Spring tutorials.
@minicomponent6377
@minicomponent6377 2 жыл бұрын
Thanks a lot
@wayurachatlapkern8152
@wayurachatlapkern8152 2 жыл бұрын
Thx you Alex
@alexgutjahr
@alexgutjahr 2 жыл бұрын
My pleasure!
@АлександрБугримов-о1е
@АлександрБугримов-о1е 3 жыл бұрын
Super
@alexgutjahr
@alexgutjahr 3 жыл бұрын
Thanks!
@taochen6491
@taochen6491 2 жыл бұрын
Hi Alex I tested, the parser of jjwt can automatically throw "io.jsonwebtoken.ExpiredJwtException" when token is expired, so it's unnecessary to check it by user.
@alexgutjahr
@alexgutjahr 2 жыл бұрын
Awesome, didn't know that - thanks for sharing!
@massiveblackwood
@massiveblackwood 3 жыл бұрын
this wont work if i using oauth2.resourceserverspec.jwt
@alexgutjahr
@alexgutjahr 3 жыл бұрын
Thanks for the comment and yes, there may be issues when you use this or other packages since I did not use them in my example so the code must be most likely changed for those packages.
@massiveblackwood
@massiveblackwood 3 жыл бұрын
I think its the reactiveauthenticationmanager thing, i tried by force them to authenticate with onerrorrrsume the continuing jwt authentication i dont feel if its right.. have u tried to combine it? Using custom jwt along with resourceserverspec? it would be great tortorial videos since i havent found one yet
@alexgutjahr
@alexgutjahr 3 жыл бұрын
@@massiveblackwood thanks for the feedback! No, I have not yet tried to combine the approaches, but added it to my backlog as a follow-up video.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Neptune : The Windows XP's Prequel
15:00
Everything Windows
Рет қаралды 2,5 М.
Factorio teaches you software engineering, seriously.
21:27
Tony Zhu
Рет қаралды 2 МЛН
How To Set Up Cors With Spring Security And Spring Boot
13:04
Alex Gutjahr
Рет қаралды 12 М.
Reactive Programming with Spring Boot | A Beginner's Guide
40:31
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,2 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН