I would like to pre-authenticate requests that are made to a Proxy Feature destination, but I do not know how to return the response from the ProxyRequestFilter:
async void ProxyRequestFilter(IHttpRequest request, HttpWebRequest webRequest)
{
if (!await request.IsAuthenticatedAsync())
{
// Return HttpStatusCode 401 Unauthorized
}
}
Plugins.Add(new ProxyFeature(
matchingRequests: req => req.PathInfo.StartsWith("/proxy"),
resolveUrl: req => $"http://destination")
{
ProxyRequestFilter = ProxyRequestFilter
});
Is it possible to check if the request.IsAuthenticated
and return a HttpStatusCode 401 Unauthorized in the ProxyRequestFilter?