Skip to content

Commit

Permalink
Revert "For analytics records, upload a singular product that was use…
Browse files Browse the repository at this point in the history
…d for an authorized operation. This replaces the existing functionality that picked a random matching product from the credential"

This reverts commit 8575002.
  • Loading branch information
KyleWiese committed Sep 26, 2024
1 parent 8575002 commit 0673c38
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
6 changes: 5 additions & 1 deletion analytics/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion auth/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion product/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type AuthorizedOperation struct {
QuotaLimit int64
QuotaInterval int64
QuotaTimeUnit string
APIProduct string
}

// Authorize a request against API Products and its Operations
Expand Down
2 changes: 0 additions & 2 deletions product/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions product/product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func TestAuthorize(t *testing.T) {
wantAuthOp: &AuthorizedOperation{
ID: "Name [email protected]",
QuotaLimit: productsMap["Name 2"].QuotaLimitInt,
APIProduct: "Name 2",
},
wantHints: `Authorizing request:
environment: prod
Expand Down Expand Up @@ -256,7 +255,6 @@ func TestAuthorize(t *testing.T) {
wantAuthOp: &AuthorizedOperation{
ID: "Name [email protected]",
QuotaLimit: productsMap["Name 1"].QuotaLimitInt,
APIProduct: "Name 1",
},
wantHints: `Authorizing request:
environment: prod
Expand Down

0 comments on commit 0673c38

Please sign in to comment.