Ensure field permissions are correctly applied
This commit is contained in:
parent
eb62515a05
commit
444a38986a
1 changed files with 14 additions and 14 deletions
28
db/yield.go
28
db/yield.go
|
@ -25,48 +25,48 @@ import (
|
||||||
|
|
||||||
func (d *document) cold(ctx context.Context) (doc *data.Doc, err error) {
|
func (d *document) cold(ctx context.Context) (doc *data.Doc, err error) {
|
||||||
|
|
||||||
|
// We need to copy the document so that
|
||||||
|
// we can add and remove the fields which
|
||||||
|
// are relevant to the particular query.
|
||||||
|
|
||||||
|
doc = d.initial.Copy()
|
||||||
|
|
||||||
// If we are not authenticated using DB,
|
// If we are not authenticated using DB,
|
||||||
// NS, or KV level, then we need to check
|
// NS, or KV level, then we need to check
|
||||||
// document permissions for this query.
|
// document permissions for this query.
|
||||||
|
|
||||||
if k, ok := ctx.Value(ctxKeyKind).(cnf.Kind); ok {
|
if k, ok := ctx.Value(ctxKeyKind).(cnf.Kind); ok {
|
||||||
if k == cnf.AuthSC {
|
if k == cnf.AuthSC {
|
||||||
if err = d.perms(ctx, d.initial); err != nil {
|
if err = d.perms(ctx, doc); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to copy the document so that
|
|
||||||
// we can add and remove the fields which
|
|
||||||
// are relevant to the particular query.
|
|
||||||
|
|
||||||
doc = d.initial.Copy()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *document) cnow(ctx context.Context) (doc *data.Doc, err error) {
|
func (d *document) cnow(ctx context.Context) (doc *data.Doc, err error) {
|
||||||
|
|
||||||
|
// We need to copy the document so that
|
||||||
|
// we can add and remove the fields which
|
||||||
|
// are relevant to the particular query.
|
||||||
|
|
||||||
|
doc = d.current.Copy()
|
||||||
|
|
||||||
// If we are not authenticated using DB,
|
// If we are not authenticated using DB,
|
||||||
// NS, or KV level, then we need to check
|
// NS, or KV level, then we need to check
|
||||||
// document permissions for this query.
|
// document permissions for this query.
|
||||||
|
|
||||||
if k, ok := ctx.Value(ctxKeyKind).(cnf.Kind); ok {
|
if k, ok := ctx.Value(ctxKeyKind).(cnf.Kind); ok {
|
||||||
if k == cnf.AuthSC {
|
if k == cnf.AuthSC {
|
||||||
if err = d.perms(ctx, d.current); err != nil {
|
if err = d.perms(ctx, doc); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to copy the document so that
|
|
||||||
// we can add and remove the fields which
|
|
||||||
// are relevant to the particular query.
|
|
||||||
|
|
||||||
doc = d.current.Copy()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue