Тёмный

How to SECURE My Microservices Architecture (REACTJS + SPRING CLOUD GATEWAY) With Keycloak 

The Dev World - by Sergio Lema
Подписаться 13 тыс.
Просмотров 21 тыс.
50% 1

Опубликовано:

 

21 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 93   
@manee427
@manee427 Год назад
Finally, find what I looked for. Really thanks and perfect video. keep doing more please
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thank you for watching! I will keep doing more video. Don't forget to share to channel to your network 😅
@katacode
@katacode Год назад
Thank you very much. You explain very complicated things in very clear language
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thank you! I try my best
@damjuve13
@damjuve13 Год назад
now i know how to implement pkce authorization with react ! thanks !
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Glad it helped you!
@daniellaerachannel
@daniellaerachannel Год назад
in your project you're still on version 2.7.1; any update concerning spring 3.0.2 and keycloak? thanks
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Oh, didn't see that. I will update it in the repository.
@wanggewg
@wanggewg 3 месяца назад
Could you please make video to demo BFF pattern ( Backend for FrontEnd). BFF is thought more secure than PKCE flow.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 3 месяца назад
I first need to investigate a little bit more about it
@Mateusz-dl1mr
@Mateusz-dl1mr Год назад
Great tutorial! But I have one question, what if there is multiple backend resources? Do i need to add security config in each microservice?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Yes, all the resources servers you have need the configuration to be able to talk with Keycloak.
@Mateusz-dl1mr
@Mateusz-dl1mr Год назад
@@TheDevWorldbySergioLema ok but what if there is for example 50 resources that have to be secured? Copy paste code in each? 😅
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Yes 😅. But you can also add a Config Server, ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-p65u4t26BBc.html
@Mateusz-dl1mr
@Mateusz-dl1mr Год назад
@@TheDevWorldbySergioLema I see but it wouldnt be better to configure api gateway as resource server and there provides configuration to secure some of services? It seems to be best solution if Spring Cloud Api Gateway is an entry point
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
You're right, i will try to implement this solution
@PatrikM
@PatrikM Год назад
Hey Sergio, thanks for a great tutorial. I've been looking for one covering both a backend and frontend connected to keycloak. I was wondering how you would implement redirect when logging out? As of this tutorial the logout button works but it doesn't take you back to the index page. I've been trying to use your solution for the signin callback, but with no luck. How would you implement the callback for logout?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Hi Rekishi, thanks for your interest. I didn't try to the logout, but it's a good question. Did you check the settings of the frontend oidc-client library post_logout_redirect_uri (github.com/IdentityModel/oidc-client-js/wiki)? Maybe just adding this configuration when creating the frontend client is enough. If that's the case, let me know your feedbacks.
@PatrikM
@PatrikM Год назад
@@TheDevWorldbySergioLema Thanks for the quick reply. I managed to solve it for now by adding the "post_logout_redirect_uri:" field to settings when creating the UserManager, then setting the same url in Keycloak and copying your signin-callback.html page and remaking it for using "signoutRedirectCallback()"
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Glad it worked so easily!
@treefrog9392
@treefrog9392 Год назад
How do you allow post requests using this keycloak flow? I am always getting back a missing csrf token error. Any idea how to configure this or to disable csrf?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
To allow the POST requests, make sure to allow the CORS in the application.yml of the Gateway. About the CSRF, I din't anything particular, it was disable by defautl.
@codingstyle9480
@codingstyle9480 Год назад
Hi, It seems, in this scenario, the role of the cloud gateway api is just to convey the request to different resource server(backend resources) endpoints? It has no contribution to the security. Here the first line of action takes place with the user requesting the react frontend, which redirects the user to keycloak login page if the user not logged in? In some scenarios where the cloud gateway is a part of the security and is the first line of action, and its called BFF(backend for front end) , if I am not mistaken. Is that right?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Yes, in this scenario the backend is acting as a BFF, you're right. The security is split between the frontend (as the client server) and the private backend (as the resources server). The API gateway is only there to redirect the requests
@techlead_ashu
@techlead_ashu 7 месяцев назад
TUSM. Great content. Just one thing - you have been writing OIDC, Open ID Connect ... but you pronounce OI-SEE-d, lol xD
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 7 месяцев назад
😂 Yes, I saw that when writing the subtitles
@poomc5462
@poomc5462 Год назад
Really great tutorial! Is there a way to create my own React login screen that could be used with keycloak? Thanks!
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thanks! Yes you can create your own React login page. Then, in Keycloak, you can select the login page where the user will be redirected.
@AlexanderKurguzkin
@AlexanderKurguzkin Год назад
Thank you, very useful!
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thank you!
@stanleynyekpeye5318
@stanleynyekpeye5318 2 месяца назад
Thanks for the video. However, I have a question. Is there a way to login to keycloak without redirecting to the keycloak login page? I have a custom login screen in my ReactJS app and I want to make use of it instead.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 2 месяца назад
Yes, you can configure a custom login page in Keycloak
@stanleynyekpeye5318
@stanleynyekpeye5318 2 месяца назад
@@TheDevWorldbySergioLema Ok. How do I go about it?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 2 месяца назад
I didn't try it, but this seems to be what you're looking for: www.baeldung.com/keycloak-custom-login-page
@cyper0418
@cyper0418 Год назад
Agree, I think resource server brings us too much overhead given microservices in reality hides behind the gateway and frontend cannot access it directly. So I would like to see a solution where we only parse the token in gateway once via some filter. And then pass the the resolved userId to microservcies through some http header(Not pass token, this way we don't need to set each and every micro-service as a resource server.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Yes, I will try to implement this way. I've already done something similar, with a single JWT, but not with OAuth2 and Keycloak.
@istvanduro3394
@istvanduro3394 Год назад
Hy! Any update on this? Sorry for bothering you.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
It's planned, but i didn't started yet
@rajeevjayaram4981
@rajeevjayaram4981 Год назад
Great Video. It helped me a lot...We are planning to use Spring 3.1 Authorization server . I am tryin to use the React Code to connect to Spring Auth server. Login Screen is comming and the login is successful.. but in the end I am getting the following error in the signin-callback.html : No matching state found in storage. Could you please tell me how to fix this issue. With Keycloak it is fine....Thanks
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thank you Rajeev. I've been looking around and found this information (github.com/IdentityModel/oidc-client-js/issues/1044). It seems to be the cookies.
@maxi331
@maxi331 8 месяцев назад
Hello! i'm trying to replay this situation and i have a CORS issue. Any idea?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 8 месяцев назад
Do you use the Spring Cloud Api Gateway? Or directly Spring Security? If you use Spring Security, check this other video where I configure the CORS: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-phs90_s0Mjk.html
@andreamonte851
@andreamonte851 Год назад
Hi! I have a doubt. I have a Web site that must access protected API. I have a Spring Cloud gateway and some microservices and here I implemented the authorization based on roles.. Now I followed the way to register the Gateway as confidential client on Keycloak and store in it client_id and secret_id. I was wondering if this way was better and what the differences were. Thanks
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Using the authentication with Keycloak is very useful if you have many different applications (clients) which need this same authentication. If you only have one application (client), maybe putting all the authentication logic inside may reduce the complexity. But, using Keycloak is using a string authentication system, OAuth2. Which was tested for many years. Using you own authentication system means that you must take care of the security breaches. What I recommend? It depends on you (and your team): * if you need the same authentication system for many application -> use Keycloak * if you don't know much about security breaches or authentication systems -> use Keycloak * otherwise -> use a simple authentication system inside you already existing application Hope this will help you
@andreamonte851
@andreamonte851 Год назад
@@TheDevWorldbySergioLema what the client scope is for? Is it mandatory?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
It's not mandatory. You can let the value to profile, name, email or openid. It says what kind of information you want to fetch from the User's profile.
@rustemzinnatullin6941
@rustemzinnatullin6941 4 месяца назад
ITM - Всем здарова! Вам тоже сложно даются видосы на инглише?
@arunadl143
@arunadl143 9 месяцев назад
great tutorial!!.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 9 месяцев назад
Thank you!
@jonathanmoore4837
@jonathanmoore4837 3 месяца назад
Thanks for video
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 3 месяца назад
Hope it helped you!
@techlead_ashu
@techlead_ashu 7 месяцев назад
Thank you so much :)
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 7 месяцев назад
I'm so glad you liked it!
@ismailforeveryone6889
@ismailforeveryone6889 Год назад
Good job keep going
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thank you!
@poseidonzf
@poseidonzf Год назад
Could gateway be also a resource server so it can validate tokens? In my case I get Cors error: Missing allow origin header in preflight request, I already tried several ways to enable Cors with no luck.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Yes, someone already told me about this alternative. I will try to make another video with this solution. About the CORS problem, you must configure them in both the api gateway and keycloak. Try with different browsers (sometimes they act differently).
@mariomatejovic2190
@mariomatejovic2190 Год назад
Hey , have you been able to mange that cors issue ?
@sinanbenlibas161
@sinanbenlibas161 10 месяцев назад
So can I login without redirecting?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 10 месяцев назад
Do you mean having a login form integrated inside the frontend without the redirection to the login page of Keycloak?
@sinanbenlibas161
@sinanbenlibas161 10 месяцев назад
@@TheDevWorldbySergioLema just like you said
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 10 месяцев назад
I don't if configuring a custom login page in Keycloak is enough. I never did it, so I can't tell you if it works.
@sinanbenlibas161
@sinanbenlibas161 10 месяцев назад
@@TheDevWorldbySergioLema thank you i have last question You have installed keycloak legacy version . Would it be a problem if we use the release version?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 10 месяцев назад
I don't thing there is much difference
@telongrestur9110
@telongrestur9110 Год назад
logout redirect not working??
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
I didn't try the logout. Have you any message describing the error? Or nothing is shown?
@telongrestur9110
@telongrestur9110 Год назад
@@TheDevWorldbySergioLema Like logout was working but it was not redirect back to app, I have to set post logout redirect url and it worked. Thanks for the video.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Thanks for your feedback!
@cristianpadilla2069
@cristianpadilla2069 Год назад
Hi sergio, have a question, what about registration?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
It must be done directly in Keycloak.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
You can see it in this video, ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-YHWfJHKGYGI.html
@cristianpadilla2069
@cristianpadilla2069 Год назад
@@TheDevWorldbySergioLema thanks sergio, so every user that wants to use my application must first register on keycloak? let´s say an E-comerce
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Yes, that's the goal of an SSO, you use keycloak just to sign, not to register. If you want to register the users in your application and manage their accounts, it's another authentication system you need
@EugeneZimin
@EugeneZimin 6 месяцев назад
Video is nice, but if you had less content switched back and fort to your face - it would be way better.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema 6 месяцев назад
Some parts need more explanations, some parts are just coding. I explain while what I'm doing in a more dynamic way than just talking in front of a screen for 5 minutes I'm sorry, but that's my way to do videos
@DivinePositives
@DivinePositives Год назад
If possible to rubyonrails
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
Oh no! Please, no, not rubyonrails
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
😅🙏
@ThePazuzu
@ThePazuzu Год назад
Why do all keycloak teachers think we all use java?
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
🤣 In fack, my channel is mainly about Java, and I've done a few videos with Keycloak. Which language are you looking for?
@ThePazuzu
@ThePazuzu Год назад
@@TheDevWorldbySergioLema I'm a Rails or Express guy so maybe JavaScript or Ruby.
@ThePazuzu
@ThePazuzu Год назад
@@TheDevWorldbySergioLema the keycloak documentation is terrible and I've wasted weeks trying to figure out how to integrate a rails api with a react frontend with keycloak. One of the worst documented projects I've ever seen.
@TheDevWorldbySergioLema
@TheDevWorldbySergioLema Год назад
It's not well documented. But once you've started and configured Keycloak, what you need to know is the OAuth2 protocol with whatever language.
Далее
Keycloak и Spring Security
37:37
Просмотров 14 тыс.
She Couldn’t Believe I Did This! 😭 #shorts
00:12
Microservices explained - the What, Why and How?
18:30
Просмотров 873 тыс.
Microservices Explained in 5 Minutes
5:17
Просмотров 770 тыс.