Skip to content

Commit

Permalink
fix: filters should not hold reference to spec (#1625)
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs authored Dec 2, 2020
1 parent 315cdb5 commit e9382c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions filters/apiusagemonitoring/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const (
// apiUsageMonitoringFilter implements filters.Filter interface and is the structure
// created for every route invocation of the `apiUsageMonitoring` filter.
type apiUsageMonitoringFilter struct {
Spec *apiUsageMonitoringSpec
clientKeys []string
realmKeys []string
Paths []*pathInfo
UnknownPath *pathInfo
}
Expand Down Expand Up @@ -131,7 +132,7 @@ func (f *apiUsageMonitoringFilter) getRealmClientKey(r *http.Request, path *path
}

// no realm in JWT ==> {unknown}.{unknown}
realm, ok := jwt.getOneOfString(f.Spec.realmKeys)
realm, ok := jwt.getOneOfString(f.realmKeys)
if !ok {
return unknownUnknown
}
Expand All @@ -142,7 +143,7 @@ func (f *apiUsageMonitoringFilter) getRealmClientKey(r *http.Request, path *path
}

// no client in JWT ==> realm.{unknown}
client, ok := jwt.getOneOfString(f.Spec.clientKeys)
client, ok := jwt.getOneOfString(f.clientKeys)
if !ok {
return realm + "." + unknownPlaceholder
}
Expand Down
3 changes: 2 additions & 1 deletion filters/apiusagemonitoring/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ func (s *apiUsageMonitoringSpec) CreateFilter(args []interface{}) (filter filter
}

filter = &apiUsageMonitoringFilter{
Spec: s,
realmKeys: s.realmKeys,
clientKeys: s.clientKeys,
Paths: paths,
UnknownPath: s.buildUnknownPathInfo(paths),
}
Expand Down

0 comments on commit e9382c0

Please sign in to comment.