Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Managed Identity Support #552

Merged
merged 208 commits into from
Feb 14, 2025
Merged

Add Managed Identity Support #552

merged 208 commits into from
Feb 14, 2025

Conversation

AndyOHart
Copy link
Collaborator

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 <bogavril@microsoft.com>
…-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 <10964656+chlowell@users.noreply.github.com>
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
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
AndyOHart and others added 11 commits January 28, 2025 18:26
* adds tests for azure ml
* 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 <10964656+chlowell@users.noreply.github.com>

---------

Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
@AndyOHart AndyOHart added this to the 1.4.0 milestone Feb 13, 2025
@AndyOHart AndyOHart requested review from chlowell and 4gust February 13, 2025 17:45
AndyOHart and others added 7 commits February 14, 2025 11:17
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
* 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
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.

6 participants