Skip to content

Commit

Permalink
Allow clientId hint when using Managed Identity
Browse files Browse the repository at this point in the history
  • Loading branch information
ArvidMartensRenson committed Jun 20, 2024
1 parent c271284 commit f0bcf34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions azcredentials/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ func getFromCredentialsObject(credentialsObj map[string]interface{}, secureData

case AzureAuthManagedIdentity:
credentials := &AzureManagedIdentityCredentials{}

clientId, err := maputil.GetStringOptional(credentialsObj, "clientId")
if err != nil {
return nil, err
}
if clientId != "" {
credentials.ClientId = clientId
}

return credentials, nil

case AzureAuthWorkloadIdentity:
Expand Down
3 changes: 2 additions & 1 deletion azcredentials/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestFromDatasourceData(t *testing.T) {
var data = map[string]interface{}{
"azureCredentials": map[string]interface{}{
"authType": "msi",
"clientId": "CLIENT-ID"
},
}
var secureData = map[string]string{}
Expand All @@ -161,7 +162,7 @@ func TestFromDatasourceData(t *testing.T) {
credential := (result).(*AzureManagedIdentityCredentials)

// ClientId currently not parsed
assert.Equal(t, credential.ClientId, "")
assert.Equal(t, credential.ClientId, "CLIENT-ID")
})

t.Run("should return workload identity credentials when workload identity auth configured", func(t *testing.T) {
Expand Down

0 comments on commit f0bcf34

Please sign in to comment.