Skip to content

Commit

Permalink
[fga] add more logging to track down sharing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
svenefftinge committed Sep 20, 2023
1 parent a2b5b00 commit 51a6c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions components/server/src/authorization/spicedb-authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,28 @@ export class SpiceDBAuthorizer {
},
): Promise<boolean> {
const featureEnabled = await isFgaChecksEnabled(experimentsFields.userId);
if (!featureEnabled) {
return true;
}
const timer = spicedbClientLatency.startTimer();
let error: Error | undefined;
try {
const response = await tryThree("[spicedb] Failed to perform authorization check.", () =>
this.client.checkPermission(req, this.callOptions),
);
const permitted = response.permissionship === v1.CheckPermissionResponse_Permissionship.HAS_PERMISSION;
if (!permitted && !featureEnabled) {
log.info("[spicedb] Permission denied.", {
response: new TrustedValue(response),
request: new TrustedValue(req),
});
return true;
}

return permitted;
} catch (err) {
error = err;
log.error("[spicedb] Failed to perform authorization check.", err, {
request: new TrustedValue(req),
});
return false;
return !featureEnabled;
} finally {
observeSpicedbClientLatency("check", error, timer());
}
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/workspace/workspace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ export class WorkspaceService {
const client = await this.clientProvider.get(instance.region);
await client.controlAdmission({}, req);
}

log.info({ userId, workspaceId }, "Admission level changed", { level });
await this.db.transaction(async (db) => {
const shareable = level === "everyone";
await db.updatePartial(workspaceId, { shareable });
Expand Down

0 comments on commit 51a6c4b

Please sign in to comment.