Skip to content

Commit a42938d

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

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,14 @@ func newConfigCredential(creds map[string]string, options configCredentialOption
129129
return nil, errors.Errorf("%s is required", CredentialKeyPassword)
130130
}
131131

132+
//msiEndpoint
133+
msiEndpoint := creds[CredentialMSIENDPOINT]
134+
identityEndpoint := creds[CredentialIDENTITYENDPOINT]
135+
136+
if msiEndpoint != "" || identityEndpoint != "" {
137+
o := &azidentity.ManagedIdentityCredentialOptions{ClientOptions: options.ClientOptions, ID: azidentity.ClientID(clientID)}
138+
return azidentity.NewManagedIdentityCredential(o)
139+
}
140+
132141
return nil, errors.New("incomplete credential configuration. Only AZURE_TENANT_ID and AZURE_CLIENT_ID are set")
133142
}

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)