Skip to content

Configure Aspire Dashboard with key-per-file configuration provider #4526

@mu88

Description

@mu88

Hi 👋🏻

Disclaimer: Since my issue is more a feature request than an API change, I decided not to use one of the predefined templates, but I'm happy to provide any further information you need.

I'm running the Aspire Dashboard as a standalone app via Docker which works nicely 👌🏻 this is my current docker-compose.yml:

services:
  aspire-dashboard:
    image: mcr.microsoft.com/dotnet/aspire-dashboard
    container_name: aspire-dashboard
    ports:
      - 4317:18889
      - 18888:18888
    environment:
      - Dashboard__Frontend__BrowserToken=Tralala

You immediately see the flaw: it contains the browser token as cleartext. Especially since I put my docker-compose.yml files under version control, that's not really great.

For my other .NET apps, I'm using the key-per-file configuration provider which would allow the following setting:

services:
  aspire-dashboard:
    image: mcr.microsoft.com/dotnet/aspire-dashboard
    container_name: aspire-dashboard
    ports:
      - 4317:18889
      - 18888:18888
    secrets:
      - Dashboard__Frontend__BrowserToken
secrets:
  Dashboard__Frontend__BrowserToken:
    file: Dashboard__Frontend__BrowserToken.txt

This way, I could easily put my docker-compose.yml under version control.

After a quick and non-comprehensive look, I think this might be implemented by adding the following lines here:

if (!string.IsNullOrEmpty(builder.Configuration[DashboardConfigNames.SecretsPath]))
{
    builder.Configuration.AddKeyPerFile(directoryPath: builder.Configuration[DashboardConfigNames.SecretsPath], optional: false);
}

With this change, the final docker-compose.yml could look like this:

services:
  aspire-dashboard:
    image: mcr.microsoft.com/dotnet/aspire-dashboard
    container_name: aspire-dashboard
    ports:
      - 4317:18889
      - 18888:18888
    environment:
      - Dashboard__SecretsPath=/run/secrets
    secrets:
      - Dashboard__Frontend__BrowserToken
secrets:
  Dashboard__Frontend__BrowserToken:
    file: Dashboard__Frontend__BrowserToken.txt

If you'd consider this a useful feature, I'm happy to provide a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions