Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fga] add more logging to track down sharing issue #18756

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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