Skip to content

Commit

Permalink
[server] report internal errors to check permissions (#18964)
Browse files Browse the repository at this point in the history
intead of reporting them as permission denied
  • Loading branch information
akosyakov authored Oct 23, 2023
1 parent 8ac11b1 commit b1a30dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/server/src/authorization/spicedb-authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { base64decode } from "@jmondi/oauth2-server";
import { DecodedZedToken } from "@gitpod/spicedb-impl/lib/impl/v1/impl.pb";
import { RequestContext } from "node-fetch";
import { getRequestContext } from "../util/request-context";
import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";

async function tryThree<T>(errMessage: string, code: (attempt: number) => Promise<T>): Promise<T> {
let attempt = 0;
Expand Down Expand Up @@ -110,7 +111,10 @@ export class SpiceDBAuthorizer {
log.error("[spicedb] Failed to perform authorization check.", err, {
request: new TrustedValue(req),
});
return { permitted: !featureEnabled };
if (!featureEnabled) {
return { permitted: true };
}
throw new ApplicationError(ErrorCodes.INTERNAL_SERVER_ERROR, "Failed to perform authorization check.");
} finally {
observeSpicedbClientLatency("check", error, timer());
}
Expand Down

0 comments on commit b1a30dd

Please sign in to comment.