Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAuthFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public DevUIAuthFilter(IOptions<DevUIOptions> options, ILogger<DevUIAuthFilter>

if (!isLoopback && !this._options.AllowRemoteAccess)
{
this._logger.LogWarning(
"Rejected non-loopback DevUI request from {RemoteIp}. Set DevUIOptions.AllowRemoteAccess to permit remote callers.",
remoteIp);
DevUILog.RejectedNonLoopbackRequest(this._logger, remoteIp);
return Results.Problem(
statusCode: StatusCodes.Status403Forbidden,
title: "DevUI access denied",
Expand Down
5 changes: 1 addition & 4 deletions dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ private static void WarnIfInsecurelyExposed(ILogger logger, DevUIOptions options

if (options.AllowRemoteAccess && !tokenConfigured && options.ConfigureEndpoints is null)
{
logger.LogWarning(
"DevUI is configured with AllowRemoteAccess=true and no authentication. " +
"Set DevUIOptions.AuthToken, the {EnvVar} environment variable, or attach an authorization policy via ConfigureEndpoints.",
DevUIOptions.AuthTokenEnvironmentVariable);
DevUILog.InsecurelyExposed(logger, DevUIOptions.AuthTokenEnvironmentVariable);
}
}
}
20 changes: 20 additions & 0 deletions dotnet/src/Microsoft.Agents.AI.DevUI/DevUILog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Net;

namespace Microsoft.Agents.AI.DevUI;

internal static partial class DevUILog
{
[LoggerMessage(
EventId = 1,
Level = LogLevel.Warning,
Message = "Rejected non-loopback DevUI request from {RemoteIp}. Set DevUIOptions.AllowRemoteAccess to permit remote callers.")]
public static partial void RejectedNonLoopbackRequest(ILogger logger, IPAddress? remoteIp);

[LoggerMessage(
EventId = 2,
Level = LogLevel.Warning,
Message = "DevUI is configured with AllowRemoteAccess=true and no authentication. Set DevUIOptions.AuthToken, the {EnvVar} environment variable, or attach an authorization policy via ConfigureEndpoints.")]
public static partial void InsecurelyExposed(ILogger logger, string envVar);
}
Loading