From 410b3efe868f1b365b941957a7de0c4100d9443e Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 2 Mar 2018 23:09:47 -0700 Subject: [PATCH] Pass in schema to Filter/FilterList --- authorization/all.go | 4 ++-- store/proxy/proxy_store.go | 4 ++-- types/server_types.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/authorization/all.go b/authorization/all.go index fc7821c4f..a99cc0762 100644 --- a/authorization/all.go +++ b/authorization/all.go @@ -30,10 +30,10 @@ func (*AllAccess) CanDelete(apiContext *types.APIContext, obj map[string]interfa return slice.ContainsString(schema.ResourceMethods, http.MethodDelete) } -func (*AllAccess) Filter(apiContext *types.APIContext, obj map[string]interface{}, context map[string]string) map[string]interface{} { +func (*AllAccess) Filter(apiContext *types.APIContext, schema *types.Schema, obj map[string]interface{}, context map[string]string) map[string]interface{} { return obj } -func (*AllAccess) FilterList(apiContext *types.APIContext, obj []map[string]interface{}, context map[string]string) []map[string]interface{} { +func (*AllAccess) FilterList(apiContext *types.APIContext, schema *types.Schema, obj []map[string]interface{}, context map[string]string) []map[string]interface{} { return obj } diff --git a/store/proxy/proxy_store.go b/store/proxy/proxy_store.go index 5dd445792..4b42dc047 100644 --- a/store/proxy/proxy_store.go +++ b/store/proxy/proxy_store.go @@ -168,7 +168,7 @@ func (p *Store) List(apiContext *types.APIContext, schema *types.Schema, opt *ty result = append(result, p.fromInternal(schema, obj.Object)) } - return apiContext.AccessControl.FilterList(apiContext, result, p.authContext), nil + return apiContext.AccessControl.FilterList(apiContext, schema, result, p.authContext), nil } func (p *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *types.QueryOptions) (chan map[string]interface{}, error) { @@ -210,7 +210,7 @@ func (p *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *t if event.Type == watch.Deleted && data.Object != nil { data.Object[".removed"] = true } - result <- apiContext.AccessControl.Filter(apiContext, data.Object, p.authContext) + result <- apiContext.AccessControl.Filter(apiContext, schema, data.Object, p.authContext) } logrus.Debugf("closing watcher for %s", schema.ID) close(result) diff --git a/types/server_types.go b/types/server_types.go index 9a314a467..74c6c89a9 100644 --- a/types/server_types.go +++ b/types/server_types.go @@ -75,8 +75,8 @@ type AccessControl interface { CanUpdate(apiContext *APIContext, obj map[string]interface{}, schema *Schema) bool CanDelete(apiContext *APIContext, obj map[string]interface{}, schema *Schema) bool - Filter(apiContext *APIContext, obj map[string]interface{}, context map[string]string) map[string]interface{} - FilterList(apiContext *APIContext, obj []map[string]interface{}, context map[string]string) []map[string]interface{} + Filter(apiContext *APIContext, schema *Schema, obj map[string]interface{}, context map[string]string) map[string]interface{} + FilterList(apiContext *APIContext, schema *Schema, obj []map[string]interface{}, context map[string]string) []map[string]interface{} } type APIContext struct {