twitchax/AspNetCore.Proxy

Is there exmaple using your proxy with JWT? I want to check the auth in the proxy like api gateway

Closed this issue · 4 comments

Is there exmaple using your proxy with JWT? I want to check the auth in the proxy like api gateway

Currently, no, but you could suggest an example.

You likely want to use this example.

.WithBeforeSend((c, hrm) =>
        {
            // Set something that is needed for the downstream endpoint.
            hrm.Headers.Authorization = new AuthenticationHeaderValue("Basic");

            return Task.CompletedTask;
        })

@twitchax how can we implement the above example?

basically i want to pass token with all the request
something to compliment
app.RunProxy(proxy => proxy.UseHttp("http://google.com"));
In essence, I aim to forward all requests as they are, but with the addition of an authentication token. Could you please provide some suggestions or guidance on how to achieve this? Thank you

Yep, basically, you use the example from the README. The way ASP.NET works is that you can do pretty much whatever you want with the context in here.

app.RunProxy(proxy => proxy
    .UseHttp((context, args) =>
    {
        // Check the auth token here by inspecting `context.Request.Headers` (or something like that).

        return "http://myhttpserver.com";
    });

Thank you so much @twitchax 👯‍♂️