Ocelot API Gateway JWT Authentication Tutorial

Microservices Tutorial Playlist Link: • What are Microservices...
In this video we explains about Ocelot API Gateway Authentication. As this is an Ocelot API Gateway JWT Authentication Tutorial we are implementing, JWT authentication with Ocelot API Gateway.
Ocelot is a .NET API Gateway. This project is aimed at people using .NET running a micro services / service oriented architecture that need a unified point of entry into their system. However it will work with anything that speaks HTTP and run on any platform that ASP.NET Core supports. Ocelot is a bunch of middlewares in a specific order.
Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is retrieved as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features!
There are two sections in the Ocelot API Gateway configuration. An array of Routes and a GlobalConfiguration. The Routes are the objects that tell Ocelot API Gateway, how to treat an upstream request [Ocelot API Upstream]. The Global configuration allows overrides of ReRoute specific settings. It's useful if you don't want to manage lots of Route specific settings.
The main functionality of an Ocelot API Gateway is to take incoming HTTP requests and forward them on to a downstream service [Ocelot API Downstream], currently as another HTTP request. Ocelot's describes the routing of one request to another as a Route.
The DownstreamPathTemplate, Scheme, and DownstreamHostAndPorts make the internal microservice URL that this request will be forwarded to. The port is the internal port used by the service. When using containers, the port specified at its dockerfile.
The Host is a service name that depends on the service name resolution you are using. When using docker-compose, the services names are provided by the Docker Host, which is using the service names provided in the docker-compose files.
DownstreamHostAndPorts is an array that contains the host and port of any downstream services that you wish to forward requests to. Usually this configuration will just contain one entry but sometimes you might want to load balance requests to your downstream services and Ocelot lets you add more than one entry and then select a load balancer. But if using Azure and any orchestrator it is probably a better idea to load balance with the cloud and orchestrator infrastructure.
The UpstreamPathTemplate is the URL that Ocelot will use to identify which DownstreamPathTemplate to use for a given request from the client. Finally, the UpstreamHttpMethod is used so Ocelot can distinguish between different requests (GET, POST, PUT) to the same URL.
What is Docker Compose?
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Docker for .Net Core:
.NET Core can easily run in a Docker container. Containers provide a lightweight way to isolate your application from the rest of the host system, sharing just the kernel, and using resources given to your application. Learn how to use docker for .Net Core and deploy .Net Core to Docker.
.NET Core images
Official .NET Core Docker images are published to the Microsoft Container Registry (MCR) and are discoverable at the Microsoft .NET Core Docker Hub repository. Each repository contains images for different combinations of the .NET (SDK or Runtime) and OS that you can use.
Microsoft provides images that are tailored for specific scenarios. For example, the ASP.NET Core repository provides images that are built for running ASP.NET Core apps in production.
Video Chapters:
0:00 - Video Summary
0:39 - JWT Implementation
8:12 - Authentication Web API
13:14 - Authentication from Services
14:50 - Testing Authentication from Services
16:51 - Authentication from API Gateway
18:51 - Role based Authorization in Ocelot API Gateway
20:33 - Ocelot API Gateway Rate Limiting
#codingdroplets #microservices #apigateway #microservicestutorial #microservice #docker #dotnet6 #dotnet5 #dotnetcore #aspnetcore

