Skip to content

[QUESTION] Access token masking for OpenTelemetry Monitor #49112

Open
@dzejsien

Description

@dzejsien

Library name and version

Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0"

Query/Question

Hi,

I have issue with the access token which is exposed in logs, for the SignalR related requests.

builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
{
    options.ConnectionString = appInsightsConnectionString;
});

In application insights, I can see access_token under "request" and "traces" tables.

I tried to write Processer, but no luck with that

public class MaskingTelemetryProcessor : BaseProcessor<Activity>
{
    public override void OnEnd(Activity data)
    {
        if (data.Kind == ActivityKind.Server)
        {
            var queryString = data.GetTagItem("url.query") as string;

            if (!string.IsNullOrEmpty(queryString) && queryString.Contains("access_token"))
            {
                Console.WriteLine(queryString);
                var queryParameters = System.Web.HttpUtility.ParseQueryString(queryString);

                if (queryParameters["access_token"] != null)
                {
                    queryParameters["access_token"] = "***";
                    data.SetTag("url.query", queryParameters.ToString());
                }
            }
        }

        base.OnEnd(data);

Please, help to understand how to filter out the access token.

Btw,
https://learn.microsoft.com/en-us/aspnet/core/signalr/security?view=aspnetcore-8.0#access-token-logging

Setting this to Warning doesn't help. Moreover, middleware is also not clear - as token is needed for SignalR to authenticate properly.

The thread was started in scope of SignalR, but was refused as "not related" to the SignalR's context.
Azure/azure-signalr#1770

Please advise. Thanks

Environment

net8
"Microsoft.AspNetCore.SignalR.Core" Version="1.2.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Monitor - DistroMonitor OpenTelemetry DistroService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions