mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-02 22:25:44 +00:00
throw unauthorized error instead of 500 for permission denied
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
|||||||
SecretNotFoundError,
|
SecretNotFoundError,
|
||||||
SecretBlindIndexDataNotFoundError,
|
SecretBlindIndexDataNotFoundError,
|
||||||
InternalServerError,
|
InternalServerError,
|
||||||
|
UnauthorizedRequestError,
|
||||||
} from "../utils/errors";
|
} from "../utils/errors";
|
||||||
import {
|
import {
|
||||||
SECRET_PERSONAL,
|
SECRET_PERSONAL,
|
||||||
@@ -302,7 +303,7 @@ export const createSecretHelper = async ({
|
|||||||
if (authData.authPayload instanceof ServiceTokenData) {
|
if (authData.authPayload instanceof ServiceTokenData) {
|
||||||
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
||||||
if (secretPath !== serviceTkScopedSecretPath) {
|
if (secretPath !== serviceTkScopedSecretPath) {
|
||||||
throw new Error("Folder Permission Denied");
|
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const folderId = await getFolderIdFromServiceToken(
|
const folderId = await getFolderIdFromServiceToken(
|
||||||
@@ -454,7 +455,7 @@ export const getSecretsHelper = async ({
|
|||||||
if (authData.authPayload instanceof ServiceTokenData) {
|
if (authData.authPayload instanceof ServiceTokenData) {
|
||||||
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
||||||
if (secretPath !== serviceTkScopedSecretPath) {
|
if (secretPath !== serviceTkScopedSecretPath) {
|
||||||
throw new Error("Folder Permission Denied");
|
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const folderId = await getFolderIdFromServiceToken(
|
const folderId = await getFolderIdFromServiceToken(
|
||||||
@@ -551,7 +552,7 @@ export const getSecretHelper = async ({
|
|||||||
if (authData.authPayload instanceof ServiceTokenData) {
|
if (authData.authPayload instanceof ServiceTokenData) {
|
||||||
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
||||||
if (secretPath !== serviceTkScopedSecretPath) {
|
if (secretPath !== serviceTkScopedSecretPath) {
|
||||||
throw new Error("Folder Permission Denied");
|
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const folderId = await getFolderIdFromServiceToken(
|
const folderId = await getFolderIdFromServiceToken(
|
||||||
@@ -658,7 +659,7 @@ export const updateSecretHelper = async ({
|
|||||||
if (authData.authPayload instanceof ServiceTokenData) {
|
if (authData.authPayload instanceof ServiceTokenData) {
|
||||||
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
||||||
if (secretPath !== serviceTkScopedSecretPath) {
|
if (secretPath !== serviceTkScopedSecretPath) {
|
||||||
throw new Error("Folder Permission Denied");
|
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const folderId = await getFolderIdFromServiceToken(
|
const folderId = await getFolderIdFromServiceToken(
|
||||||
@@ -811,7 +812,7 @@ export const deleteSecretHelper = async ({
|
|||||||
if (authData.authPayload instanceof ServiceTokenData) {
|
if (authData.authPayload instanceof ServiceTokenData) {
|
||||||
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
const { secretPath: serviceTkScopedSecretPath } = authData.authPayload;
|
||||||
if (secretPath !== serviceTkScopedSecretPath) {
|
if (secretPath !== serviceTkScopedSecretPath) {
|
||||||
throw new Error("Folder Permission Denied");
|
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const folderId = await getFolderIdFromServiceToken(
|
const folderId = await getFolderIdFromServiceToken(
|
||||||
|
|||||||
Reference in New Issue
Block a user