Пікірлер: 143

  • @CodingDroplets
    @CodingDroplets Жыл бұрын

    ⭐ Join Us on Patreon: www.patreon.com/CodingDroplets Microservices Tutorial Playlist Link: kzread.info/dash/bejne/mYR90M2Fc8nHnKg.html

  • @robdev1
    @robdev1 Жыл бұрын

    Brilliant tutorials on Jwt. I was struggling to find examples of how to integrate Microsoft Identity with Jwt and Gateways/Microservices. You're an absolute life saver!

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching the video and for leaving such a positive comment. I'm delighted to hear that the tutorial was helpful.

  • @yasirzafar3106
    @yasirzafar310611 ай бұрын

    Thank you so much, best series on microservices well done, your videos are to the point and you well described real world scenarios, I really appreciate your tremendous efforts.

  • @CodingDroplets

    @CodingDroplets

    11 ай бұрын

    Thank you for your kind words and positive feedback! We're delighted to hear that you enjoyed our microservices series and found the content valuable. Your appreciation motivates us to continue delivering concise and practical videos.

  • @MrDpk27
    @MrDpk27 Жыл бұрын

    Thanks! Loved your series on microservices .

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Glad to hear it!

  • @OmesaHD
    @OmesaHD8 ай бұрын

    it takes great understanding to make tutorials this concise and clear. props to you man, thanks a lot truly. this will pass my uni semester lmao

  • @CodingDroplets

    @CodingDroplets

    8 ай бұрын

    Glad to hear that you found the tutorial helpful, and I appreciate your kind words!

  • @--Mr.Bombastic--

    @--Mr.Bombastic--

    4 ай бұрын

    ​@@CodingDropletsThank you, I had been searching for the past 2 days on how to use authentication in other microservices, I was distressed. Thank you for your help. May God keep you happy always.

  • @noranora847
    @noranora847Ай бұрын

    Great tutorial! Thank you so much for sharing. This series has been so helpful for starting with microservices.

  • @CodingDroplets

    @CodingDroplets

    Ай бұрын

    Thank you for your kind words! Glad to hear that.

  • @iamaashishpatel
    @iamaashishpatel10 ай бұрын

    Awesome tutorials! Concise and to the point!

  • @CodingDroplets

    @CodingDroplets

    10 ай бұрын

    Glad it was helpful!

  • @HirenPatel-or7po
    @HirenPatel-or7poАй бұрын

    Wonderful series! Very well explained! Cleared my all doubts! Please keep up the good work!

  • @CodingDroplets

    @CodingDroplets

    Ай бұрын

    Thank you so much for your feedback and kind words!

  • @ziedkefi146
    @ziedkefi146 Жыл бұрын

    Dear sir , Thank you very much for your continuous efforts to share knowledge . All the respect 🙏

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thanks and welcome

  • @narenderjaswal
    @narenderjaswal Жыл бұрын

    Thank you so much sir for providing the best tutorial on this platform, when first i started i didn't thought that it would be worked on my case but it did work without any single error thank you so much.

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You're welcome! I'm glad to hear that you found my tutorial helpful and that you were able to apply it successfully to your own project without any issues. Thank you for taking the time to leave such a positive comment, it means a lot to me. If you have any questions or there's anything else I can help you with, feel free to let me know. Thanks again!

  • @narenderjaswal

    @narenderjaswal

    Жыл бұрын

    @@CodingDroplets sir i want to know how i can set admin and user both to use "Get" method in Role based authentication

  • @AzwihangwisiMagoda
    @AzwihangwisiMagoda Жыл бұрын

    This was super helpful. Thank you!

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Glad it was helpful!

  • @ugochukwuumerie6378
    @ugochukwuumerie6378 Жыл бұрын

    Great content 👌, learnt alot today. Keep it up

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you! Glad to know you liked it.

  • @user-sj2gr4se6c
    @user-sj2gr4se6c Жыл бұрын

    Thank you! Excellent content!

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are welcome. Glad to know you liked it!

  • @merlinsantiago9153
    @merlinsantiago9153 Жыл бұрын

    Great content!Thank you from Perú

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are most welcome. Glad to know you liked it!

  • @codeskol954
    @codeskol954 Жыл бұрын

    good one for the professional approach

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thanks!

  • @Chapali9a
    @Chapali9a Жыл бұрын

    Excellent tutorial. Thank you

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching my tutorial on Ocelot API Gateway and for taking the time to leave a comment. I'm thrilled to hear that you found the tutorial helpful! It's always great to receive feedback and know that my content is making a positive impact. If you have any suggestions or topics you would like me to cover in future videos, please don't hesitate to let me know. Thank you again for your support and I hope to continue creating helpful content for you and others in the future.

  • @baharehbahadorani6218
    @baharehbahadorani621811 ай бұрын

    Thank you for this very useful video.

  • @CodingDroplets

    @CodingDroplets

    11 ай бұрын

    You're very welcome! Glad to hear that you found the video useful.

  • @DavidDanosTech
    @DavidDanosTech11 ай бұрын

    Thanks a lot. Great Project !!!!!!!!!!!!

  • @CodingDroplets

    @CodingDroplets

    11 ай бұрын

    Thank you so much for your enthusiastic comment! Glad to hear that you found the project great and valuable.

  • @user-qr7vv5xn4j
    @user-qr7vv5xn4j Жыл бұрын

    I've been looking for it for a long time. Thank u very much.

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are welcome. Glad to know it helped.

  • @syedshiblimahmud5391
    @syedshiblimahmud5391 Жыл бұрын

    you are awesome 💖 thank you so much

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are welcome! Glad to hear that.

  • @nesrinyildirim7676
    @nesrinyildirim7676 Жыл бұрын

    Thank you for sharing❤

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are so welcome

  • @ahmedaljazzar5313
    @ahmedaljazzar5313 Жыл бұрын

    Great Video! i wish if you can do another one to describe how we can use the scope and how the internal service can communicate with each other with the authentication

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Great suggestion! Will do it soon.

  • @fadygamilmahrousmasoud5863
    @fadygamilmahrousmasoud5863 Жыл бұрын

    you are amazing and i really appreciate the efforts you put in this content 💗, i want to ask you if this is the last video on this series or you will upload more videos ? Than you again.

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    I can say that there is no end for a series. We may upload new videos to in any series. Technology is developing. New things will come up. We'll create new videos in each series.

  • @mac653
    @mac65310 ай бұрын

    Great content... Just two questions when is the front end coming and why didn't you use a Message Queuing service like RabbitMQ?

  • @golig-hx9rp
    @golig-hx9rp Жыл бұрын

    nice video...👍👍👍

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank You!

  • @YaSiRaRaFaTdoTNet
    @YaSiRaRaFaTdoTNet Жыл бұрын

    Thanks for the tutorials! Your videos are concise but to the point! What is your total plan to complete the series and by when?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Hello .. There is no end for a series.. We might add new videos in each series. please do follow us and stay updated

  • @ferosekhan1704
    @ferosekhan17044 ай бұрын

    Bravo, excellent, marvelous. I had watched the microservice playlist. Got an overview of microservice and its implementation along with JWT authorization. Its great, I have a doubt. How do you merge the multiple database result into single API. Lets say i would like to get a report on Order based on company, product and order date range. Since Database are seperate how do you merge them and show it to single API result.

  • @vijukgl
    @vijukgl3 ай бұрын

    Amazing! I must say wonderful tutorial. full API package. I'm looking forward for implementation of an API in Azure docker. please kindly share the video link if you already made it!

  • @CodingDroplets

    @CodingDroplets

    2 ай бұрын

    Thank you for your kind words! I'm glad you found the tutorial helpful. I haven't made a video specifically on deploying a .NET Core API to Azure using Docker yet, but I'll definitely consider it for a future video.

  • @user-vf3su9bj2c
    @user-vf3su9bj2c Жыл бұрын

    Thanks for all your tutorials. I just had a couple of questions" How to you add multiple Roles for "RouteClaimsRequirement"? How do you provide policy based Authentication in Ocelot?

  • @robdev1

    @robdev1

    Жыл бұрын

    Ocelot doesn't support comma separated roles at this stage: Solutions: stackoverflow.com/questions/65649254/how-to-allow-multiple-roles-to-access-route-through-routeclaimsrequirement github.com/ThreeMammals/Ocelot/issues/1460 stackoverflow.com/questions/60300349/how-to-check-claim-value-in-array-or-any-in-ocelot-gateway

  • @guillermomazzari4983
    @guillermomazzari4983 Жыл бұрын

    Thanks for the series, I've watched all the videos until now, regarding your question, I prefer to apply it on the API gateway, I feel the whole project is more secure that way, and the code is cleaner, you can configure everything from the ocelot file, IMO, that's much better. I have a question, will you be adding more videos to this series? Like message bus and/or GRPC

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are most welcome! We used to add videos to existing serieses. For gRPC, we have a seperate series. Please find the below URL. kzread.info/dash/bejne/qmGf1tmGhLGWido.html

  • @guillermomazzari4983

    @guillermomazzari4983

    Жыл бұрын

    @@CodingDroplets Thanks dude! I really learned a lot from this series!

  • @jstoturial9293
    @jstoturial92936 ай бұрын

    Thankx pro But i have one quetion When i have admin who have changable permission How i can make authorization handler ?

  • @muhammadhabib63
    @muhammadhabib636 ай бұрын

    thank you so much, loved this entire series, I was wondering if you are planning to continue it or not ? rabbit mq, service discovery for communication b/w microservices can be a good choice for next few videos. one particular confusion I had is if we are suppose to do the authentication in API gateway , why did you create a separate class library for jwt authentication , is there any particular reason or benefit for that ?

  • @CodingDroplets

    @CodingDroplets

    5 ай бұрын

    Thank you for your feedback and I'm delighted to hear that you enjoyed the series! I'm always considering new topics for future videos, and your suggestions for RabbitMQ and service discovery for microservices communication are excellent ideas that I'll certainly take into account. Regarding the separate class library for JWT authentication, it's a great practice for modularizing code and promoting reusability. By encapsulating the JWT authentication logic in a separate library, such as the AddCustomJwtAuthentication extension, we can easily reference it in multiple projects without duplicating code.

  • @jessandgary5940
    @jessandgary5940 Жыл бұрын

    Doesn't adding the authentication project as a dependency in each microservice kind of defeat the purpose here? Is there a way to do this where the Authorisation service, gateway service and other service do not share dependencies and are completely separate projects?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Two options are explained in the video. The second option only needs the dependency in the API Gateway.

  • @khanfaizan05
    @khanfaizan059 ай бұрын

    Thank you so much , great content. I have a question though. I have microservices altogether as separate projects, implemented api gateway also a separate project , ready and deployed in azure web service app I am thinking of creating a jwt authentication project in the api gateway project . So that i api gateway can access jwt services to generate access token. Also makes it easy to make use of your second approach of authenticating in gateway mode , then only allowing authenticated requests to respective microservice.. Please tell me is this a good way of implementing this architecture in this use case. Thanks

  • @CodingDroplets

    @CodingDroplets

    8 ай бұрын

    Thank you for your positive feedback, and I'm glad you found the content helpful! Your plan to create a JWT authentication project within the API Gateway project and have the API Gateway handle the generation of access tokens is a valid and commonly used approach in microservices architectures. However, please ensure that you implement proper security practices.

  • @khanfaizan05

    @khanfaizan05

    8 ай бұрын

    ​​@@CodingDropletsthanks for your reply. Can you tell me how to implement role based Authorization for the same

  • @Danielflores-nh8rg
    @Danielflores-nh8rg Жыл бұрын

    very good content, it would be perfect if you taught how to deploy that project in ec2 or some orchestrator

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    This video is part of a series (link below). In some previous videos we've explained about the deployment. kzread.info/head/PLzewa6pjbr3JQKhB_U_FiuYwQC70i-TyU

  • @rekhaopteamize7407
    @rekhaopteamize7407 Жыл бұрын

    How you deploy this project to Azure Docker Containers. If possible Please make a video. Thanks.

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Will do it soon. Thanks

  • @sujilkumart9874
    @sujilkumart9874 Жыл бұрын

    Nice topic I have one issue my web api already integrated with windows authtcation if I configure ocelot it always throw 401 error any solution for it?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching my video on Ocelot API Gateway and leaving a comment. I'm glad you found the topic interesting. Regarding your issue with Windows authentication and Ocelot, I understand that you are experiencing 401 errors after configuring Ocelot. This issue could be related to the way you have configured Ocelot and Windows authentication. First, make sure that you have correctly configured Ocelot to work with Windows authentication. You may need to set the correct authentication options in your Ocelot configuration file. Also, ensure that your API is configured to accept requests with Windows authentication. If you have verified that your configuration is correct, another issue that could be causing the 401 errors is the way that the authentication is being propagated through Ocelot to your API. Ocelot passes the authentication token through as a bearer token by default, but Windows authentication uses a different authentication method. You may need to implement a custom middleware to handle the Windows authentication token. I recommend reviewing the Ocelot documentation and troubleshooting guides to help you diagnose and resolve this issue.

  • @Duat72
    @Duat72 Жыл бұрын

    In Customer Controller on the action GetCustomers() if I Put [Authorize(Roles = "Administrator")] or [Authorize(Roles = "Administrator,User")] Token not work, i am getting a permission error from ocelot : message: 403 (Forbidden), if I leave[Authorize] it works why?

  • @Duat72

    @Duat72

    Жыл бұрын

    found on my own in the construction of the token "Role" must be lowercase "role"

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Hope the issue is cleared. The source code is available in the below github repo. github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @Duat72

    @Duat72

    Жыл бұрын

    @@CodingDroplets thanks, I had already downloaded the source, right in the source I found this error : "Role" must be in lower case "role" otherwise it doesn't work on the controller

  • @abdulmussavir4627
    @abdulmussavir4627 Жыл бұрын

    Hi, This tutorial is very helpful for Docker implementation. However, when I tried implementing the code on Windows Docker, I encountered an error. Could you please share the content of the Docker Compose YML file for Windows Docker?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching my tutorial on Ocelot API Gateway Authentication in Docker, and I'm glad to hear that you found it helpful for Docker implementation. Regarding your question, I apologize for the inconvenience caused by the error you encountered while implementing the code on Windows Docker. Unfortunately, I did not create a separate Docker Compose YML file for Windows Docker as I did the tutorial on a Linux-based docker container. However, you can try adapting the existing Docker Compose YML file to work with Windows Docker by making any necessary adjustments, such as changing the path separators from forward slashes to backslashes. If you encounter any further issues or have any other questions, please don't hesitate to reach out to me. I'll do my best to help you with your Docker implementation. Thanks again for your comment, and I hope you find the information provided useful.

  • @abdulmussavir4627

    @abdulmussavir4627

    Жыл бұрын

    @@CodingDroplets Okay Got it Thank you.

  • @andrecruz1965
    @andrecruz19657 ай бұрын

    Hello, Thank you for this video, very good. I do have a question, I'm using .NET 8 , and when I use app.UseAuthentication() , all requests come with 401 Unauthorized, but If I remove it, it behaves as expected (I receive 401 Unauthorized if a request has invalid JWT or no token). Can useAuthentication() interfere? Should I remove it? Or is that a bad practice for Production-code ? Thank you so much for your videos. Subscribed!

  • @CodingDroplets

    @CodingDroplets

    7 ай бұрын

    Thank you for your positive feedback and for subscribing! I'm glad to hear that you found the tutorial helpful. If you're facing challenges where all requests result in a 401 Unauthorized, it's essential to review your authentication setup. Check the authentication configuration, token validation logic, middleware order, and introduce logging for troubleshooting. For additional reference and to compare your implementation, you can find the source code for the tutorial on GitHub: github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @andrecruz1965

    @andrecruz1965

    7 ай бұрын

    @@CodingDroplets Thank you so much for your response!

  • @CodingDroplets

    @CodingDroplets

    7 ай бұрын

    You're very welcome!

  • @valeantigot6390
    @valeantigot6390 Жыл бұрын

    Hey! great videos! are you also on audea???

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank You! Not in audea

  • @alejandrocan3445
    @alejandrocan3445 Жыл бұрын

    Greate tuto, thanks! Have you any repository of this solution? Thank you again!

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Most welcome. Thank you for sharing your feedback. Below is the repository URL. github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @sara99-ip3zg
    @sara99-ip3zg Жыл бұрын

    thank you for the tutorial, I was following your steps but it got to the docker orchestrator support step and I don't know how to proceed, I didn't use docker in my project (im planing on doing it later) , can this tutorial work for me without using docker or should I just give up? it's really sad I allready got to the middle of the video

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching the tutorial and for your question. I understand that you have reached the part where Docker orchestration is introduced, but you haven't used Docker in your project yet. Don't worry, you can still continue with the tutorial even if you're not using Docker at the moment. The Docker orchestration part is an optional step that showcases how to deploy the Ocelot API Gateway in a containerized environment. If you're not using Docker right now, you can simply skip that step and proceed with the rest of the tutorial. The tutorial will still be applicable and helpful for you to understand the concepts of Ocelot API Gateway and JWT authentication. You can focus on implementing the authentication and authorization mechanisms within your project without Docker.

  • @sara99-ip3zg

    @sara99-ip3zg

    Жыл бұрын

    @@CodingDroplets thank you so much for your reply, yes I managed to follow the video and I implemented the Api Gateway and authentication mechanism, Im going to use a db to fetch user accounts instead of hard coding them, but I have an issue if you kindly give me your guidance on it, I want to implement a sign up mechanism but my app will have 2 users (admin and user) , how should I go about this theoretically? It doesn't seem right to include the role in the registration, also should I change the userAccount class attributes to have some other data from registration (name, surname etc) or create another class userRegistration that handles that data and populate the relevant data (username, password) into userAccount, i would appreciate it very much if you help me with this and thank you again

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for your feedback and for sharing your progress with the tutorial. I'm glad to hear that you were able to follow the video and implement the API Gateway and authentication mechanism successfully. Regarding your question about implementing a sign-up mechanism with two user roles (admin and user), here are a few suggestions: Separate User Roles: You can consider creating a separate field or property in the user account model to indicate the user's role. During the sign-up process, you can provide an option for the user to choose their role (admin or user). This way, you can differentiate between the roles and apply the appropriate authorization rules in your application. User Account Attributes: If you need additional information such as name, surname, or any other data during the registration process, you can either add those attributes directly to the user account class or create a separate class for user registration that captures the additional information. Then, you can populate the relevant data (such as username and password) into the user account object. It's important to design the registration process in a way that aligns with your application's requirements and security considerations. Consider factors such as data validation, authentication, and authorization when implementing the sign-up mechanism. I hope these suggestions provide some guidance for your implementation. If you have further questions or need assistance with any specific aspect, feel free to ask. Good luck with your project, and thank you for your support!

  • @sara99-ip3zg

    @sara99-ip3zg

    Жыл бұрын

    @@CodingDroplets Thank you so much for your swift reply, I think I will let the user choose his role from a dropdown menu, and I will just add the relevant registration data to the UserAccount (it seems simpler + I may need to fetch the additional data in the authen response and display it in the user profile in my front app) , I have an additional "stupid" question if I may trouble you further, will adding an Id attribute to the userAccout entity class affect the authentication logic or cause any errors? because as the UserAccount will now have a table users I plan to add this line to it ( [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } ), is this the right approach ?

  • @sara99-ip3zg

    @sara99-ip3zg

    Жыл бұрын

    @@CodingDroplets hello again sir, im having an error about the usage of a scoped service (JwtAuthenticationManager.Data.ApplicationDbContext) within a singleton service (JwtAuthenticationManager.JwtTokenHandler), does making jwtAuthManager a scoped service instead of singleton a good solution ? It works but chatGpt told me about thread issues and I worry a problem might come out of this later, so sorry for the inconvenience and thank you again

  • @rinshima
    @rinshima7 ай бұрын

    I have a few questions.: 1) Where should I do the user registration logic, in Authentication Web Api or Jwt Authentication Manager? 2) How can I get a UserId from a jwt token in other APIs, for example? 3) How should my other application receive a new token after the expiration of the previous token? 4) Where should I store the jwt token in the application, for a long time for frequent reuse?

  • @CodingDroplets

    @CodingDroplets

    7 ай бұрын

    Great questions! I appreciate your engagement with the tutorial. Here are some brief answers: 1) User registration logic is typically handled in an authentication service. 2) You can include the User ID in token's claims. In your other APIs, you can use retrieve the User ID from Claims. 3) When a token expires, the client needs to request a new one. You can implement refresh token if needed, so that the client don't need to authenticate frequently using user name and password. 4) You can store JWT tokens securely in the client application using mechanisms like browser storage (localStorage or sessionStorage) for web applications. For mobile or desktop apps, consider secure storage options like Keychain (iOS) or Keystore (Android). Always prioritize security and avoid storing sensitive data in an insecure manner.

  • @rinshima

    @rinshima

    7 ай бұрын

    @@CodingDroplets Thanks for the answer, a new question has appeared, how in JwtAuthenticateManager can I get a database from Environment if I can't add it to docker? Can I make this UserAccount search logic from the database in the Authentication Web Api controller, and not in the JwtAuthenticationManager, and transfer the already found UserAccounts there?

  • @CodingDroplets

    @CodingDroplets

    7 ай бұрын

    Certainly! It sounds like you want to handle the UserAccount search logic from the database in the Authentication Web API controller rather than in the JwtAuthenticationManager. This approach is absolutely valid, and you can pass the already found UserAccounts to the JwtAuthenticationManager. By separating the database retrieval logic into the Authentication Web API controller, you keep your concerns neatly organized. This approach allows for more flexibility and easier testing.

  • @rinshima

    @rinshima

    7 ай бұрын

    @@CodingDroplets Thank you for your help, you explain very well.

  • @CodingDroplets

    @CodingDroplets

    7 ай бұрын

    You are welcome!

  • @evgeniilewicki5874
    @evgeniilewicki587421 күн бұрын

    This is certainly cool when you have one microservice. But when there are many of them? Write everything in one ocelot file? Wouldn't it be too much with 20 microservices? Can you show me how to deal with this? Or is this something you can’t do?

  • @CodingDroplets

    @CodingDroplets

    20 күн бұрын

    That's a great question! Managing multiple microservices in a single Ocelot configuration file can be overwhelming. A better approach is to break the configuration into smaller, more manageable files. This way, each microservice has its own configuration file, making it easier to maintain and scale.

  • @evgeniilewicki5874

    @evgeniilewicki5874

    20 күн бұрын

    ​@@CodingDroplets Yes, but how to work with these files? After all, you can connect only two ocelot files. There is no documentation on this issue. How to work, for example, with such a hierarchy of ocelot.Cashboxes and nested within it is ocelot.Cashboxes.Numeric and so on. And so, let's say three or more files with attachments.

  • @waquarkhan1649
    @waquarkhan1649 Жыл бұрын

    Can we create frontend for this architecture in angular?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Yes, you can

  • @waquarkhan1649

    @waquarkhan1649

    Жыл бұрын

    @@CodingDroplets Do you have any reference video of it.

  • @samehhakim4340
    @samehhakim4340 Жыл бұрын

    Thank you for this playlist but i've question : if we update or refactoring any api what about the inserted data on databases ? - we must update code any time as customer requests without remove any inserted data, what can we make it ? finaly many thanks for this playlist

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    In docker, we can create volume for DB folder.

  • @marghuburrahmanansari4952
    @marghuburrahmanansari49526 ай бұрын

    Please make a video on the service registry with microservices using .netcore web api.

  • @CodingDroplets

    @CodingDroplets

    6 ай бұрын

    Thank you for your suggestion! I'll definitely consider creating a tutorial on service registry in the context of microservices.

  • @marghuburrahmanansari4952

    @marghuburrahmanansari4952

    6 ай бұрын

    @@CodingDroplets Thanks

  • @anneemojo
    @anneemojo Жыл бұрын

    did somebody actually make it work using the second method and not injecting the handler into the microservices?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching the video. The source code for the project explained in the video is available on GitHub (github.com/codingdroplets/OcelotAuthenticationAndAuthorization), and I encourage you to refer to it for further guidance and to try it out for yourself. If you have any further questions or concerns, please do not hesitate to let me know. Thank you again for your interest in the tutorial and for taking the time to leave your comment.

  • @MrAngel750
    @MrAngel7509 ай бұрын

    why U don't use the authentication filter sir why only authorization,

  • @CodingDroplets

    @CodingDroplets

    9 ай бұрын

    Thank you for your question! In the tutorial, the focus was on demonstrating authorization with Ocelot API Gateway. However, incorporating authentication filters is indeed an essential aspect of building a secure API gateway. I'll certainly consider it for future content. Authentication filters in Ocelot can be applied to validate and authenticate incoming requests. They are typically used to check credentials, tokens, or other authentication mechanisms before requests are further processed.

  • @MrAngel750

    @MrAngel750

    9 ай бұрын

    @@CodingDroplets Thank you sir

  • @CodingDroplets

    @CodingDroplets

    9 ай бұрын

    Welcome

  • @user-uw3mb5ct9y
    @user-uw3mb5ct9y9 ай бұрын

    hi, I'm trying to implement the authentication, It will be really helpful if the code used in this video can be shared

  • @CodingDroplets

    @CodingDroplets

    9 ай бұрын

    Certainly! I appreciate your interest in the code. You can find the source code used in the tutorial on GitHub. Here's the link to the repository: github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @user-uw3mb5ct9y

    @user-uw3mb5ct9y

    9 ай бұрын

    Thank you so much, it will really help.@@CodingDroplets

  • @CodingDroplets

    @CodingDroplets

    9 ай бұрын

    You're very welcome!

  • @alexei6557
    @alexei6557 Жыл бұрын

    Has anyone received 401 unauthorized despite providing a token when retrieving customers?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    In the demo application, token validity is assigned as 20 mins. Hence you'll get Unauthorized response if the token is expired. Please find the source code in the below Github url. github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @kalpeshdave3980

    @kalpeshdave3980

    Жыл бұрын

    Yes

  • @asalam345
    @asalam345 Жыл бұрын

    Thanks a lot. Could you plz share your source code also.

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @dmitriikonshin9725
    @dmitriikonshin9725 Жыл бұрын

    it will be great if you shared github repository

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @dmitriikonshin9725

    @dmitriikonshin9725

    Жыл бұрын

    @@CodingDroplets Thank you very much for tutorial. Great job!

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You are welcome

  • @Gimmiyimmy
    @Gimmiyimmy Жыл бұрын

    Please share github url for reference

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @riddhidave3023
    @riddhidave3023 Жыл бұрын

    Can you provide github link or source code?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You can find the source code in the below URL. github.com/codingdroplets/OcelotAuthenticationAndAuthorization

  • @riddhidave3023

    @riddhidave3023

    Жыл бұрын

    Thank you

  • @berkslv
    @berkslv Жыл бұрын

    Thanks for not sharing code

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Source Code is available in our Github Repo: github.com/codingdroplets/OcelotAuthenticationAndAuthorization