From eed524d67ef1356b51818b2681659bc23fcd22c7 Mon Sep 17 00:00:00 2001 From: CrowleyRajapakse Date: Wed, 14 Feb 2024 15:15:34 +0530 Subject: [PATCH] fixing token issuer CR not creating issue --- apim-apk-agent/internal/eventhub/marshaller.go | 2 +- apim-apk-agent/internal/k8sClient/k8s_client.go | 8 ++++---- apim-apk-agent/pkg/eventhub/types/types.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apim-apk-agent/internal/eventhub/marshaller.go b/apim-apk-agent/internal/eventhub/marshaller.go index 415a0784..fb279138 100644 --- a/apim-apk-agent/internal/eventhub/marshaller.go +++ b/apim-apk-agent/internal/eventhub/marshaller.go @@ -272,7 +272,7 @@ func MarshalKeyManager(keyManagerInternal *types.KeyManager) eventhubTypes.Resol Name: keyManagerInternal.Name, Enabled: keyManagerInternal.Enabled, Type: keyManagerInternal.Type, - TenantDomain: keyManagerInternal.TenantDomain, + Organization: keyManagerInternal.Organization, TokenType: keyManagerInternal.TokenType, KeyManagerConfig: marshalKeyManagrConfig(keyManagerInternal.Configuration), } diff --git a/apim-apk-agent/internal/k8sClient/k8s_client.go b/apim-apk-agent/internal/k8sClient/k8s_client.go index 68dbbdb9..4bf26b3a 100644 --- a/apim-apk-agent/internal/k8sClient/k8s_client.go +++ b/apim-apk-agent/internal/k8sClient/k8s_client.go @@ -343,7 +343,7 @@ func DeployBackendCR(backends *dpv1alpha1.Backend, k8sClient client.Client) { func CreateAndUpdateTokenIssuersCR(keyManager eventhubTypes.ResolvedKeyManager, k8sClient client.Client) error { conf, _ := config.ReadConfigs() sha1ValueofKmName := getSha1Value(keyManager.Name) - sha1ValueOfOrganization := getSha1Value(keyManager.TenantDomain) + sha1ValueOfOrganization := getSha1Value(keyManager.Organization) labelMap := map[string]string{"name": sha1ValueofKmName, "organization": sha1ValueOfOrganization} tokenIssuer := dpv1alpha2.TokenIssuer{ @@ -353,7 +353,7 @@ func CreateAndUpdateTokenIssuersCR(keyManager eventhubTypes.ResolvedKeyManager, }, Spec: dpv1alpha2.TokenIssuerSpec{ Name: keyManager.Name, - Organization: keyManager.TenantDomain, + Organization: keyManager.Organization, Issuer: keyManager.KeyManagerConfig.Issuer, ClaimMappings: marshalClaimMappings(keyManager.KeyManagerConfig.ClaimMappings), SignatureValidation: marshalSignatureValidation(keyManager.KeyManagerConfig), @@ -412,7 +412,7 @@ func DeleteTokenIssuersCR(k8sClient client.Client, keymanagerName string, tenant func UpdateTokenIssuersCR(keyManager eventhubTypes.ResolvedKeyManager, k8sClient client.Client) error { conf, _ := config.ReadConfigs() sha1ValueofKmName := getSha1Value(keyManager.Name) - sha1ValueOfOrganization := getSha1Value(keyManager.TenantDomain) + sha1ValueOfOrganization := getSha1Value(keyManager.Organization) labelMap := map[string]string{"name": sha1ValueofKmName, "organization": sha1ValueOfOrganization} tokenIssuer := &dpv1alpha2.TokenIssuer{} err := k8sClient.Get(context.Background(), client.ObjectKey{Name: keyManager.UUID, Namespace: conf.DataPlane.Namespace}, tokenIssuer) @@ -422,7 +422,7 @@ func UpdateTokenIssuersCR(keyManager eventhubTypes.ResolvedKeyManager, k8sClient } tokenIssuer.ObjectMeta.Labels = labelMap tokenIssuer.Spec.Name = keyManager.Name - tokenIssuer.Spec.Organization = keyManager.TenantDomain + tokenIssuer.Spec.Organization = keyManager.Organization tokenIssuer.Spec.Issuer = keyManager.KeyManagerConfig.Issuer tokenIssuer.Spec.ClaimMappings = marshalClaimMappings(keyManager.KeyManagerConfig.ClaimMappings) tokenIssuer.Spec.SignatureValidation = marshalSignatureValidation(keyManager.KeyManagerConfig) diff --git a/apim-apk-agent/pkg/eventhub/types/types.go b/apim-apk-agent/pkg/eventhub/types/types.go index 136f2955..b642faba 100644 --- a/apim-apk-agent/pkg/eventhub/types/types.go +++ b/apim-apk-agent/pkg/eventhub/types/types.go @@ -164,7 +164,7 @@ type KeyManager struct { Name string `json:"name"` Type string `json:"type"` Enabled bool `json:"enabled"` - TenantDomain string `json:"tenantDomain,omitempty"` + Organization string `json:"organization,omitempty"` TokenType string `json:"tokenType"` Configuration map[string]interface{} `json:"additionalProperties"` } @@ -175,7 +175,7 @@ type ResolvedKeyManager struct { Name string `json:"name"` Type string `json:"type"` Enabled bool `json:"enabled"` - TenantDomain string `json:"tenantDomain,omitempty"` + Organization string `json:"organization,omitempty"` TokenType string `json:"tokenType"` KeyManagerConfig KeyManagerConfig `json:"configuration"` }