abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.74k stars 3.41k forks source link

Setting up customer interceptors in conjunction with dynamic C# proxies #19442

Open karlschriek opened 5 months ago

karlschriek commented 5 months ago

Is there an existing article or article request for this?

Describe the article you'd like

I am looking for documentation that would explain how to do the following (in my opinion fairly straightforward) usecase:

  1. Register two dynamic c# http client proxies, e.g. one for "FoobarService" and one for "BazbarService" (presumably using AddHttpClientProxies. The service "MyEntryService" will interact with these to services in the back. The user with authenticate against "MyEntryService"
  2. Create a custom interceptor, which will intercept outgoing requests, fetch the existing "Authorization" header from httpContext, and append it to the outgoing request.
  3. Attach that interceptor only to "FoobarService". I.e., for "BazbarService" we do not wish to add this header.

I am fairly certain I need to implement an "AbpInterceptor" for this (or more specifically, override the DynamicHttpProxyInterceptor) and then I need to attach it specifically to FoobarService

maliming commented 5 months ago

hi

Maybe you can override the IRemoteServiceHttpClientAuthenticator to fetch the existing "Authorization" header from httpContext, and append it to the outgoing request.