mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 06:45:28 +00:00
103 lines
2.7 KiB
TypeScript
103 lines
2.7 KiB
TypeScript
import express from "express";
|
|
const router = express.Router();
|
|
import {
|
|
requireAuth,
|
|
requireMembershipOrgAuth,
|
|
requireOrganizationAuth,
|
|
validateRequest,
|
|
} from "../../middleware";
|
|
import { body, param } from "express-validator";
|
|
import {
|
|
ACCEPTED,
|
|
ADMIN,
|
|
AUTH_MODE_API_KEY,
|
|
AUTH_MODE_JWT,
|
|
MEMBER,
|
|
OWNER,
|
|
} from "../../variables";
|
|
import { organizationsController } from "../../controllers/v2";
|
|
|
|
// TODO: /POST to create membership
|
|
|
|
router.get(
|
|
"/:organizationId/memberships",
|
|
param("organizationId").exists().trim(),
|
|
validateRequest,
|
|
requireAuth({
|
|
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
|
}),
|
|
requireOrganizationAuth({
|
|
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
organizationsController.getOrganizationMemberships
|
|
);
|
|
|
|
router.patch(
|
|
"/:organizationId/memberships/:membershipId",
|
|
param("organizationId").exists().trim(),
|
|
param("membershipId").exists().trim(),
|
|
body("role").exists().isString().trim().isIn([OWNER, ADMIN, MEMBER]),
|
|
validateRequest,
|
|
requireAuth({
|
|
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
|
}),
|
|
requireOrganizationAuth({
|
|
acceptedRoles: [OWNER, ADMIN],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
requireMembershipOrgAuth({
|
|
acceptedRoles: [OWNER, ADMIN],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
organizationsController.updateOrganizationMembership
|
|
);
|
|
|
|
router.delete(
|
|
"/:organizationId/memberships/:membershipId",
|
|
param("organizationId").exists().trim(),
|
|
param("membershipId").exists().trim(),
|
|
validateRequest,
|
|
requireAuth({
|
|
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
|
}),
|
|
requireOrganizationAuth({
|
|
acceptedRoles: [OWNER, ADMIN],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
requireMembershipOrgAuth({
|
|
acceptedRoles: [OWNER, ADMIN],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
organizationsController.deleteOrganizationMembership
|
|
);
|
|
|
|
router.get(
|
|
"/:organizationId/workspaces",
|
|
param("organizationId").exists().trim(),
|
|
validateRequest,
|
|
requireAuth({
|
|
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
|
}),
|
|
requireOrganizationAuth({
|
|
acceptedRoles: [OWNER, ADMIN],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
organizationsController.getOrganizationWorkspaces
|
|
);
|
|
|
|
router.get(
|
|
"/:organizationId/service-accounts",
|
|
param("organizationId").exists().trim(),
|
|
validateRequest,
|
|
requireAuth({
|
|
acceptedAuthModes: [AUTH_MODE_JWT],
|
|
}),
|
|
requireOrganizationAuth({
|
|
acceptedRoles: [OWNER, ADMIN],
|
|
acceptedStatuses: [ACCEPTED],
|
|
}),
|
|
organizationsController.getOrganizationServiceAccounts
|
|
);
|
|
|
|
export default router; |