ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.4k stars 1.64k forks source link

I'm New to Ocelot And Most of the Documentation Seems Out of Date #988

Closed RobKraft closed 8 months ago

RobKraft commented 5 years ago

I could really use an API Gateway and what I read about Ocelot is very promising, but I think a recent release of Ocelot has caused most of the documentation to be irrelevant.

1) Logging - I figured out how to turn on logging.AddConsole(), but don't see how I can now use NLog for logging.

2) Authentication. I picked Ocelot because we use Identity Server, but the IdentityServer examples in the documentation no longer compile. I can't figure out what package or using statement to add to use a method like AddIdentityServerAuthentication. I'll admit I am a n00b to Microsoft Middleware. So maybe that is why it is taking me many hours to figure out how to add a working line of code to Ocelot, but before I spendt a few more days trying to get that line to work I thought I'd see if there was newer documentation somewhere, or if perhaps direct support for IdentityServer had been deprecated. My current authorization code does not compile but I haven't figured out why. It is very basic in Program.cs: .ConfigureServices(s => { s.AddOcelot(); s.AddAuthentication("CS"); }) and in ocelot.json: "UpstreamHttpMethod": [ "Get", "Post", "Options" ], "AuthenticationOptions": { "AuthenticationProviderKey": "CS", "AllowedScopes": []

thiagoloureiro commented 5 years ago

Hi Rob, can you share your code/repo here in GitHub? (If it’s possible) I can take a look Thanks

Sent from my iPhone

On 13 Aug 2019, at 12:12 am, RobKraft notifications@github.com wrote:

I could really use an API Gateway and what I read about Ocelot is very promising, but I think a recent release of Ocelot has caused most of the documentation to be irrelevant.

Logging - I figured out how to turn on logging.AddConsole(), but don't see how I can now use NLog for logging.

Authentication. I picked Ocelot because we use Identity Server, but the IdentityServer examples in the documentation no longer compile. I can't figure out what package or using statement to add to use a method like AddIdentityServerAuthentication. I'll admit I am a n00b to Microsoft Middleware. So maybe that is why it is taking me many hours to figure out how to add a working line of code to Ocelot, but before I spendt a few more days trying to get that line to work I thought I'd see if there was newer documentation somewhere, or if perhaps direct support for IdentityServer had been deprecated. My current authorization code does not compile but I haven't figured out why. It is very basic in Program.cs: .ConfigureServices(s => { s.AddOcelot(); s.AddAuthentication("CS"); }) and in ocelot.json: "UpstreamHttpMethod": [ "Get", "Post", "Options" ], "AuthenticationOptions": { "AuthenticationProviderKey": "CS", "AllowedScopes": []

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

RobKraft commented 5 years ago

Thanks for the quick response. Here are the files. I have changed very little from the default so far. This is using the Nuget for Ocelot 13.5.2 APIGateway.zip

thiagoloureiro commented 5 years ago

Hi @RobKraft thanks for sharing the files.

Can you take a look in my repo? I've just updated to 13.5.2 and it's working fine.

You can use it as a start point (remove consul stuff if you don't need it!)

https://github.com/thiagoloureiro/APIGatewayOcelot

Cheers mate.

RobKraft commented 5 years ago

Thank you sir, that is working for me after I modeled your repo. I removed the value from my AuthenticationProviderKey, which I don't expect to need anyway: "AuthenticationProviderKey": ""

raman-m commented 8 months ago

Great success story!