Skip to content

Use API key auth for OTLP in local development#3031

Merged
JamesNK merged 8 commits intomainfrom
jamesnk/localdevelopment-otlp-apikey
Mar 20, 2024
Merged

Use API key auth for OTLP in local development#3031
JamesNK merged 8 commits intomainfrom
jamesnk/localdevelopment-otlp-apikey

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Mar 20, 2024

Previous PR added API key auth to OTLP endpoint. There is the opportunity to secure the local dev environment by using API key auth and having the host co-ordinate the dashboard and user apps.

This PR:

  • Generates a random API key each time the app host is run.
  • Passes environment variables to dashboard to enable API key auth, and the expected API key.
  • Passes environment variables to ups to add API key header to OTLP requests.
  • Can be disabled by passing DOTNET_DISABLE_OTLP_API_KEY_AUTH=true setting to apphost.
Microsoft Reviewers: Open in CodeFlow

@JamesNK
Copy link
Copy Markdown
Member Author

JamesNK commented Mar 20, 2024

FYI @martinjt

I've looked at how your https://github.com/practical-otel/opentelemetry-aspire-collector/ works and I believe it will need some changes but should continue to be possible if API key auth is added to the dashboard's OTLP endpoint.

You'll need to:

  • Read the API key from the AppHost:OtlpApiKey config setting.
  • Pass the API key to collector container as an env var
  • Update the config file to include an x-otlp-api-key header to the exporter.
  • Consider removing the OTEL_EXPORTER_OTLP_HEADERS env var that is passed to apps. They don't need it if they're talking to the collector.

AppHost:OtlpApiKey config setting won't be present if the feature is disabled.

@JamesNK JamesNK enabled auto-merge (squash) March 20, 2024 05:29
@JamesNK JamesNK merged commit 30e43cd into main Mar 20, 2024
@JamesNK JamesNK deleted the jamesnk/localdevelopment-otlp-apikey branch March 20, 2024 05:50
@martinjt
Copy link
Copy Markdown

Cool, I can do that, I'm assuming thar will be Preview 5?

@JamesNK
Copy link
Copy Markdown
Member Author

JamesNK commented Mar 20, 2024

Yes, preview 5.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants