microsoft / microsoft/dev-tunnels

CLI managed identity authentication does not work with non-IMDS token endpoints or sytem-assigned managed identities

Open
#511 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
508
Forks
52
Avg merge
20h 6m
Merged PRs (30d)
7

Description

devtunnel user login allows managed identity authentication using --mi-client-id, --mi-object-id or --mi-resource-id. The implementation in Microsoft.DevTunnels.Cli.Authentication.ManagedIdentityApp.AcquireTokenAsync tries to acquire an access token from the IMDS managed identity token endpoint http://169.254.169.254/metadata/identity/oauth2/token with the Metadata header.

This does not work with hosting platforms that expose managed identities on a different endpoint. For example Managed identities in Azure Container Apps expose the token endpoint at an endpoint defined in the environment variable IDENTITY_ENDPOINT, in practice this is always http://localhost:42356/msi/token. ACA also requires a x-identity-header with the value of the IDENTITY_HEADER environment variable.

This also does not work for system-assigned managed identities which require the object_id/client_id/msi_res_id parameters to be omitted.

Consider support for authenticating using managed identity on platforms with non-IMDS managed identity token endpoints.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Microsoft.DevTunnels.Cli.Authentication.ManagedIdentityApp.AcquireTokenAsync and compare its IMDS request with the Azure Container Apps endpoint requirements. Account for IDENTITY_ENDPOINT and IDENTITY_HEADER, while omitting identity parameters for system-assigned identities. Done means managed identity login supports both IMDS and non-IMDS hosting platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
authentication, cli, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.