proudmonkey / ApiBoilerPlate

A simple yet organized project template for building ASP.NET Core APIs in .NET Core 3.1
MIT License
361 stars 77 forks source link

Use Middleware instead of DelegatingHandlers #13

Closed Reckonian closed 4 years ago

Reckonian commented 4 years ago

Great job with this project! Its saving me a good bit of time and sanity.

However, I am noticing that the DelegatingHandler isn't being called. Which means the authorization process via IdentityServer4 isn't functioning as expected.

See: https://www.dotnetcurry.com/aspnet-mvc/1149/convert-aspnet-webapi2-aspnet5-mvc6

proudmonkey commented 4 years ago

Hi @Reckonian,

I'm not sure if I'm following you correctly, but the DelagatingHandler for invoking the IDS4 will be invoked once you've setup the HttpClient typed instance. You can see how it is binded here: https://github.com/proudmonkey/ApiBoilerPlate/blob/master/ApiBoilerPlate/Infrastructure/Installers/RegisterApiResources.cs#L51

Also, the link you've provided is 5 years old and there are lots of changes that was happening in ASP.NET Core between those period. In short, what you've read there "might" be outdated.

Here's an article I've posted a few Months ago that might be useful in this context. https://vmsdurano.com/apiboilerplate-and-identityserver4-access-control-for-apis/

Thank you for your feedback.