Skip to content

Conversation

@AndyOHart
Copy link
Contributor

PR Summary: Add Managed Identity Support

Branch: andyohart/managed-identity
Merging into: main

Overview

This PR introduces Managed Identity support to the Microsoft Authentication Library for Go through a new client. The new client supports multiple sources for managed identities, including:

  • IMDS
  • Azure Arc
  • Service Fabric
  • App Service
  • Azure Machine Learning
  • Cloud Shell

The client can handle both System Assigned Managed Identities and User Assigned Managed Identities.
For user-assigned identities, you can specify:

  • Client ID
  • Resource ID
  • Object ID

Key Changes

  • New Managed Identity Client: Added a new client to handle managed identity authentication.
  • Multiple Sources Support: The client supports various managed identity sources, enhancing flexibility and usability.
  • Tests: Comprehensive tests have been added to ensure the reliability and correctness of the new functionality.
  • Documentation: Updated documentation to include details on the new managed identity client and usage instructions.

Code Sample

Here's a basic example of how to use the new managed identity client to acquire a token:

package main

import (
    "context"
    "fmt"
    "github.com/AzureAD/microsoft-authentication-library-for-go/msal"
)

func main() {
	miSystemAssigned, err := mi.New(mi.SystemAssigned())
	if err != nil {
		log.Fatal(err)
	}
	result, err := miSystemAssigned.AcquireToken(context.TODO(), "https://management.azure.com")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("token expire at : ", result.ExpiresOn)
}

AndyOHart and others added 30 commits August 21, 2024 08:30
* Readme suggestion update

Co-authored-by: Bogdan Gavril <[email protected]>
…-class-implementation

Implement Initial API Classes
Added a simple version of getting token and printing it
reformatting code.
Added tests and implementation for SAMI IMDS
Reverted changes in the test app
Formatting changes
Added method for UAMI
Updated the some code and cleaned up some comments and print statement
Updated the key for the resource

Co-authored-by: Charles Lowell <[email protected]>
Updated the token from url function to a reaquest based function
Updated test to fail not only return error
Added tests for failure and success for SAMI
added context to request
Updated the tests to check for errors more correctly
Update some test and used mock.Client
some refactoring for comments
AndyOHart and others added 10 commits January 29, 2025 19:44
* Service fabric ssl checker

* adding new test

* Service fabric and its tests

* Updated Test to check for supported sources

* Removed some unused code

* Removed the SSL validation

* Updated the get token method

* Update apps/managedidentity/servicefabric_test.go

Co-authored-by: Charles Lowell <[email protected]>

---------

Co-authored-by: Charles Lowell <[email protected]>
@AndyOHart AndyOHart added this to the 1.4.0 milestone Feb 13, 2025
@AndyOHart AndyOHart requested review from 4gust and chlowell February 13, 2025 17:45
AndyOHart and others added 7 commits February 14, 2025 11:17
Co-authored-by: Charles Lowell <[email protected]>
* Update documentation file to link to full suite of sample documentation instead of just showing IMDS documentation
* Added a new error InvalidJsonErr

* Update confidential_test.go
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

@AndyOHart AndyOHart merged commit e6d9244 into main Feb 14, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants