Skip to content

Commit

Permalink
Add MSI Support for Azure plugin.
Browse files Browse the repository at this point in the history
Signed-off-by: yanggang <gang.yang@daocloud.io>
  • Loading branch information
yanggang committed Oct 10, 2023
1 parent b316101 commit 4de800a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6927-yanggangtony
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add MSI Support for Azure plugin.
9 changes: 9 additions & 0 deletions pkg/util/azure/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,14 @@ func newConfigCredential(creds map[string]string, options configCredentialOption
return nil, errors.Errorf("%s is required", CredentialKeyPassword)
}

//msiEndpoint
msiEndpoint := creds[CredentialMSI_ENDPOINT]
identityEndpoint := creds[CredentialIDENTITY_ENDPOINT]

if msiEndpoint != "" || identityEndpoint != "" {
o := &azidentity.ManagedIdentityCredentialOptions{ClientOptions: options.ClientOptions, ID: azidentity.ClientID(clientID)}
return azidentity.NewManagedIdentityCredential(o)
}

return nil, errors.New("incomplete credential configuration. Only AZURE_TENANT_ID and AZURE_CLIENT_ID are set")
}
6 changes: 6 additions & 0 deletions pkg/util/azure/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const (
CredentialKeyUsername = "AZURE_USERNAME" // #nosec
CredentialKeyPassword = "AZURE_PASSWORD" // #nosec

CredentialIMDS_ENDPOINT = "IMDS_ENDPOINT" // #nosec
CredentialIDENTITY_ENDPOINT = "IDENTITY_ENDPOINT" // #nosec
CredentialIDENTITY_HEADER = "IDENTITY_HEADER" // #nosec
CredentialIDENTITY_SERVER_THUMBPRINT = "IDENTITY_SERVER_THUMBPRINT" // #nosec
CredentialMSI_ENDPOINT = "MSI_ENDPOINT" // #nosec

credentialFile = "credentialsFile"
)

Expand Down

0 comments on commit 4de800a

Please sign in to comment.