Skip to content

Distributed tracing and metrics are not emitted on redirects with custom ICredentials #115938

@antonfirsov

Description

@antonfirsov

There is an overlook in the code that disables auth for redirects with custom ICredentials:

if (settings._allowAutoRedirect)
{
// Just as with WinHttpHandler, for security reasons, we do not support authentication on redirects
// if the credential is anything other than a CredentialCache.
// We allow credentials in a CredentialCache since they are specifically tied to URIs.
HttpMessageHandlerStage redirectHandler =
(settings._credentials == null || settings._credentials is CredentialCache) ?
handler :
new HttpConnectionHandler(poolManager); // will not authenticate
handler = new RedirectHandler(settings._maxAutomaticRedirections, handler, redirectHandler);
}

In case settings._credentials is not a CredentialCache we pass an HttpConnectionHandler to RedirectHandler to be used on redirects. This will opt out from the previously configured handler chain in the method, which unfortunately also includes MetricsHandler and DiagnosticsHandler, not only HttpAuthenticatedConnectionHandler.

This bug has a very limited impact.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions