Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected resource service client authentication mode: Unsecured #3279

Closed
thangchung opened this issue Mar 29, 2024 · 2 comments
Closed

Unexpected resource service client authentication mode: Unsecured #3279

thangchung opened this issue Mar 29, 2024 · 2 comments
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Comments

@thangchung
Copy link

I followed the guidance at https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md to install the latest released from .NET Aspire (8.0.0-preview.5.24178.10). After installed in my laptop (Windows 11), and ran it.

> $env:DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS = 'true'; dotnet run apphost.csproj

It threw an exception:

info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.0.0-preview.4.24156.9+692dc41a65da572a7df25d53a9f2880afe59fdd8
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: ___app-host
info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 40044 --detach --kubeconfig "C:\Users\thangchung\AppData\Local\Temp\aspire.agphgkry.4aa\kubeconfig"
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      Starting API server...
info: Aspire.Hosting.Dcp.start-apiserver.api-server[0]
      API server started        {"Address": "::1", "Port": 64855}
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Starting DCP controller host
info: Aspire.Hosting.Dcp.start-apiserver.dcp-host[0]
      Started all services      {"count": 1}
info: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      Executables cannot be started via IDE: missing required environment variable 'DEBUG_SESSION_PORT'
info: Aspire.Hosting.Dcp.dcpctrl[0]
      starting controller manager
info: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      starting process...       {"Executable": {"name":"aspire-dashboard"}, "Reconciliation": 2, "executable": "C:\\Program Files\\dotnet\\packs\\Aspire.Dashboard.Sdk.win-x64\\8.0.0-preview.5.24178.10\\tools\\Aspire.Dashboard.exe"}
info: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      process started   {"Executable": {"name":"aspire-dashboard"}, "Reconciliation": 2, "executable": "C:\\Program Files\\dotnet\\packs\\Aspire.Dashboard.Sdk.win-x64\\8.0.0-preview.5.24178.10\\tools\\Aspire.Dashboard.exe", "PID": 16056}
dbug: Aspire.Hosting.Dcp.HttpPingDashboardAvailability[0]
      Dashboard not ready yet.
      System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (localhost:15030)
       ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
         at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
         at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
         at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
         at Aspire.Hosting.Dcp.HttpPingDashboardAvailability.WaitForDashboardAvailabilityAsync(Uri url, TimeSpan timeout, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/HttpPingDashboardAvailability.cs:line 32

I check the code at the PR: #3033

switch (options.Otlp.AuthMode)
{
    case OtlpAuthMode.Unsecured:
        break;
    case OtlpAuthMode.ApiKey:
        if (string.IsNullOrEmpty(options.Otlp.PrimaryApiKey))
        {
            errorMessages.Add("PrimaryApiKey is required when OTLP authentication mode is API key. Specify a Dashboard:Otlp:PrimaryApiKey value.");
        }
        break;
    case OtlpAuthMode.ClientCertificate:
        break;
    case null:
        errorMessages.Add($"OTLP endpoint authentication is not configured. Either specify {DashboardConfigNames.DashboardUnsecuredAllowAnonymousName.ConfigKey} with a value of true, or specify ${DashboardConfigNames.DashboardOtlpAuthModeName.ConfigKey}. Possible values: {string.Join(", ", typeof(OtlpAuthMode).GetEnumNames())}");
        break;
    default:
        errorMessages.Add($"Unexpected OTLP authentication mode: {options.Otlp.AuthMode}");
        break;
}

I think some wrong logic here. Why does it run to the switch default in this case? I passed DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS = 'true', then I expected it should match with the first one and break.

Ref: https://github.com/dotnet/aspire/blob/main/src/Aspire.Dashboard/Configuration/ValidateDashboardOptions.cs#L46

I checked the Windows event logs:

Application: Aspire.Dashboard.exe
CoreCLR Version: 8.0.224.6711
.NET Version: 8.0.2
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Extensions.Options.OptionsValidationException: Unexpected resource service client authentication mode: Unsecured
   at Aspire.Dashboard.DashboardWebApplication.GetDashboardOptions(WebApplicationBuilder builder, IConfigurationSection dashboardConfigSection) in /_/src/Aspire.Dashboard/DashboardWebApplication.cs:line 239
   at Aspire.Dashboard.DashboardWebApplication..ctor(Action`1 configureBuilder) in /_/src/Aspire.Dashboard/DashboardWebApplication.cs:line 82
   at Program.<Main>$(String[] args) in /_/src/Aspire.Dashboard/Program.cs:line 7

Could anyone check it? Currently, I couldn't roll back to the previous version (dotnet workload removed the ability to version rollback).

/cc @davidfowl @JamesNK

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 29, 2024
@davidfowl
Copy link
Member

davidfowl commented Mar 29, 2024

Looks like you’re on the preview 4 packages still?

image

@thangchung
Copy link
Author

Thanks, David. That was my fault. I upgraded all libs to 8.1.0-preview.1.24179, and it worked.

Now I can run $env:ASPIRE_ALLOW_UNSECURED_TRANSPORT = 'true'; dotnet run --project my-app-host\AppHost.csproj

@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

No branches or pull requests

2 participants