authorize: use query instead of sync for databroker data (#3377)

This commit is contained in:
Caleb Doxsey 2022-06-01 15:40:07 -06:00 committed by GitHub
parent fd82cc7870
commit f61e7efe73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 661 additions and 1008 deletions

View file

@ -7,6 +7,7 @@ import (
"io"
"google.golang.org/protobuf/proto"
structpb "google.golang.org/protobuf/types/known/structpb"
"github.com/pomerium/pomerium/pkg/grpcutil"
"github.com/pomerium/pomerium/pkg/protoutil"
@ -118,6 +119,27 @@ func (x *PutResponse) GetRecord() *Record {
return records[0]
}
// SetFilterByID sets the filter to an id.
func (x *QueryRequest) SetFilterByID(id string) {
x.Filter = &structpb.Struct{Fields: map[string]*structpb.Value{
"id": structpb.NewStringValue(id),
}}
}
// SetFilterByIDOrIndex sets the filter to an id or an index.
func (x *QueryRequest) SetFilterByIDOrIndex(idOrIndex string) {
x.Filter = &structpb.Struct{Fields: map[string]*structpb.Value{
"$or": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{
structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
"id": structpb.NewStringValue(idOrIndex),
}}),
structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
"$index": structpb.NewStringValue(idOrIndex),
}}),
}}),
}}
}
// default is 4MB, but we'll do 1MB
const maxMessageSize = 1024 * 1024 * 1