From 3ae7e38089c4cc8bd9c1da6583a482330adced3c Mon Sep 17 00:00:00 2001 From: Anneli Date: Tue, 18 Jul 2023 15:05:16 +0200 Subject: [PATCH] remove check UserIsAdmin in generateDeployKey. fix typo --- api/applications/applications_handler.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/api/applications/applications_handler.go b/api/applications/applications_handler.go index be79e34d..4caea711 100644 --- a/api/applications/applications_handler.go +++ b/api/applications/applications_handler.go @@ -642,15 +642,6 @@ func (ah *ApplicationHandler) getMachineUserServiceAccount(ctx context.Context, // RegenerateDeployKey Regenerates deploy key and secret and returns the new key func (ah *ApplicationHandler) RegenerateDeployKey(ctx context.Context, appName string, regenerateDeployKeyAndSecretData applicationModels.RegenerateDeployKeyAndSecretData) error { // Make check that this is an existing application and that the user has access to it - userAccount := ah.getUserAccount() - userIsAdmin, err := ah.authorizationValidator.UserIsAdmin(ctx, &userAccount, appName) - if err != nil { - return err - } - if !userIsAdmin { - return fmt.Errorf("user is not allowed to regenerate deploy key for %s", appName) - } - currentRegistration, err := ah.getUserAccount().RadixClient.RadixV1().RadixRegistrations().Get(ctx, appName, metav1.GetOptions{}) if err != nil { return err @@ -684,11 +675,11 @@ func (ah *ApplicationHandler) RegenerateDeployKey(ctx context.Context, appName s if err != nil { return fmt.Errorf("failed to derive public key from private key: %v", err) } - exisingSecret, err := ah.getUserAccount().Client.CoreV1().Secrets(crdUtils.GetAppNamespace(appName)).Get(ctx, defaults.GitPrivateKeySecretName, metav1.GetOptions{}) + existingSecret, err := ah.getUserAccount().Client.CoreV1().Secrets(crdUtils.GetAppNamespace(appName)).Get(ctx, defaults.GitPrivateKeySecretName, metav1.GetOptions{}) if err != nil { return err } - newSecret := exisingSecret.DeepCopy() + newSecret := existingSecret.DeepCopy() newSecret.Data[defaults.GitPrivateKeySecretKey] = []byte(regenerateDeployKeyAndSecretData.PrivateKey) _, err = ah.getUserAccount().Client.CoreV1().Secrets(crdUtils.GetAppNamespace(appName)).Update(ctx, newSecret, metav1.UpdateOptions{}) if err != nil {