Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions backend/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ func (f *BackendRootCmdFlags) ToBackendOptions(ctx context.Context, cmd *cobra.C
}

smiClientBuilder := app.NewServiceManagedIdentityClientBuilder(fpaMIDataplaneClientBuilder, azureConfig)
clusterOperatorIdentityClientBuilder := app.NewClusterOperatorIdentityClientBuilder(fpaMIDataplaneClientBuilder, azureConfig)

azCoreClientOptions := *azureConfig.CloudEnvironment.AZCoreClientOptions()
miDataplaneBasedIdentityAccessTokenRetrieverBuilder := azureclient.NewMIDataplaneBasedIdentityAccessTokenRetrieverBuilder(
Expand Down Expand Up @@ -489,12 +490,13 @@ func (f *BackendRootCmdFlags) ToBackendOptions(ctx context.Context, cmd *cobra.C
BackupConfig: backupConfig,
FPAMIDataplaneClientBuilder: fpaMIDataplaneClientBuilder,
MIDataplaneBasedIdentityAccessTokenRetrieverBuilder: miDataplaneBasedIdentityAccessTokenRetrieverBuilder,
SMIClientBuilder: smiClientBuilder,
CheckAccessV2ClientBuilder: checkAccessV2ClientBuilder,
ClusterScopedIdentitiesConfig: clusterScopedIdentitiesConfig,
CloudEnvironment: azureConfig.CloudEnvironment,
MetricsRegisterer: legacyregistry.Registerer(),
MetricsGatherer: legacyregistry.DefaultGatherer,
SMIClientBuilder: smiClientBuilder,
ClusterOperatorIdentityClientBuilder: clusterOperatorIdentityClientBuilder,
CheckAccessV2ClientBuilder: checkAccessV2ClientBuilder,
ClusterScopedIdentitiesConfig: clusterScopedIdentitiesConfig,
CloudEnvironment: azureConfig.CloudEnvironment,
MetricsRegisterer: legacyregistry.Registerer(),
MetricsGatherer: legacyregistry.DefaultGatherer,
}

return backendOptions, nil
Expand Down
1 change: 1 addition & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v1.3.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6 v6.2.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.5.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.4
github.com/Azure/azure-sdk-for-go/sdk/tracing/azotel v0.4.0
github.com/Azure/checkaccess-v2-go-sdk v0.0.4-0.20260707173829-4b27d1696d22
Expand Down
2 changes: 2 additions & 0 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3 v3.0.1/go.mod h1:8h8yhzh9o+0HeSIhUxYny+rEQajScrfIpNktvgYG3Q8=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.1 h1:/Zt+cDPnpC3OVDm/JKLOs7M2DKmLRIIp3XIx9pHHiig=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.1/go.mod h1:Ng3urmn6dYe8gnbCMoHHVl5APYz2txho3koEkV2o2HA=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.5.0 h1:MaKvxE6D0KkjOg6Wd9M00iqP5PR0kUxCfiezes4JweM=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.5.0/go.mod h1:i2h9fsTFKZorh8RdV2IcSUf/Qj98GlTkrTvUbX/s8as=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.4.0 h1:/g8S6wk65vfC6m3FIxJ+i5QDyN9JWwXI8Hb0Img10hU=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.4.0/go.mod h1:gpl+q95AzZlKVI3xSoseF9QPrypk0hQqBiJYeB/cR/I=
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 h1:nCYfgcSyHZXJI8J0IWE5MsCGlb2xp9fJiXyxWgmOFg4=
Expand Down
8 changes: 8 additions & 0 deletions backend/pkg/app/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type BackendOptions struct {
MIDataplaneBasedIdentityAccessTokenRetrieverBuilder azureclient.MIDataplaneBasedIdentityAccessTokenRetrieverBuilder
BackupConfig *clusterbackups.BackupConfig
SMIClientBuilder azureclient.ServiceManagedIdentityClientBuilder
ClusterOperatorIdentityClientBuilder azureclient.ClusterOperatorIdentityClientBuilder
CheckAccessV2ClientBuilder azureclient.CheckAccessV2ClientBuilder
ClusterScopedIdentitiesConfig *internalazure.ClusterScopedIdentitiesConfig
CloudEnvironment *azureconfig.AzureCloudEnvironment
Expand Down Expand Up @@ -826,6 +827,12 @@ func (b *Backend) runBackendControllersUnderLeaderElection(ctx context.Context,
serviceProviderClusterLister,
backendInformers,
)
azureClusterKeyVaultAccessibilityValidationController := clustervalidation.NewClusterValidationController(
validationutils.NewAzureClusterKeyVaultAccessibilityValidation(b.options.ClusterOperatorIdentityClientBuilder),
b.options.ResourcesDBClient,
serviceProviderClusterLister,
backendInformers,
)
azureVMSizeSupportsEphemeralOSDiskValidationController := nodepoolvalidation.NewNodePoolValidationController(
validationutils.NewAzureVMSizeSupportsEphemeralOSDiskValidation(virtualMachineResourceSKUsCachedReaderController),
b.options.ResourcesDBClient,
Expand Down Expand Up @@ -1080,6 +1087,7 @@ func (b *Backend) runBackendControllersUnderLeaderElection(ctx context.Context,
go azureRPRegistrationValidationController.Run(ctx, 20)
go azureClusterResourceGroupExistenceValidationController.Run(ctx, 20)
go azureClusterManagedIdentitiesExistenceValidationController.Run(ctx, 20)
go azureClusterKeyVaultAccessibilityValidationController.Run(ctx, 20)
go azureVMSizeSupportsEphemeralOSDiskValidationController.Run(ctx, 20)
go azureNodePoolVMQuotaValidationController.Run(ctx, 20)
go controlPlaneIdentitiesPermissionsValidationController.Run(ctx, 20)
Expand Down
7 changes: 7 additions & 0 deletions backend/pkg/app/fpa_wiring.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ func NewServiceManagedIdentityClientBuilder(fpaMIdataplaneClientBuilder azurecli
azureConfig.CloudEnvironment.ARMClientOptions(),
)
}

func NewClusterOperatorIdentityClientBuilder(fpaMIdataplaneClientBuilder azureclient.FPAMIDataplaneClientBuilder, azureConfig *azureconfig.AzureConfig) azureclient.ClusterOperatorIdentityClientBuilder {
return azureclient.NewClusterOperatorIdentityClientBuilder(
fpaMIdataplaneClientBuilder,
azureConfig.CloudEnvironment.ARMClientOptions(),
)
}
58 changes: 58 additions & 0 deletions backend/pkg/azure/client/credential_helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2026 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package client

import (
"context"
"fmt"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
azcorearm "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/msi-dataplane/pkg/dataplane"

"github.com/Azure/ARO-HCP/internal/utils"
)

// credentialForIdentity obtains an azcore.TokenCredential for the given
// customer-granted managed identity, via the Managed Identities Data Plane
// Service, using the cluster's identity URL. It works for any identity the
// cluster has been granted (the SMI, or a cluster operator identity like
// "kms") -- the data plane request is keyed by resource ID alone.
func credentialForIdentity(
ctx context.Context,
fpaMIdataplaneClientBuilder FPAMIDataplaneClientBuilder,
azCoreClientOptions azcore.ClientOptions,
clusterIdentityURL string,
identityResourceID *azcorearm.ResourceID,
) (azcore.TokenCredential, error) {
miDataplaneClient, err := fpaMIdataplaneClientBuilder.ManagedIdentitiesDataplane(clusterIdentityURL)
if err != nil {
return nil, err
}

dataplaneRequest := dataplane.UserAssignedIdentitiesRequest{
IdentityIDs: []string{identityResourceID.String()},
}
resp, err := miDataplaneClient.GetUserAssignedIdentitiesCredentials(ctx, dataplaneRequest)
if err != nil {
return nil, err
}
if len(resp.ExplicitIdentities) == 0 {
return nil,
utils.TrackError(fmt.Errorf("managed identities data plane returned no credentials for identity '%s'", identityResourceID.String()))
}

return dataplane.GetCredential(azCoreClientOptions, resp.ExplicitIdentities[0])
}
33 changes: 33 additions & 0 deletions backend/pkg/azure/client/keyvault_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2026 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package client

//go:generate $MOCKGEN -typed -source=keyvault_client.go -destination=mock_keyvault_client.go -package client KeyVaultKeysClient

import (
"context"

"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys"
)

// KeyVaultKeysClient is the Key Vault Keys data plane client, addressed
// directly by vault DNS name rather than by ARM resource ID. This lets
// callers reach a customer-owned Key Vault without needing to know which
// resource group or subscription it lives in.
type KeyVaultKeysClient interface {
GetKey(ctx context.Context, name string, version string, options *azkeys.GetKeyOptions) (azkeys.GetKeyResponse, error)
}

var _ KeyVaultKeysClient = (*azkeys.Client)(nil)
81 changes: 81 additions & 0 deletions backend/pkg/azure/client/mock_keyvault_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 119 additions & 0 deletions backend/pkg/azure/client/mock_operator_identity_client_builder.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading