diff --git a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAuthFilter.cs b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAuthFilter.cs index b8e4b499f8..7f238ab3a0 100644 --- a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAuthFilter.cs +++ b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIAuthFilter.cs @@ -51,9 +51,7 @@ public DevUIAuthFilter(IOptions options, ILogger 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", diff --git a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs index 18d0ae24cf..d22cd46f61 100644 --- a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs @@ -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); } } } diff --git a/dotnet/src/Microsoft.Agents.AI.DevUI/DevUILog.cs b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUILog.cs new file mode 100644 index 0000000000..a963b42a6f --- /dev/null +++ b/dotnet/src/Microsoft.Agents.AI.DevUI/DevUILog.cs @@ -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); +}