Skip to content

Commit

Permalink
Pass in schema to Filter/FilterList
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Mar 3, 2018
1 parent d9307fc commit 410b3ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions authorization/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions store/proxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions types/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 410b3ef

Please sign in to comment.