@@ -158,15 +158,15 @@ func (f *fga) ApplyPatch(ctx context.Context, name string) error {
158
158
}
159
159
160
160
if ! resp .GetAllowed () {
161
- err = f .updateTuples (ctx , []client.ClientTupleKey {
161
+ err = f .sendTuples (ctx , []client.ClientTupleKey {
162
162
{User : "user:*" , Relation : "authenticated" , Object : ObjectServer ().String ()},
163
163
}, nil )
164
164
if err != nil {
165
165
return err
166
166
}
167
167
168
168
// Attempt to clear the former version of this permission.
169
- _ = f .updateTuples (ctx , nil , []client.ClientTupleKeyWithoutCondition {
169
+ _ = f .sendTuples (ctx , nil , []client.ClientTupleKeyWithoutCondition {
170
170
{User : "user:*" , Relation : "viewer" , Object : ObjectServer ().String ()},
171
171
})
172
172
}
@@ -210,7 +210,7 @@ func (f *fga) connect(ctx context.Context, certificateCache *certificate.Cache,
210
210
}
211
211
212
212
// Allow basic authenticated access.
213
- err = f .updateTuples (ctx , []client.ClientTupleKey {
213
+ err = f .sendTuples (ctx , []client.ClientTupleKey {
214
214
{User : "user:*" , Relation : "authenticated" , Object : ObjectServer ().String ()},
215
215
}, nil )
216
216
if err != nil {
@@ -866,6 +866,7 @@ func (f *fga) DeleteStorageBucket(ctx context.Context, projectName string, stora
866
866
return f .updateTuples (ctx , nil , deletions )
867
867
}
868
868
869
+ // updateTuples sends an object update to OpenFGA if it's currently online.
869
870
func (f * fga ) updateTuples (ctx context.Context , writes []client.ClientTupleKey , deletions []client.ClientTupleKeyWithoutCondition ) error {
870
871
// If offline, skip updating as a full sync will happen after connection.
871
872
if ! f .online {
@@ -876,6 +877,11 @@ func (f *fga) updateTuples(ctx context.Context, writes []client.ClientTupleKey,
876
877
return nil
877
878
}
878
879
880
+ return f .sendTuples (ctx , writes , deletions )
881
+ }
882
+
883
+ // sendTuples directly sends the write/deletion tuples to OpenFGA.
884
+ func (f * fga ) sendTuples (ctx context.Context , writes []client.ClientTupleKey , deletions []client.ClientTupleKeyWithoutCondition ) error {
879
885
ctx , cancel := context .WithTimeout (ctx , 10 * time .Second )
880
886
defer cancel ()
881
887
0 commit comments