From 0673c38e036b7ae9dac2783e53245ef3598d8752 Mon Sep 17 00:00:00 2001 From: KyleWiese Date: Thu, 26 Sep 2024 20:04:38 +0000 Subject: [PATCH] Revert "For analytics records, upload a singular product that was used for an authorized operation. This replaces the existing functionality that picked a random matching product from the credential" This reverts commit 85750025b4d2c1ecf4a8061c87d64c503596f68d. --- analytics/record.go | 6 +++++- auth/context.go | 1 - product/manager.go | 1 - product/product.go | 2 -- product/product_test.go | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/analytics/record.go b/analytics/record.go index 98c041e..85557c4 100644 --- a/analytics/record.go +++ b/analytics/record.go @@ -86,9 +86,13 @@ func (r Record) EnsureFields(authContext *auth.Context) Record { r.ClientID = authContext.ClientID r.Organization = authContext.Organization() r.Environment = authContext.Environment() + r.GatewayFlowID = uuid.New().String() - r.APIProduct = authContext.AnalyticsProduct + // select arbitrary APIProduct + if len(authContext.APIProducts) > 0 { + r.APIProduct = authContext.APIProducts[0] + } return r } diff --git a/auth/context.go b/auth/context.go index 57eec7a..f949f3b 100644 --- a/auth/context.go +++ b/auth/context.go @@ -47,7 +47,6 @@ type Context struct { Scopes []string APIKey string CustomAttributes string - AnalyticsProduct string // A single product to attatch to analytics records based on matched operations. } // if claims can't be processed, returns error and sets no fields diff --git a/product/manager.go b/product/manager.go index 4391ae5..9d77b2e 100644 --- a/product/manager.go +++ b/product/manager.go @@ -82,7 +82,6 @@ type AuthorizedOperation struct { QuotaLimit int64 QuotaInterval int64 QuotaTimeUnit string - APIProduct string } // Authorize a request against API Products and its Operations diff --git a/product/product.go b/product/product.go index ec9f1b1..5960ad6 100644 --- a/product/product.go +++ b/product/product.go @@ -318,7 +318,6 @@ func (p *APIProduct) authorize(authContext *auth.Context, api, path, method stri QuotaLimit: p.QuotaLimitInt, QuotaInterval: p.QuotaIntervalInt, QuotaTimeUnit: p.QuotaTimeUnit, - APIProduct: p.Name, } // OperationConfig quota is an override if oc.Quota != nil && oc.Quota.LimitInt > 0 { @@ -354,7 +353,6 @@ func (p *APIProduct) authorize(authContext *auth.Context, api, path, method stri QuotaLimit: p.QuotaLimitInt, QuotaInterval: p.QuotaIntervalInt, QuotaTimeUnit: p.QuotaTimeUnit, - APIProduct: p.Name, }) hint = " authorized\n" diff --git a/product/product_test.go b/product/product_test.go index ac2dafe..4629f5a 100644 --- a/product/product_test.go +++ b/product/product_test.go @@ -196,7 +196,6 @@ func TestAuthorize(t *testing.T) { wantAuthOp: &AuthorizedOperation{ ID: "Name 2-prod-foo@google.com-app", QuotaLimit: productsMap["Name 2"].QuotaLimitInt, - APIProduct: "Name 2", }, wantHints: `Authorizing request: environment: prod @@ -256,7 +255,6 @@ func TestAuthorize(t *testing.T) { wantAuthOp: &AuthorizedOperation{ ID: "Name 1-prod-foo@google.com-app", QuotaLimit: productsMap["Name 1"].QuotaLimitInt, - APIProduct: "Name 1", }, wantHints: `Authorizing request: environment: prod