go-azure-sdk icon indicating copy to clipboard operation
go-azure-sdk copied to clipboard

Support MSI authentication in Azure Container App and App Service like environments

Open vermacodes opened this issue 4 months ago • 3 comments

Fixes #1054

This pull request introduces changes to the managed_identity_authorizer.go file to enhance support for Azure App Service environments. The most important changes include adding environment variable checks for MSI_ENDPOINT and MSI_SECRET, updating the managedIdentityConfig struct, and modifying the azureMetadata function to include the IDENTITY_HEADER if it is set.

Enhancements for Azure App Service environments:

  • sdk/auth/managed_identity_authorizer.go: Added environment variable checks for MSI_ENDPOINT and MSI_SECRET to use a custom endpoint and a newer API version if these variables are present. ([sdk/auth/managed_identity_authorizer.goR141-R157](diffhunk://#diff-34bbc13c23439cbbb815afe5de29f488cbd66a126f2ad0785bd62bdf5ef71667R141-R157))
  • sdk/auth/managed_identity_authorizer.go: Modified the managedIdentityConfig struct to dynamically set the MsiApiVersion and MsiEndpoint based on environment variables. ([sdk/auth/managed_identity_authorizer.goR141-R157](diffhunk://#diff-34bbc13c23439cbbb815afe5de29f488cbd66a126f2ad0785bd62bdf5ef71667R141-R157))
  • sdk/auth/managed_identity_authorizer.go: Updated the azureMetadata function to include the IDENTITY_HEADER in the request headers if the environment variable is set. ([sdk/auth/managed_identity_authorizer.goL165-R191](diffhunk://#diff-34bbc13c23439cbbb815afe5de29f488cbd66a126f2ad0785bd62bdf5ef71667L165-R191))

General improvements:

  • sdk/auth/managed_identity_authorizer.go: Added the os package to the import list to support the new environment variable checks. ([sdk/auth/managed_identity_authorizer.goR14](diffhunk://#diff-34bbc13c23439cbbb815afe5de29f488cbd66a126f2ad0785bd62bdf5ef71667R14))

vermacodes avatar Oct 09 '24 18:10 vermacodes