Skip to content

Commit 7bb463e

Browse files
author
yanggang
committed
Add MSI Support for Azure plugin.
Signed-off-by: yanggang <[email protected]>
1 parent b316101 commit 7bb463e

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add MSI Support for Azure plugin.

pkg/util/azure/credential.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ func NewCredential(creds map[string]string, options policy.ClientOptions) (azcor
4949
errMsgs = append(errMsgs, err.Error())
5050
}
5151

52+
//msiEndpoint credential
53+
msiEndpoint := creds[CredentialMSIENDPOINT]
54+
identityEndpoint := creds[CredentialIDENTITYENDPOINT]
55+
56+
if msiEndpoint != "" || identityEndpoint != "" {
57+
o := &azidentity.ManagedIdentityCredentialOptions{ClientOptions: options, ID: azidentity.ClientID(creds[CredentialKeyClientID])}
58+
msi, err := azidentity.NewManagedIdentityCredential(o)
59+
if err == nil {
60+
credential = append(credential, msi)
61+
} else {
62+
errMsgs = append(errMsgs, err.Error())
63+
}
64+
}
65+
5266
// workload identity credential
5367
wic, err := azidentity.NewWorkloadIdentityCredential(&azidentity.WorkloadIdentityCredentialOptions{
5468
AdditionallyAllowedTenants: additionalTenants,

pkg/util/azure/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ const (
4949
CredentialKeyUsername = "AZURE_USERNAME" // #nosec
5050
CredentialKeyPassword = "AZURE_PASSWORD" // #nosec
5151

52+
CredentialIMDSENDPOINT = "IMDS_ENDPOINT" // #nosec
53+
CredentialIDENTITYENDPOINT = "IDENTITY_ENDPOINT" // #nosec
54+
CredentialIDENTITYHEADER = "IDENTITY_HEADER" // #nosec
55+
CredentialIDENTITYSERVERTHUMBPRINT = "IDENTITY_SERVER_THUMBPRINT" // #nosec
56+
CredentialMSIENDPOINT = "MSI_ENDPOINT" // #nosec
57+
5258
credentialFile = "credentialsFile"
5359
)
5460

0 commit comments

Comments
 (0)