Video není dostupné.
Omlouváme se.

Spring Cloud API Gateway | JWT Security | Pass UserDetails to Microservices | JavaTechie

Sdílet
Vložit
  • čas přidán 28. 04. 2023
  • In this Tutorial, we will understand How to pass authentication user information from Spring cloud api gateway to other microservices
    #javatechie #microservice #security #jwt
    Spring boot microservice Premium course lunched with 70% off 🚀 🚀
    Hurry-up & Register today itself!
    COURSE LINK : javatechie5246...
    PROMO CODE : JAVATECHIE50
    Join this channel to get access to perks:
    www.youtube.co...
    Microservices Security Using JWT | Spring Cloud Gateway
    • Microservices Security...
    GitHub:
    github.com/Jav...
    Blogs:
    / javatechie
    Facebook:
    / javatechie
    guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
    Disclaimer/Policy:
    --------------------------------
    Note : All uploaded content in this channel is mine and its not copied from any community ,
    you are free to use source code from above mentioned GitHub account

Komentáře • 109

  • @impertator644
    @impertator644 Před rokem +7

    Great content. It would be also great to see, how to integrate this authentication with frontend, I mean for example, how to handle loging. And also how to handle "log once".

  • @ntjoel19
    @ntjoel19 Před 6 měsíci +2

    I appreciate the content and the architecture. Thank you for the video. For a better scalability, separation of concerns, security enforcement, I thing you can totaly seperate the gateway with the authentication by making the authentication service an independant microservice.

    • @Javatechie
      @Javatechie  Před 6 měsíci

      Yes that's what we need to play with identity services from gateway

    • @saqlainmirza9644
      @saqlainmirza9644 Před 5 měsíci +1

      @@Javatechie please make this

  • @MAMUNGM
    @MAMUNGM Před rokem +3

    Thank you so much to add this requested content

  • @MAMUNGM
    @MAMUNGM Před rokem +2

    Thanks to you for adding this. How to configure the cors origin configuration in api-gateway and auth microservice?

  • @Adventurevictoria
    @Adventurevictoria Před měsícem

    is this an excellent idea? pour all the security logic into the gateway which is the busiest service for routing the message that can cause potential bottlenecks for the entire service? and make all sub-microservices open up with as naked? the main job of gateway is routing the messages to the proper microservice. you could implement basic token validation here since it will cut down all unnecessary burdens in earliest point but securityfilter in gateway shouldn't be much heavy like this .

  • @RahulKumar-qu1if
    @RahulKumar-qu1if Před rokem +6

    Hi , can you please make a video on how to integrate both Oauth2 and jwt in a single application

    • @Javatechie
      @Javatechie  Před rokem +4

      Okay i will

    • @pranoydas9654
      @pranoydas9654 Před rokem

      ​@@Javatechiesir, have you created the video of Oauth2 and JWT in a single application?

  • @jimiotulana2546
    @jimiotulana2546 Před rokem +4

    Thanks a lot, very informative, however, I was wondering if the restaurant API had been using a role-based control how do you pass the user role such that the endpoint can only honor the request if the user has the right permission

    • @Gabrysia445
      @Gabrysia445 Před rokem

      maybe you could pass this in the same manner that user name was sent? Add a header "userRoles" with role as a value in the gateway

  • @siddharthshitole7574
    @siddharthshitole7574 Před rokem +2

    Hi Techie, I really love your content, requesting you to make a series on code review. it will be helpful for everyone

    • @Javatechie
      @Javatechie  Před rokem

      Yes it's on my queue buddy soon i will do that

  • @southcroydon7462
    @southcroydon7462 Před 15 dny

    Hi, which video has API Gateway details ? not sure I understand AbstractGatewayFilterFactory

  • @dineshpanigrahi1065
    @dineshpanigrahi1065 Před rokem +3

    Hi @JavaTechie,
    Can you please make a video explaining to prevent direct calls to microservices, we should access the microservices only through the api gateway, and role based authorization in continuation of the spring cloud api gateway | JWT Security video

    • @Javatechie
      @Javatechie  Před rokem

      Yes interesting. I will give it a try

    • @dineshpanigrahi1065
      @dineshpanigrahi1065 Před rokem

      @@Javatechie Thank you . Can we have a video in continuation to this video ASAP

  • @hduy8536
    @hduy8536 Před 5 měsíci

    You can make a video to decentralize permissions. For example, if the user does not have permission to access service A, it will be denied.

  • @ngonimugandani4504
    @ngonimugandani4504 Před 3 měsíci +1

    This is awesome

  • @aadiraj6126
    @aadiraj6126 Před rokem +2

    What is the industry best practices? Details are passed through header or request body?

    • @Javatechie
      @Javatechie  Před rokem

      Yes we can pass as part of the header not an issue it won't be visible to outside calls. Request body needs to use when we have to pass multiple fields or object

  • @nadigatlapraveen4681
    @nadigatlapraveen4681 Před 4 měsíci +1

    Hi sir, can you please make a video on role based spring boot microservices security

  • @Virat77799
    @Virat77799 Před 4 měsíci

    How rolebased authorisation happens witn this architecture..please make a video of it. How any rest end point will give access to only admin or role ?

  • @viacheslav_chudnovskyi
    @viacheslav_chudnovskyi Před rokem +1

    Is it considered a bad practice to set Authentication in the SecurityContextHolder in the API gateway to make it accessible from a controller in another service?

  • @cevinananda1639
    @cevinananda1639 Před 9 měsíci +2

    very good tutorial, but i have a question. The services is secure if we access it from the api gateway, but it have no secure system when we try access it directly from the service (without using api gateway endpoint). My question, is there any ways to make the services only can be access from the api gateway and can't be access from the service directly. Thank you

    • @Javatechie
      @Javatechie  Před 9 měsíci

      That is why we are using gateway to make a single entry point to our application so if you won't expose microservice endpoints then the user won't access it .

    • @cevinananda1639
      @cevinananda1639 Před 9 měsíci +1

      thank you for your fast response. Forgive me, I am new to this microservices thing. I just knew that when we already at the deployment phase, we can make the service only accessible by the api gateway and block any other request that's not from the api gateway.
      good tutorial and very helpful person, thank you very much

  • @gamingbeast710
    @gamingbeast710 Před 8 měsíci +1

    aswome

  • @maantram
    @maantram Před 7 měsíci

    We have Zuul proxy and spring boot 2.1.x and implemented resourceserverconfig adapter. Now we have upgarding to spring boot 3.2.0 and cloud gateway. What is the equalent implementation for resourceconfigadaptor

  • @akshaynilkanth9671
    @akshaynilkanth9671 Před rokem +2

    Hi Brother,
    I guess we need not do that because when the request is forwarded the SecurityContextHolder object already has user details int it.........after learning from your previous video i implemented the same architecture and tried it

    • @Javatechie
      @Javatechie  Před rokem

      Yes that's correct but in each microservice i shouldn't add security dependency to just fetch the user info

    • @akshaynilkanth9671
      @akshaynilkanth9671 Před rokem +1

      @@Javatechie Yes indeed......thanks for all your tutorials.....you have no idea how much it has helped me to build my career

    • @Javatechie
      @Javatechie  Před rokem +1

      Glad to hear this Akshay . Keep learning 😃

  • @rahulvijay1781
    @rahulvijay1781 Před rokem +1

    Awsome javatechie can u implement oauth2 in api gateway ?

  • @hkkabir2024
    @hkkabir2024 Před 3 měsíci

    i have checked in the gateway it's not possible to use RouteValidator class "/auth/**" it's not working. would u like to findout the solution

  • @Prakash-gz6py
    @Prakash-gz6py Před rokem +1

    Hi, I’m curious to know about your mac experience. Is it good for development? Which MacBook you are using, please? Is it worth to buy? Planning to buy but not sure with performance!! Thanks.

    • @Javatechie
      @Javatechie  Před rokem

      Mac for development is superb and can't compare with any other OS. Without any second thought go ahead with it .
      I am using both Mac desktop and mac pro laptop 💻 . It's amazing 😍

  • @cd62
    @cd62 Před rokem +1

    Hi @Java Techie, Thank you for such great content.
    Sir, how to handle if api gateway go down? In this conditions I need to create cluster for this.
    Can you create a video to explain if possible?
    Thanks for support

    • @Javatechie
      @Javatechie  Před rokem

      Hi buddy, usually in real-time we do follow multiple instances for service as a replica, in case of region instance goes down then immediately traffic should redirect to active instance and to achieve this usually we do need to configure proper DR (disaster recovery)

  • @walterricardoforerosanchez8461

    Thanks for the content ❤
    What is the name of the app next to the configuration?

  • @pranoydas9654
    @pranoydas9654 Před rokem +2

    Sir, can you make a video of role based authentication like user role , admin role etc ? Using JWT

    • @Javatechie
      @Javatechie  Před rokem +1

      Role base i am also struggling to find a solution. Will definitely update you

  • @MEGANE34
    @MEGANE34 Před rokem +1

    Hi Java Techie, Thank you for great content.can make spring boot project for deploying azure with jenkins pls

    • @Javatechie
      @Javatechie  Před rokem

      Azure doesn't have much experience but will check and update you

    • @MEGANE34
      @MEGANE34 Před rokem +1

      @@Javatechie Thank you, i am looking forwad 😳😳

  • @anupamupadhyay826
    @anupamupadhyay826 Před rokem +2

    Hi @Java Techie, thank you for sharing such valuable content. I have a question: could you please help me understand the process of implementing method-level role-based authorization in a Swiggy microservice? While I'd prefer not to use Keycloak, I'm interested in any references or guidance you could provide to achieve this. For instance, I'm curious about effectively utilizing the @PreAuthorize annotation in a Swiggy microservice

    • @Javatechie
      @Javatechie  Před rokem +1

      That's tough to implement i am working on a poc once it is done i will upload

    • @hieunghiemxuan3992
      @hieunghiemxuan3992 Před 3 měsíci

      Hi @@Javatechie, I went through your series about Auth in microservice and I couldn't find the videos about role-based authorization. I mean the next video of this one. Did you already upload it?

    • @Javatechie
      @Javatechie  Před 3 měsíci

      Not uploaded yet buddy

  • @karthicks2198
    @karthicks2198 Před 9 měsíci +1

    Hi, But still need to product other micro services right, between micro services communication how to secure? Without using api gate still you can access directly other micro service, it should required security right?

    • @Javatechie
      @Javatechie  Před 9 měsíci

      Simple answer why will you expose other microservices direct endpoint? What is the need for an api gateway then ?

  • @collinstamaletalemwa6218
    @collinstamaletalemwa6218 Před 7 měsíci +1

    Great tutorial!
    Although, what is the best way for one to secure the microservices as well? Since they only appear secure when accessed through the gateway, but one does not need to be authorised to access the microservices directly

    • @Javatechie
      @Javatechie  Před 7 měsíci

      If you will allow user to directly access to microservices then what is the need of api gateway it doesn’t make any sense right because we are bypassing the flow

    • @collinstamaletalemwa6218
      @collinstamaletalemwa6218 Před 7 měsíci +1

      @@Javatechie it is not a matter of giving users access, but it turns out to be a big security concern once anyone decides to attack you. There is no point of defense at all

    • @Javatechie
      @Javatechie  Před 7 měsíci +1

      Okay if forcefully you want to secure then you need to implement security in each and every microservices that is what I can think at this moment. Will check and update if there could be any better approach

  • @AbhishekSharma-jg2ow
    @AbhishekSharma-jg2ow Před rokem +1

    Hi @Java Techie, Thank you for such great content.
    Sir, I came across a question in an interview and was still unable to find a suitable solution, I will be grateful if you can make a small video on this. I believe this may require generics, recursion or reflection concepts. WAP to compare if two arguments are equal, they can be anything primitive, Array, Map, Collection or custom objects, and the input param type is Object. Ex, isEqual(Object arg1, Object arg2). As per the question, we don't have knowledge of the input provided.

    • @amjadali3601
      @amjadali3601 Před rokem +1

      We can do this using generic method if all the Class that we need to compare implements Comparable interface

    • @Javatechie
      @Javatechie  Před rokem

      Good question i believe we can directly play with object but will check and update

  • @hoanganhtuan7266
    @hoanganhtuan7266 Před rokem

    Hello , my identity-service is not working properly, after running all service 15' it works. Please show me how to configure that, thank you !

  • @robinrajlouis9183
    @robinrajlouis9183 Před 5 měsíci

    How to handle Authorization (role based Authorization)?

  • @anilkumarraju8839
    @anilkumarraju8839 Před rokem +2

    Hi bro nice can we expect Saga pattern implementation video bro

    • @Javatechie
      @Javatechie  Před rokem

      Hi Anil Kumar , please check this video it's already there in the channel czcams.com/video/6O5iJ7PKUhs/video.html

  • @srinukumbam6918
    @srinukumbam6918 Před rokem +1

    Hi Bro,
    Thank you for This content, and it is very much useful for every java developer.
    And my question is here restaurant service also authorised service if swiggy service want to call restaurant service like using RestTemplate, how we have to pass the token since the request will directly go to gatway. Is it As you explained in above or any other way?

    • @Javatechie
      @Javatechie  Před rokem

      Swiggy service needs to pass a token to access restaurant service using rest template headers

    • @srinukumbam6918
      @srinukumbam6918 Před rokem +1

      @@Javatechie Thank you bro.

  • @user-yd6zf5kf5l
    @user-yd6zf5kf5l Před 9 měsíci

    Hi @Java Techie, Thank you for This content, and it is very much useful for me, But How Swagger calls works in this case. Can you pls add that also..

  • @saurabhtandel3332
    @saurabhtandel3332 Před rokem

    How to exclude some API from applying Jwt in the headers.

  • @ratnajiguptha5643
    @ratnajiguptha5643 Před rokem

    Hi , can you make a video implementation of oauth and sign with different platform like google, Facebook, github .

  • @sujeetsharma9976
    @sujeetsharma9976 Před rokem

    Hi Java Techie, Can you make a video on logout that makes Jwttoken expired in microservice.

  • @BrilliantMindsZw
    @BrilliantMindsZw Před rokem +1

    Thank you, do you have any audit implementation?

    • @Javatechie
      @Javatechie  Před rokem

      Audit implementation using spring security?

  • @slogger5033
    @slogger5033 Před 7 měsíci +1

    I am getting a forbidden error after following the above video, Can anyone please tell what can be possible scenarios to look into it?

    • @Javatechie
      @Javatechie  Před 7 měsíci

      You might have made some mistake please import the code and try again

  • @arpit1145
    @arpit1145 Před rokem

    Better approach is use two way TLS or A2A cert .

  • @SanjayKumar-di5db
    @SanjayKumar-di5db Před rokem +2

    there is security vulnerability in this way, if client adds the same header in the request then micro services might read the header added by the client and not the gateway so need to block the header coming from the client either at infra level like nginx or cloudfront or need to put check on gateway itself that if client sending any of these headers then forbidden

    • @Javatechie
      @Javatechie  Před rokem

      Not getting you Sanjay , what do you mean by client here ?

    • @SanjayKumar-di5db
      @SanjayKumar-di5db Před rokem

      In detail all headers in http could be a list of values and gateway is adding some headers and hacker can add the same headers then there is a chance that micro service side the header it reads is coming from hacker

    • @Javatechie
      @Javatechie  Před rokem

      Okay got you.then we can mask it and pass

    • @deviprasadhota2617
      @deviprasadhota2617 Před rokem

      Great one... One question how to enable cors cor support host header?

    • @deviprasadhota2617
      @deviprasadhota2617 Před rokem

      Just encountered like problem.. Can you tell me how I can support host header for my api... Now its forbidding the host header. One of our client wants to access the api by giving its endpoint.

  • @sk-ip4md
    @sk-ip4md Před rokem

    Hi, Can you please make a video on Oauth2 + webclient+ token uri?

  • @ashishmishra2346
    @ashishmishra2346 Před 10 měsíci

    how routing will be done if url of swiggy-service(host1:port1) and restaurant-service(host2:port2) is different

  • @vinodhreddy6227
    @vinodhreddy6227 Před rokem +1

    U can cover roles to access the rest endpoint

    • @Javatechie
      @Javatechie  Před rokem

      No but this is not the way to maintain Authorization. I will upload that video

    • @vinodhreddy6227
      @vinodhreddy6227 Před rokem +1

      @@Javatechie ok, identity service we can't add roles and services we can use ryt?

    • @Javatechie
      @Javatechie  Před rokem

      You can add roles in identity service but in other microservices to use this role for Authorization bit tricky

    • @vinodhreddy6227
      @vinodhreddy6227 Před rokem +1

      @@Javatechie cover that topic also, thanks

  • @logic_master950
    @logic_master950 Před rokem

    Hi sir, can you create a video on how to to password reset using mail api.

  • @kmiiloberrio-dev
    @kmiiloberrio-dev Před rokem

    How to deploy in aws this distributed system?

  • @user-te2wj9ng9z
    @user-te2wj9ng9z Před rokem +1

    I got the problem while I try it using Postman, it's send me a message : An expected CSRF token cannot be found

    • @Javatechie
      @Javatechie  Před 11 měsíci

      Disable it

    • @user-te2wj9ng9z
      @user-te2wj9ng9z Před 11 měsíci

      @@Javatechie how i did'nt understand, i have disable the csrf in auth-service

    • @Javatechie
      @Javatechie  Před 11 měsíci

      I have done this in securityFilterChain please check and do the same

    • @user-te2wj9ng9z
      @user-te2wj9ng9z Před 11 měsíci +1

      @@Javatechie thank you, i didn't check it before. Now its work

  • @mohdshahrukh6176
    @mohdshahrukh6176 Před rokem +1

    Sir career related kuch guidance milskti hae?

    • @Javatechie
      @Javatechie  Před rokem +1

      Drop me an email to javatechie4u@gmail.com

  • @sagar8964
    @sagar8964 Před rokem +1

    how To disable direct access to microservice & allow only though api gateway?

    • @Javatechie
      @Javatechie  Před rokem +1

      Yes that's what the gateway pattern

    • @sagar8964
      @sagar8964 Před rokem

      @@Javatechie can you please make a tutorial on it?? Also how to use preAuthorize in swiggy controller?

  • @vamshibyagari5986
    @vamshibyagari5986 Před 11 měsíci +1

    08:31 why's this crying😂

  • @tendaikawadza4492
    @tendaikawadza4492 Před rokem

    i need support on one of my api to do this

  • @mrowox
    @mrowox Před 9 měsíci

    Is it possible to pass a user object instead of the username. For example, I might need the email, username, and role of the user. Also how to I restrict API endpoints bu roles and permissions

    • @Javatechie
      @Javatechie  Před 9 měsíci +1

      I don't think we can pass an object directly in the header but you can pass multiple key and value

    • @mrowox
      @mrowox Před 9 měsíci +1

      @@Javatechie so how can I use something like @AuthenticatedPrincipal or annotations like @hasRole and @hasAuthority in the respective microservices?

    • @Javatechie
      @Javatechie  Před 9 měsíci

      I still have not found the solution for role based Authorization in this approach. Looking into it m