mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 01:05:40 +00:00
Add eslint rule and fix as many issues as possible
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import healthCheck from './status';
|
||||
import healthCheck from "./status";
|
||||
|
||||
export {
|
||||
healthCheck
|
||||
healthCheck,
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { getSmtpConfigured } from '../../config';
|
||||
import express, { Request, Response } from "express";
|
||||
import { getSmtpConfigured } from "../../config";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get(
|
||||
'/status',
|
||||
"/status",
|
||||
async (req: Request, res: Response) => {
|
||||
res.status(200).json({
|
||||
date: new Date(),
|
||||
message: 'Ok',
|
||||
emailConfigured: await getSmtpConfigured()
|
||||
message: "Ok",
|
||||
emailConfigured: await getSmtpConfigured(),
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import passport from 'passport';
|
||||
import { requireAuth, validateRequest } from '../../middleware';
|
||||
import { authController } from '../../controllers/v1';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
import { AUTH_MODE_JWT } from '../../variables';
|
||||
import { body } from "express-validator";
|
||||
import passport from "passport";
|
||||
import { requireAuth, validateRequest } from "../../middleware";
|
||||
import { authController } from "../../controllers/v1";
|
||||
import { authLimiter } from "../../helpers/rateLimiter";
|
||||
import { AUTH_MODE_JWT } from "../../variables";
|
||||
|
||||
router.post('/token', validateRequest, authController.getNewToken);
|
||||
router.post("/token", validateRequest, authController.getNewToken);
|
||||
|
||||
router.post( // deprecated (moved to api/v2/auth/login1)
|
||||
'/login1',
|
||||
"/login1",
|
||||
authLimiter,
|
||||
body('email').exists().trim().notEmpty(),
|
||||
body('clientPublicKey').exists().trim().notEmpty(),
|
||||
body("email").exists().trim().notEmpty(),
|
||||
body("clientPublicKey").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.login1
|
||||
);
|
||||
|
||||
router.post( // deprecated (moved to api/v2/auth/login2)
|
||||
'/login2',
|
||||
"/login2",
|
||||
authLimiter,
|
||||
body('email').exists().trim().notEmpty(),
|
||||
body('clientProof').exists().trim().notEmpty(),
|
||||
body("email").exists().trim().notEmpty(),
|
||||
body("clientProof").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.login2
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/logout',
|
||||
"/logout",
|
||||
authLimiter,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
authController.logout
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/checkAuth',
|
||||
"/checkAuth",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
authController.checkAuth
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/redirect/google',
|
||||
"/redirect/google",
|
||||
authLimiter,
|
||||
passport.authenticate('google', {
|
||||
scope: ['profile', 'email'],
|
||||
passport.authenticate("google", {
|
||||
scope: ["profile", "email"],
|
||||
session: false,
|
||||
}),
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/callback/google',
|
||||
passport.authenticate('google', { failureRedirect: '/login/provider/error', session: false }),
|
||||
"/callback/google",
|
||||
passport.authenticate("google", { failureRedirect: "/login/provider/error", session: false }),
|
||||
authController.handleAuthProviderCallback,
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/common-passwords',
|
||||
"/common-passwords",
|
||||
authLimiter,
|
||||
authController.getCommonPasswords
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/sessions',
|
||||
"/sessions",
|
||||
authLimiter,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
authController.revokeAllSessions
|
||||
);
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param } from 'express-validator';
|
||||
import { body, param } from "express-validator";
|
||||
import {
|
||||
requireAuth,
|
||||
requireBotAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { botController } from '../../controllers/v1';
|
||||
import { ADMIN, MEMBER, AUTH_MODE_JWT } from '../../variables';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { botController } from "../../controllers/v1";
|
||||
import { ADMIN, AUTH_MODE_JWT, MEMBER } from "../../variables";
|
||||
|
||||
router.get(
|
||||
'/:workspaceId',
|
||||
"/:workspaceId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim().notEmpty(),
|
||||
param("workspaceId").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
botController.getBotByWorkspaceId
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/:botId/active',
|
||||
"/:botId/active",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireBotAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
body('isActive').exists().isBoolean(),
|
||||
body('botKey'),
|
||||
body("isActive").exists().isBoolean(),
|
||||
body("botKey"),
|
||||
validateRequest,
|
||||
botController.setBotActiveState
|
||||
);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import signup from './signup';
|
||||
import bot from './bot';
|
||||
import auth from './auth';
|
||||
import user from './user';
|
||||
import userAction from './userAction';
|
||||
import organization from './organization';
|
||||
import workspace from './workspace';
|
||||
import membershipOrg from './membershipOrg';
|
||||
import membership from './membership';
|
||||
import key from './key';
|
||||
import inviteOrg from './inviteOrg';
|
||||
import secret from './secret';
|
||||
import serviceToken from './serviceToken';
|
||||
import password from './password';
|
||||
import stripe from './stripe';
|
||||
import integration from './integration';
|
||||
import integrationAuth from './integrationAuth';
|
||||
import secretsFolder from './secretsFolder';
|
||||
import signup from "./signup";
|
||||
import bot from "./bot";
|
||||
import auth from "./auth";
|
||||
import user from "./user";
|
||||
import userAction from "./userAction";
|
||||
import organization from "./organization";
|
||||
import workspace from "./workspace";
|
||||
import membershipOrg from "./membershipOrg";
|
||||
import membership from "./membership";
|
||||
import key from "./key";
|
||||
import inviteOrg from "./inviteOrg";
|
||||
import secret from "./secret";
|
||||
import serviceToken from "./serviceToken";
|
||||
import password from "./password";
|
||||
import stripe from "./stripe";
|
||||
import integration from "./integration";
|
||||
import integrationAuth from "./integrationAuth";
|
||||
import secretsFolder from "./secretsFolder";
|
||||
|
||||
export {
|
||||
signup,
|
||||
@@ -35,5 +35,5 @@ export {
|
||||
stripe,
|
||||
integration,
|
||||
integrationAuth,
|
||||
secretsFolder
|
||||
secretsFolder,
|
||||
};
|
||||
|
||||
@@ -8,9 +8,9 @@ import {
|
||||
} from "../../middleware";
|
||||
import {
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
} from "../../variables";
|
||||
import { body, param } from "express-validator";
|
||||
import { integrationController } from "../../controllers/v1";
|
||||
|
||||
@@ -1,156 +1,156 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param, query } from 'express-validator';
|
||||
import { body, param, query } from "express-validator";
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireIntegrationAuthorizationAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import {
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_API_KEY
|
||||
} from '../../variables';
|
||||
import { integrationAuthController } from '../../controllers/v1';
|
||||
MEMBER,
|
||||
} from "../../variables";
|
||||
import { integrationAuthController } from "../../controllers/v1";
|
||||
|
||||
router.get(
|
||||
'/integration-options',
|
||||
"/integration-options",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
integrationAuthController.getIntegrationOptions
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:integrationAuthId',
|
||||
"/:integrationAuthId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
param('integrationAuthId'),
|
||||
param("integrationAuthId"),
|
||||
validateRequest,
|
||||
integrationAuthController.getIntegrationAuth
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/oauth-token',
|
||||
"/oauth-token",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'body'
|
||||
locationWorkspaceId: "body",
|
||||
}),
|
||||
body('workspaceId').exists().trim().notEmpty(),
|
||||
body('code').exists().trim().notEmpty(),
|
||||
body('integration').exists().trim().notEmpty(),
|
||||
body("workspaceId").exists().trim().notEmpty(),
|
||||
body("code").exists().trim().notEmpty(),
|
||||
body("integration").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
integrationAuthController.oAuthExchange
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/access-token',
|
||||
body('workspaceId').exists().trim().notEmpty(),
|
||||
body('accessId').trim(),
|
||||
body('accessToken').exists().trim().notEmpty(),
|
||||
body('url').trim(),
|
||||
body('namespace').trim(),
|
||||
body('integration').exists().trim().notEmpty(),
|
||||
"/access-token",
|
||||
body("workspaceId").exists().trim().notEmpty(),
|
||||
body("accessId").trim(),
|
||||
body("accessToken").exists().trim().notEmpty(),
|
||||
body("url").trim(),
|
||||
body("namespace").trim(),
|
||||
body("integration").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'body'
|
||||
locationWorkspaceId: "body",
|
||||
}),
|
||||
integrationAuthController.saveIntegrationAccessToken
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:integrationAuthId/apps',
|
||||
"/:integrationAuthId/apps",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
param('integrationAuthId'),
|
||||
query('teamId'),
|
||||
param("integrationAuthId"),
|
||||
query("teamId"),
|
||||
validateRequest,
|
||||
integrationAuthController.getIntegrationAuthApps
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:integrationAuthId/teams',
|
||||
"/:integrationAuthId/teams",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
param('integrationAuthId'),
|
||||
param("integrationAuthId"),
|
||||
validateRequest,
|
||||
integrationAuthController.getIntegrationAuthTeams
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:integrationAuthId/vercel/branches',
|
||||
"/:integrationAuthId/vercel/branches",
|
||||
requireAuth({
|
||||
acceptedAuthModes: ['jwt']
|
||||
acceptedAuthModes: ["jwt"],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
param('integrationAuthId').exists().isString(),
|
||||
query('appId').exists().isString(),
|
||||
query('teamId').optional().isString(),
|
||||
param("integrationAuthId").exists().isString(),
|
||||
query("appId").exists().isString(),
|
||||
query("teamId").optional().isString(),
|
||||
validateRequest,
|
||||
integrationAuthController.getIntegrationAuthVercelBranches
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:integrationAuthId/railway/environments',
|
||||
"/:integrationAuthId/railway/environments",
|
||||
requireAuth({
|
||||
acceptedAuthModes: ['jwt']
|
||||
acceptedAuthModes: ["jwt"],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
param('integrationAuthId').exists().isString(),
|
||||
query('appId').exists().isString(),
|
||||
param("integrationAuthId").exists().isString(),
|
||||
query("appId").exists().isString(),
|
||||
validateRequest,
|
||||
integrationAuthController.getIntegrationAuthRailwayEnvironments
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:integrationAuthId/railway/services',
|
||||
"/:integrationAuthId/railway/services",
|
||||
requireAuth({
|
||||
acceptedAuthModes: ['jwt']
|
||||
acceptedAuthModes: ["jwt"],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER]
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
}),
|
||||
param('integrationAuthId').exists().isString(),
|
||||
query('appId').exists().isString(),
|
||||
param("integrationAuthId").exists().isString(),
|
||||
query("appId").exists().isString(),
|
||||
validateRequest,
|
||||
integrationAuthController.getIntegrationAuthRailwayServices
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:integrationAuthId',
|
||||
"/:integrationAuthId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireIntegrationAuthorizationAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
attachAccessToken: false
|
||||
attachAccessToken: false,
|
||||
}),
|
||||
param('integrationAuthId'),
|
||||
param("integrationAuthId"),
|
||||
validateRequest,
|
||||
integrationAuthController.deleteIntegrationAuth
|
||||
);
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import { requireAuth, validateRequest } from '../../middleware';
|
||||
import { membershipOrgController } from '../../controllers/v1';
|
||||
import { AUTH_MODE_JWT } from '../../variables';
|
||||
import { body } from "express-validator";
|
||||
import { requireAuth, validateRequest } from "../../middleware";
|
||||
import { membershipOrgController } from "../../controllers/v1";
|
||||
import { AUTH_MODE_JWT } from "../../variables";
|
||||
|
||||
router.post(
|
||||
'/signup',
|
||||
"/signup",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('inviteeEmail').exists().trim().notEmpty().isEmail(),
|
||||
body('organizationId').exists().trim().notEmpty(),
|
||||
body("inviteeEmail").exists().trim().notEmpty().isEmail(),
|
||||
body("organizationId").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
membershipOrgController.inviteUserToOrganization
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/verify',
|
||||
body('email').exists().trim().notEmpty(),
|
||||
body('organizationId').exists().trim().notEmpty(),
|
||||
body('code').exists().trim().notEmpty(),
|
||||
"/verify",
|
||||
body("email").exists().trim().notEmpty(),
|
||||
body("organizationId").exists().trim().notEmpty(),
|
||||
body("code").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
membershipOrgController.verifyUserToOrganization
|
||||
);
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { body, param } from 'express-validator';
|
||||
import { ADMIN, MEMBER, AUTH_MODE_JWT } from '../../variables';
|
||||
import { keyController } from '../../controllers/v1';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body, param } from "express-validator";
|
||||
import { ADMIN, AUTH_MODE_JWT, MEMBER } from "../../variables";
|
||||
import { keyController } from "../../controllers/v1";
|
||||
|
||||
router.post(
|
||||
'/:workspaceId',
|
||||
"/:workspaceId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('key').exists(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("key").exists(),
|
||||
validateRequest,
|
||||
keyController.uploadKey
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/latest',
|
||||
"/:workspaceId/latest",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId'),
|
||||
param("workspaceId"),
|
||||
validateRequest,
|
||||
keyController.getLatestKey
|
||||
);
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param } from 'express-validator';
|
||||
import { requireAuth, validateRequest } from '../../middleware';
|
||||
import { membershipController } from '../../controllers/v1';
|
||||
import { membershipController as EEMembershipControllers } from '../../ee/controllers/v1';
|
||||
import { AUTH_MODE_JWT } from '../../variables';
|
||||
import { body, param } from "express-validator";
|
||||
import { requireAuth, validateRequest } from "../../middleware";
|
||||
import { membershipController } from "../../controllers/v1";
|
||||
import { membershipController as EEMembershipControllers } from "../../ee/controllers/v1";
|
||||
import { AUTH_MODE_JWT } from "../../variables";
|
||||
|
||||
// note: ALL DEPRECIATED (moved to api/v2/workspace/:workspaceId/memberships/:membershipId)
|
||||
|
||||
router.get( // used for old CLI (deprecate)
|
||||
'/:workspaceId/connect',
|
||||
"/:workspaceId/connect",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
membershipController.validateMembership
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:membershipId',
|
||||
"/:membershipId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('membershipId').exists().trim(),
|
||||
param("membershipId").exists().trim(),
|
||||
validateRequest,
|
||||
membershipController.deleteMembership
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:membershipId/change-role',
|
||||
"/:membershipId/change-role",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('role').exists().trim(),
|
||||
body("role").exists().trim(),
|
||||
validateRequest,
|
||||
membershipController.changeMembershipRole
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:membershipId/deny-permissions',
|
||||
"/:membershipId/deny-permissions",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('membershipId').isMongoId().exists().trim(),
|
||||
body('permissions').isArray().exists(),
|
||||
param("membershipId").isMongoId().exists().trim(),
|
||||
body("permissions").isArray().exists(),
|
||||
validateRequest,
|
||||
EEMembershipControllers.denyMembershipPermissions
|
||||
);
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { param } from 'express-validator';
|
||||
import { requireAuth, validateRequest } from '../../middleware';
|
||||
import { membershipOrgController } from '../../controllers/v1';
|
||||
import { AUTH_MODE_JWT } from '../../variables';
|
||||
import { param } from "express-validator";
|
||||
import { requireAuth, validateRequest } from "../../middleware";
|
||||
import { membershipOrgController } from "../../controllers/v1";
|
||||
import { AUTH_MODE_JWT } from "../../variables";
|
||||
|
||||
router.post(
|
||||
// TODO
|
||||
'/membershipOrg/:membershipOrgId/change-role',
|
||||
"/membershipOrg/:membershipOrgId/change-role",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('membershipOrgId'),
|
||||
param("membershipOrgId"),
|
||||
validateRequest,
|
||||
membershipOrgController.changeMembershipOrgRole
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:membershipOrgId',
|
||||
"/:membershipOrgId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('membershipOrgId').exists().trim(),
|
||||
param("membershipOrgId").exists().trim(),
|
||||
validateRequest,
|
||||
membershipOrgController.deleteMembershipOrg
|
||||
);
|
||||
|
||||
@@ -1,177 +1,177 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param } from 'express-validator';
|
||||
import { body, param } from "express-validator";
|
||||
import {
|
||||
requireAuth,
|
||||
requireOrganizationAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import {
|
||||
OWNER,
|
||||
ACCEPTED,
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
ACCEPTED,
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
import { organizationController } from '../../controllers/v1';
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
OWNER,
|
||||
} from "../../variables";
|
||||
import { organizationController } from "../../controllers/v1";
|
||||
|
||||
router.get( // deprecated (moved to api/v2/users/me/organizations)
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
organizationController.getOrganizations
|
||||
);
|
||||
|
||||
router.post( // not used on frontend
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('organizationName').exists().trim().notEmpty(),
|
||||
body("organizationName").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
organizationController.createOrganization
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId',
|
||||
"/:organizationId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.getOrganization
|
||||
);
|
||||
|
||||
router.get( // deprecated (moved to api/v2/organizations/:organizationId/memberships)
|
||||
'/:organizationId/users',
|
||||
"/:organizationId/users",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.getOrganizationMembers
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId/my-workspaces', // deprecated (moved to api/v2/organizations/:organizationId/workspaces)
|
||||
"/:organizationId/my-workspaces", // deprecated (moved to api/v2/organizations/:organizationId/workspaces)
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.getOrganizationWorkspaces
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/:organizationId/name',
|
||||
"/:organizationId/name",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
body('name').exists().trim().notEmpty(),
|
||||
param("organizationId").exists().trim(),
|
||||
body("name").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
organizationController.changeOrganizationName
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId/incidentContactOrg',
|
||||
"/:organizationId/incidentContactOrg",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.getOrganizationIncidentContacts
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:organizationId/incidentContactOrg',
|
||||
"/:organizationId/incidentContactOrg",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
body('email').exists().trim().notEmpty(),
|
||||
param("organizationId").exists().trim(),
|
||||
body("email").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
organizationController.addOrganizationIncidentContact
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:organizationId/incidentContactOrg',
|
||||
"/:organizationId/incidentContactOrg",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
body('email').exists().trim().notEmpty(),
|
||||
param("organizationId").exists().trim(),
|
||||
body("email").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
organizationController.deleteOrganizationIncidentContact
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:organizationId/customer-portal-session',
|
||||
"/:organizationId/customer-portal-session",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.createOrganizationPortalSession
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId/subscriptions',
|
||||
"/:organizationId/subscriptions",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.getOrganizationSubscriptions
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId/workspace-memberships',
|
||||
"/:organizationId/workspace-memberships",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
param('organizationId').exists().trim(),
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
organizationController.getOrganizationMembersAndTheirWorkspaces
|
||||
);
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import { requireAuth, requireSignupAuth, validateRequest } from '../../middleware';
|
||||
import { passwordController } from '../../controllers/v1';
|
||||
import { passwordLimiter } from '../../helpers/rateLimiter';
|
||||
import { body } from "express-validator";
|
||||
import { requireAuth, requireSignupAuth, validateRequest } from "../../middleware";
|
||||
import { passwordController } from "../../controllers/v1";
|
||||
import { passwordLimiter } from "../../helpers/rateLimiter";
|
||||
import {
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
AUTH_MODE_JWT,
|
||||
} from "../../variables";
|
||||
|
||||
router.post(
|
||||
'/srp1',
|
||||
"/srp1",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('clientPublicKey').exists().isString().trim().notEmpty(),
|
||||
body("clientPublicKey").exists().isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
passwordController.srp1
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/change-password',
|
||||
"/change-password",
|
||||
passwordLimiter,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('clientProof').exists().trim().notEmpty(),
|
||||
body('protectedKey').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKey').exists().isString().trim().notEmpty(), // private key encrypted under new pwd
|
||||
body('encryptedPrivateKeyIV').exists().isString().trim().notEmpty(), // new iv for private key
|
||||
body('encryptedPrivateKeyTag').exists().isString().trim().notEmpty(), // new tag for private key
|
||||
body('salt').exists().isString().trim().notEmpty(), // part of new pwd
|
||||
body('verifier').exists().isString().trim().notEmpty(), // part of new pwd
|
||||
body("clientProof").exists().trim().notEmpty(),
|
||||
body("protectedKey").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKey").exists().isString().trim().notEmpty(), // private key encrypted under new pwd
|
||||
body("encryptedPrivateKeyIV").exists().isString().trim().notEmpty(), // new iv for private key
|
||||
body("encryptedPrivateKeyTag").exists().isString().trim().notEmpty(), // new tag for private key
|
||||
body("salt").exists().isString().trim().notEmpty(), // part of new pwd
|
||||
body("verifier").exists().isString().trim().notEmpty(), // part of new pwd
|
||||
validateRequest,
|
||||
passwordController.changePassword
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/email/password-reset',
|
||||
"/email/password-reset",
|
||||
passwordLimiter,
|
||||
body('email').exists().isString().trim().notEmpty().isEmail(),
|
||||
body("email").exists().isString().trim().notEmpty().isEmail(),
|
||||
validateRequest,
|
||||
passwordController.emailPasswordReset
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/email/password-reset-verify',
|
||||
"/email/password-reset-verify",
|
||||
passwordLimiter,
|
||||
body('email').exists().isString().trim().notEmpty().isEmail(),
|
||||
body('code').exists().isString().trim().notEmpty(),
|
||||
body("email").exists().isString().trim().notEmpty().isEmail(),
|
||||
body("code").exists().isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
passwordController.emailPasswordResetVerify
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/backup-private-key',
|
||||
"/backup-private-key",
|
||||
passwordLimiter,
|
||||
requireSignupAuth,
|
||||
passwordController.getBackupPrivateKey
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/backup-private-key',
|
||||
"/backup-private-key",
|
||||
passwordLimiter,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('clientProof').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKey').exists().isString().trim().notEmpty(), // (backup) private key encrypted under a strong key
|
||||
body('iv').exists().isString().trim().notEmpty(), // new iv for (backup) private key
|
||||
body('tag').exists().isString().trim().notEmpty(), // new tag for (backup) private key
|
||||
body('salt').exists().isString().trim().notEmpty(), // salt generated from strong key
|
||||
body('verifier').exists().isString().trim().notEmpty(), // salt generated from strong key
|
||||
body("clientProof").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKey").exists().isString().trim().notEmpty(), // (backup) private key encrypted under a strong key
|
||||
body("iv").exists().isString().trim().notEmpty(), // new iv for (backup) private key
|
||||
body("tag").exists().isString().trim().notEmpty(), // new tag for (backup) private key
|
||||
body("salt").exists().isString().trim().notEmpty(), // salt generated from strong key
|
||||
body("verifier").exists().isString().trim().notEmpty(), // salt generated from strong key
|
||||
validateRequest,
|
||||
passwordController.createBackupPrivateKey
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/password-reset',
|
||||
"/password-reset",
|
||||
requireSignupAuth,
|
||||
body('protectedKey').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKey').exists().isString().trim().notEmpty(), // private key encrypted under new pwd
|
||||
body('encryptedPrivateKeyIV').exists().isString().trim().notEmpty(), // new iv for private key
|
||||
body('encryptedPrivateKeyTag').exists().isString().trim().notEmpty(), // new tag for private key
|
||||
body('salt').exists().isString().trim().notEmpty(), // part of new pwd
|
||||
body('verifier').exists().isString().trim().notEmpty(), // part of new pwd
|
||||
body("protectedKey").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKey").exists().isString().trim().notEmpty(), // private key encrypted under new pwd
|
||||
body("encryptedPrivateKeyIV").exists().isString().trim().notEmpty(), // new iv for private key
|
||||
body("encryptedPrivateKeyTag").exists().isString().trim().notEmpty(), // new tag for private key
|
||||
body("salt").exists().isString().trim().notEmpty(), // part of new pwd
|
||||
body("verifier").exists().isString().trim().notEmpty(), // part of new pwd
|
||||
validateRequest,
|
||||
passwordController.resetPassword
|
||||
);
|
||||
|
||||
@@ -1,61 +1,61 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireServiceTokenAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { body, query, param } from 'express-validator';
|
||||
import { secretController } from '../../controllers/v1';
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body, param, query } from "express-validator";
|
||||
import { secretController } from "../../controllers/v1";
|
||||
import {
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
} from "../../variables";
|
||||
|
||||
// note to devs: these endpoints will be deprecated in favor of v2
|
||||
|
||||
router.post(
|
||||
'/:workspaceId',
|
||||
"/:workspaceId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
body('secrets').exists(),
|
||||
body('keys').exists(),
|
||||
body('environment').exists().trim().notEmpty(),
|
||||
body('channel'),
|
||||
param('workspaceId').exists().trim(),
|
||||
body("secrets").exists(),
|
||||
body("keys").exists(),
|
||||
body("environment").exists().trim().notEmpty(),
|
||||
body("channel"),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
secretController.pushSecrets
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId',
|
||||
"/:workspaceId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
query('environment').exists().trim(),
|
||||
query('channel'),
|
||||
param('workspaceId').exists().trim(),
|
||||
query("environment").exists().trim(),
|
||||
query("channel"),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
secretController.pullSecrets
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/service-token',
|
||||
"/:workspaceId/service-token",
|
||||
requireServiceTokenAuth,
|
||||
query('environment').exists().trim(),
|
||||
query('channel'),
|
||||
param('workspaceId').exists().trim(),
|
||||
query("environment").exists().trim(),
|
||||
query("channel"),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
secretController.pullSecretsServiceToken
|
||||
);
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireServiceTokenAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { body } from 'express-validator';
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body } from "express-validator";
|
||||
import {
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
import { serviceTokenController } from '../../controllers/v1';
|
||||
} from "../../variables";
|
||||
import { serviceTokenController } from "../../controllers/v1";
|
||||
|
||||
// note: deprecate service-token routes in favor of service-token data routes/structure
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
"/",
|
||||
requireServiceTokenAuth,
|
||||
serviceTokenController.getServiceToken
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'body'
|
||||
locationWorkspaceId: "body",
|
||||
}),
|
||||
body('name').exists().trim().notEmpty(),
|
||||
body('workspaceId').exists().trim().notEmpty(),
|
||||
body('environment').exists().trim().notEmpty(),
|
||||
body('expiresIn'), // measured in ms
|
||||
body('publicKey').exists().trim().notEmpty(),
|
||||
body('encryptedKey').exists().trim().notEmpty(),
|
||||
body('nonce').exists().trim().notEmpty(),
|
||||
body("name").exists().trim().notEmpty(),
|
||||
body("workspaceId").exists().trim().notEmpty(),
|
||||
body("environment").exists().trim().notEmpty(),
|
||||
body("expiresIn"), // measured in ms
|
||||
body("publicKey").exists().trim().notEmpty(),
|
||||
body("encryptedKey").exists().trim().notEmpty(),
|
||||
body("nonce").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
serviceTokenController.createServiceToken
|
||||
);
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import { validateRequest } from '../../middleware';
|
||||
import { signupController } from '../../controllers/v1';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
import { body } from "express-validator";
|
||||
import { validateRequest } from "../../middleware";
|
||||
import { signupController } from "../../controllers/v1";
|
||||
import { authLimiter } from "../../helpers/rateLimiter";
|
||||
|
||||
router.post(
|
||||
'/email/signup',
|
||||
"/email/signup",
|
||||
authLimiter,
|
||||
body('email').exists().trim().notEmpty().isEmail(),
|
||||
body("email").exists().trim().notEmpty().isEmail(),
|
||||
validateRequest,
|
||||
signupController.beginEmailSignup
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/email/verify',
|
||||
"/email/verify",
|
||||
authLimiter,
|
||||
body('email').exists().trim().notEmpty().isEmail(),
|
||||
body('code').exists().trim().notEmpty(),
|
||||
body("email").exists().trim().notEmpty().isEmail(),
|
||||
body("code").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
signupController.verifyEmailSignup
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { stripeController } from '../../controllers/v1';
|
||||
import { stripeController } from "../../controllers/v1";
|
||||
|
||||
router.post('/webhook', stripeController.handleWebhook);
|
||||
router.post("/webhook", stripeController.handleWebhook);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { requireAuth } from '../../middleware';
|
||||
import { userController } from '../../controllers/v1';
|
||||
import { requireAuth } from "../../middleware";
|
||||
import { userController } from "../../controllers/v1";
|
||||
import {
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
AUTH_MODE_JWT,
|
||||
} from "../../variables";
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
userController.getUser
|
||||
);
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { requireAuth, validateRequest } from '../../middleware';
|
||||
import { body, query } from 'express-validator';
|
||||
import { userActionController } from '../../controllers/v1';
|
||||
import { AUTH_MODE_JWT } from '../../variables';
|
||||
import { requireAuth, validateRequest } from "../../middleware";
|
||||
import { body, query } from "express-validator";
|
||||
import { userActionController } from "../../controllers/v1";
|
||||
import { AUTH_MODE_JWT } from "../../variables";
|
||||
|
||||
// note: [userAction] will be deprecated in /v2 in favor of [action]
|
||||
router.post(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('action'),
|
||||
body("action"),
|
||||
validateRequest,
|
||||
userActionController.addUserAction
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
query('action'),
|
||||
query("action"),
|
||||
validateRequest,
|
||||
userActionController.getUserAction
|
||||
);
|
||||
|
||||
@@ -1,161 +1,161 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param, query } from 'express-validator';
|
||||
import { body, param } from "express-validator";
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import {
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
import { workspaceController, membershipController } from '../../controllers/v1';
|
||||
} from "../../variables";
|
||||
import { membershipController, workspaceController } from "../../controllers/v1";
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/keys',
|
||||
"/:workspaceId/keys",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspacePublicKeys
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/users',
|
||||
"/:workspaceId/users",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspaceMemberships
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
workspaceController.getWorkspaces
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId',
|
||||
"/:workspaceId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspace
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('workspaceName').exists().trim().notEmpty(),
|
||||
body('organizationId').exists().trim().notEmpty(),
|
||||
body("workspaceName").exists().trim().notEmpty(),
|
||||
body("organizationId").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
workspaceController.createWorkspace
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:workspaceId',
|
||||
"/:workspaceId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.deleteWorkspace
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:workspaceId/name',
|
||||
"/:workspaceId/name",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('name').exists().trim().notEmpty(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("name").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
workspaceController.changeWorkspaceName
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:workspaceId/invite-signup',
|
||||
"/:workspaceId/invite-signup",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('email').exists().trim().notEmpty(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("email").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
membershipController.inviteUserToWorkspace
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/integrations',
|
||||
"/:workspaceId/integrations",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspaceIntegrations
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/authorizations',
|
||||
"/:workspaceId/authorizations",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspaceIntegrationAuthorizations
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/service-tokens', // deprecate
|
||||
"/:workspaceId/service-tokens", // deprecate
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspaceServiceTokens
|
||||
);
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { param, body } from 'express-validator';
|
||||
import { body, param } from "express-validator";
|
||||
import {
|
||||
requireAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { apiKeyDataController } from '../../controllers/v2';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { apiKeyDataController } from "../../controllers/v2";
|
||||
import {
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
AUTH_MODE_JWT,
|
||||
} from "../../variables";
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
apiKeyDataController.getAPIKeyData
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/',
|
||||
"/",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('name').exists().trim(),
|
||||
body('expiresIn'), // measured in ms
|
||||
body("name").exists().trim(),
|
||||
body("expiresIn"), // measured in ms
|
||||
validateRequest,
|
||||
apiKeyDataController.createAPIKeyData
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:apiKeyDataId',
|
||||
"/:apiKeyDataId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('apiKeyDataId').exists().trim(),
|
||||
param("apiKeyDataId").exists().trim(),
|
||||
validateRequest,
|
||||
apiKeyDataController.deleteAPIKeyData
|
||||
);
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import { requireMfaAuth, validateRequest } from '../../middleware';
|
||||
import { authController } from '../../controllers/v2';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
import { body } from "express-validator";
|
||||
import { requireMfaAuth, validateRequest } from "../../middleware";
|
||||
import { authController } from "../../controllers/v2";
|
||||
import { authLimiter } from "../../helpers/rateLimiter";
|
||||
|
||||
router.post(
|
||||
'/login1',
|
||||
"/login1",
|
||||
authLimiter,
|
||||
body('email').isString().trim().notEmpty(),
|
||||
body('clientPublicKey').isString().trim().notEmpty(),
|
||||
body("email").isString().trim().notEmpty(),
|
||||
body("clientPublicKey").isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.login1
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/login2',
|
||||
"/login2",
|
||||
authLimiter,
|
||||
body('email').isString().trim().notEmpty(),
|
||||
body('clientProof').isString().trim().notEmpty(),
|
||||
body("email").isString().trim().notEmpty(),
|
||||
body("clientProof").isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.login2
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/mfa/send',
|
||||
"/mfa/send",
|
||||
authLimiter,
|
||||
body('email').isString().trim().notEmpty().isEmail(),
|
||||
body("email").isString().trim().notEmpty().isEmail(),
|
||||
validateRequest,
|
||||
authController.sendMfaToken
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/mfa/verify',
|
||||
"/mfa/verify",
|
||||
authLimiter,
|
||||
requireMfaAuth,
|
||||
body('email').isString().trim().notEmpty(),
|
||||
body('mfaToken').isString().trim().notEmpty(),
|
||||
body("email").isString().trim().notEmpty(),
|
||||
body("mfaToken").isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.verifyMfaToken
|
||||
);
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
import express, { Response, Request } from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param } from 'express-validator';
|
||||
import { environmentController } from '../../controllers/v2';
|
||||
import { body, param } from "express-validator";
|
||||
import { environmentController } from "../../controllers/v2";
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from '../../middleware';
|
||||
} from "../../middleware";
|
||||
import {
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
} from "../../variables";
|
||||
|
||||
router.post(
|
||||
'/:workspaceId/environments',
|
||||
"/:workspaceId/environments",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('environmentSlug').exists().trim(),
|
||||
body('environmentName').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("environmentSlug").exists().trim(),
|
||||
body("environmentName").exists().trim(),
|
||||
validateRequest,
|
||||
environmentController.createWorkspaceEnvironment
|
||||
);
|
||||
|
||||
router.put(
|
||||
'/:workspaceId/environments',
|
||||
"/:workspaceId/environments",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('environmentSlug').exists().trim(),
|
||||
body('environmentName').exists().trim(),
|
||||
body('oldEnvironmentSlug').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("environmentSlug").exists().trim(),
|
||||
body("environmentName").exists().trim(),
|
||||
body("oldEnvironmentSlug").exists().trim(),
|
||||
validateRequest,
|
||||
environmentController.renameWorkspaceEnvironment
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:workspaceId/environments',
|
||||
"/:workspaceId/environments",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('environmentSlug').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("environmentSlug").exists().trim(),
|
||||
validateRequest,
|
||||
environmentController.deleteWorkspaceEnvironment
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/environments',
|
||||
"/:workspaceId/environments",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [MEMBER, ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
environmentController.getAllAccessibleEnvironmentsOfWorkspace
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import auth from './auth';
|
||||
import signup from './signup';
|
||||
import users from './users';
|
||||
import organizations from './organizations';
|
||||
import workspace from './workspace';
|
||||
import secret from './secret'; // deprecated
|
||||
import secrets from './secrets';
|
||||
import serviceTokenData from './serviceTokenData';
|
||||
import serviceAccounts from './serviceAccounts';
|
||||
import apiKeyData from './apiKeyData';
|
||||
import auth from "./auth";
|
||||
import signup from "./signup";
|
||||
import users from "./users";
|
||||
import organizations from "./organizations";
|
||||
import workspace from "./workspace";
|
||||
import secret from "./secret"; // deprecated
|
||||
import secrets from "./secrets";
|
||||
import serviceTokenData from "./serviceTokenData";
|
||||
import serviceAccounts from "./serviceAccounts";
|
||||
import apiKeyData from "./apiKeyData";
|
||||
import environment from "./environment"
|
||||
import tags from "./tags"
|
||||
|
||||
@@ -23,5 +23,5 @@ export {
|
||||
serviceAccounts,
|
||||
apiKeyData,
|
||||
environment,
|
||||
tags
|
||||
tags,
|
||||
}
|
||||
@@ -1,101 +1,101 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireOrganizationAuth,
|
||||
requireMembershipOrgAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { body, param } from 'express-validator';
|
||||
requireOrganizationAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body, param } from "express-validator";
|
||||
import {
|
||||
OWNER,
|
||||
ACCEPTED,
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
ACCEPTED,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_API_KEY
|
||||
} from '../../variables';
|
||||
import { organizationsController } from '../../controllers/v2';
|
||||
MEMBER,
|
||||
OWNER,
|
||||
} from "../../variables";
|
||||
import { organizationsController } from "../../controllers/v2";
|
||||
|
||||
// TODO: /POST to create membership
|
||||
|
||||
router.get(
|
||||
'/:organizationId/memberships',
|
||||
param('organizationId').exists().trim(),
|
||||
"/:organizationId/memberships",
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
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]),
|
||||
"/: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]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
requireMembershipOrgAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
organizationsController.updateOrganizationMembership
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:organizationId/memberships/:membershipId',
|
||||
param('organizationId').exists().trim(),
|
||||
param('membershipId').exists().trim(),
|
||||
"/:organizationId/memberships/:membershipId",
|
||||
param("organizationId").exists().trim(),
|
||||
param("membershipId").exists().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
requireMembershipOrgAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
organizationsController.deleteOrganizationMembership
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId/workspaces',
|
||||
param('organizationId').exists().trim(),
|
||||
"/:organizationId/workspaces",
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
organizationsController.getOrganizationWorkspaces
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:organizationId/service-accounts',
|
||||
param('organizationId').exists().trim(),
|
||||
"/:organizationId/service-accounts",
|
||||
param("organizationId").exists().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
organizationsController.getOrganizationServiceAccounts
|
||||
);
|
||||
|
||||
@@ -1,146 +1,146 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireSecretAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { body, param, query } from 'express-validator';
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body, param, query } from "express-validator";
|
||||
import {
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_SERVICE_TOKEN,
|
||||
MEMBER,
|
||||
PERMISSION_READ_SECRETS,
|
||||
PERMISSION_WRITE_SECRETS
|
||||
} from '../../variables';
|
||||
import { CreateSecretRequestBody, ModifySecretRequestBody } from '../../types/secret';
|
||||
import { secretController } from '../../controllers/v2';
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
} from "../../variables";
|
||||
import { CreateSecretRequestBody, ModifySecretRequestBody } from "../../types/secret";
|
||||
import { secretController } from "../../controllers/v2";
|
||||
|
||||
// note to devs: stop supporting these routes [deprecated]
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post(
|
||||
'/batch-create/workspace/:workspaceId/environment/:environment',
|
||||
"/batch-create/workspace/:workspaceId/environment/:environment",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().isMongoId().trim(),
|
||||
param('environment').exists().trim(),
|
||||
body('secrets').exists().isArray().custom((value) => value.every((item: CreateSecretRequestBody) => typeof item === 'object')),
|
||||
body('channel'),
|
||||
param("workspaceId").exists().isMongoId().trim(),
|
||||
param("environment").exists().trim(),
|
||||
body("secrets").exists().isArray().custom((value) => value.every((item: CreateSecretRequestBody) => typeof item === "object")),
|
||||
body("channel"),
|
||||
validateRequest,
|
||||
secretController.createSecrets
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/workspace/:workspaceId/environment/:environment',
|
||||
"/workspace/:workspaceId/environment/:environment",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().isMongoId().trim(),
|
||||
param('environment').exists().trim(),
|
||||
body('secret').exists().isObject(),
|
||||
body('channel'),
|
||||
param("workspaceId").exists().isMongoId().trim(),
|
||||
param("environment").exists().trim(),
|
||||
body("secret").exists().isObject(),
|
||||
body("channel"),
|
||||
validateRequest,
|
||||
secretController.createSecret
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/workspace/:workspaceId',
|
||||
param('workspaceId').exists().trim(),
|
||||
"/workspace/:workspaceId",
|
||||
param("workspaceId").exists().trim(),
|
||||
query("environment").exists(),
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_TOKEN]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_TOKEN],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
query('channel'),
|
||||
query("channel"),
|
||||
validateRequest,
|
||||
secretController.getSecrets
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:secretId',
|
||||
"/:secretId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_TOKEN]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_TOKEN],
|
||||
}),
|
||||
requireSecretAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS]
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS],
|
||||
}),
|
||||
validateRequest,
|
||||
secretController.getSecret
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/batch/workspace/:workspaceId/environment/:environmentName',
|
||||
"/batch/workspace/:workspaceId/environment/:environmentName",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('workspaceId').exists().isMongoId().trim(),
|
||||
param('environmentName').exists().trim(),
|
||||
body('secretIds').exists().isArray().custom(array => array.length > 0),
|
||||
param("workspaceId").exists().isMongoId().trim(),
|
||||
param("environmentName").exists().trim(),
|
||||
body("secretIds").exists().isArray().custom(array => array.length > 0),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
validateRequest,
|
||||
secretController.deleteSecrets
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:secretId',
|
||||
"/:secretId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireSecretAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS, PERMISSION_WRITE_SECRETS]
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS, PERMISSION_WRITE_SECRETS],
|
||||
}),
|
||||
param('secretId').isMongoId(),
|
||||
param("secretId").isMongoId(),
|
||||
validateRequest,
|
||||
secretController.deleteSecret
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/batch-modify/workspace/:workspaceId/environment/:environmentName',
|
||||
"/batch-modify/workspace/:workspaceId/environment/:environmentName",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('secrets').exists().isArray().custom((secrets: ModifySecretRequestBody[]) => secrets.length > 0),
|
||||
param('workspaceId').exists().isMongoId().trim(),
|
||||
param('environmentName').exists().trim(),
|
||||
body("secrets").exists().isArray().custom((secrets: ModifySecretRequestBody[]) => secrets.length > 0),
|
||||
param("workspaceId").exists().isMongoId().trim(),
|
||||
param("environmentName").exists().trim(),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
validateRequest,
|
||||
secretController.updateSecrets
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/workspace/:workspaceId/environment/:environmentName',
|
||||
"/workspace/:workspaceId/environment/:environmentName",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
body('secret').isObject(),
|
||||
param('workspaceId').exists().isMongoId().trim(),
|
||||
param('environmentName').exists().trim(),
|
||||
body("secret").isObject(),
|
||||
param("workspaceId").exists().isMongoId().trim(),
|
||||
param("environmentName").exists().trim(),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
validateRequest,
|
||||
secretController.updateSecret
|
||||
|
||||
@@ -3,24 +3,24 @@ const router = express.Router();
|
||||
import { Types } from "mongoose";
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireSecretsAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { validateClientForSecrets } from "../../validation";
|
||||
import { query, body } from "express-validator";
|
||||
import { body, query } from "express-validator";
|
||||
import { secretsController } from "../../controllers/v2";
|
||||
import {
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
SECRET_PERSONAL,
|
||||
SECRET_SHARED,
|
||||
PERMISSION_READ_SECRETS,
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_SERVICE_ACCOUNT,
|
||||
AUTH_MODE_SERVICE_TOKEN,
|
||||
AUTH_MODE_API_KEY,
|
||||
MEMBER,
|
||||
PERMISSION_READ_SECRETS,
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
SECRET_PERSONAL,
|
||||
SECRET_SHARED,
|
||||
} from "../../variables";
|
||||
import { BatchSecretRequest } from "../../types/secret";
|
||||
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireOrganizationAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireServiceAccountAuth,
|
||||
requireServiceAccountWorkspacePermissionAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { param, query, body } from 'express-validator';
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body, param, query } from "express-validator";
|
||||
import {
|
||||
OWNER,
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
ACCEPTED,
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_SERVICE_ACCOUNT
|
||||
} from '../../variables';
|
||||
import { serviceAccountsController } from '../../controllers/v2';
|
||||
AUTH_MODE_SERVICE_ACCOUNT,
|
||||
MEMBER,
|
||||
OWNER,
|
||||
} from "../../variables";
|
||||
import { serviceAccountsController } from "../../controllers/v2";
|
||||
|
||||
router.get( // TODO: check
|
||||
'/me',
|
||||
"/me",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_SERVICE_ACCOUNT]
|
||||
acceptedAuthModes: [AUTH_MODE_SERVICE_ACCOUNT],
|
||||
}),
|
||||
serviceAccountsController.getCurrentServiceAccount
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:serviceAccountId',
|
||||
param('serviceAccountId').exists().isString().trim(),
|
||||
"/:serviceAccountId",
|
||||
param("serviceAccountId").exists().isString().trim(),
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
serviceAccountsController.getServiceAccountById
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/',
|
||||
body('organizationId').exists().isString().trim(),
|
||||
body('name').exists().isString().trim(),
|
||||
body('publicKey').exists().isString().trim(),
|
||||
body('expiresIn').isNumeric(), // measured in ms
|
||||
"/",
|
||||
body("organizationId").exists().isString().trim(),
|
||||
body("name").exists().isString().trim(),
|
||||
body("publicKey").exists().isString().trim(),
|
||||
body("expiresIn").isNumeric(), // measured in ms
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireOrganizationAuth({
|
||||
acceptedRoles: [OWNER, ADMIN, MEMBER],
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
locationOrganizationId: 'body'
|
||||
locationOrganizationId: "body",
|
||||
}),
|
||||
serviceAccountsController.createServiceAccount
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/:serviceAccountId/name',
|
||||
param('serviceAccountId').exists().isString().trim(),
|
||||
"/:serviceAccountId/name",
|
||||
param("serviceAccountId").exists().isString().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
serviceAccountsController.changeServiceAccountName
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:serviceAccountId',
|
||||
param('serviceAccountId').exists().isString().trim(),
|
||||
"/:serviceAccountId",
|
||||
param("serviceAccountId").exists().isString().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
serviceAccountsController.deleteServiceAccount
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:serviceAccountId/permissions/workspace',
|
||||
param('serviceAccountId').exists().isString().trim(),
|
||||
"/:serviceAccountId/permissions/workspace",
|
||||
param("serviceAccountId").exists().isString().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
serviceAccountsController.getServiceAccountWorkspacePermissions
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:serviceAccountId/permissions/workspace',
|
||||
param('serviceAccountId').exists().isString().trim(),
|
||||
body('workspaceId').exists().isString().notEmpty(),
|
||||
body('environment').exists().isString().notEmpty(),
|
||||
body('read').isBoolean().optional(),
|
||||
body('write').isBoolean().optional(),
|
||||
body('encryptedKey').exists().isString().notEmpty(),
|
||||
body('nonce').exists().isString().notEmpty(),
|
||||
"/:serviceAccountId/permissions/workspace",
|
||||
param("serviceAccountId").exists().isString().trim(),
|
||||
body("workspaceId").exists().isString().notEmpty(),
|
||||
body("environment").exists().isString().notEmpty(),
|
||||
body("read").isBoolean().optional(),
|
||||
body("write").isBoolean().optional(),
|
||||
body("encryptedKey").exists().isString().notEmpty(),
|
||||
body("nonce").exists().isString().notEmpty(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'body'
|
||||
locationWorkspaceId: "body",
|
||||
}),
|
||||
serviceAccountsController.addServiceAccountWorkspacePermission
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/:serviceAccountId/permissions/workspace/:serviceAccountWorkspacePermissionId',
|
||||
param('serviceAccountId').exists().isString().trim(),
|
||||
param('serviceAccountWorkspacePermissionId').exists().isString().trim(),
|
||||
"/:serviceAccountId/permissions/workspace/:serviceAccountWorkspacePermissionId",
|
||||
param("serviceAccountId").exists().isString().trim(),
|
||||
param("serviceAccountWorkspacePermissionId").exists().isString().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
requireServiceAccountWorkspacePermissionAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
serviceAccountsController.deleteServiceAccountWorkspacePermission
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:serviceAccountId/keys',
|
||||
query('workspaceId').optional().isString(),
|
||||
"/:serviceAccountId/keys",
|
||||
query("workspaceId").optional().isString(),
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_ACCOUNT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_ACCOUNT],
|
||||
}),
|
||||
requireServiceAccountAuth({
|
||||
acceptedRoles: [OWNER, ADMIN],
|
||||
acceptedStatuses: [ACCEPTED]
|
||||
acceptedStatuses: [ACCEPTED],
|
||||
}),
|
||||
serviceAccountsController.getServiceAccountKeys
|
||||
);
|
||||
|
||||
@@ -2,18 +2,18 @@ import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
requireServiceTokenDataAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { param, body } from "express-validator";
|
||||
import { body, param } from "express-validator";
|
||||
import {
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_SERVICE_ACCOUNT,
|
||||
AUTH_MODE_SERVICE_TOKEN,
|
||||
MEMBER,
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
} from "../../variables";
|
||||
import { serviceTokenDataController } from "../../controllers/v2";
|
||||
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import { requireSignupAuth, validateRequest } from '../../middleware';
|
||||
import { signupController } from '../../controllers/v2';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
import { body } from "express-validator";
|
||||
import { requireSignupAuth, validateRequest } from "../../middleware";
|
||||
import { signupController } from "../../controllers/v2";
|
||||
import { authLimiter } from "../../helpers/rateLimiter";
|
||||
|
||||
router.post(
|
||||
'/complete-account/signup',
|
||||
"/complete-account/signup",
|
||||
authLimiter,
|
||||
requireSignupAuth,
|
||||
body('email').exists().isString().trim().notEmpty().isEmail(),
|
||||
body('firstName').exists().isString().trim().notEmpty(),
|
||||
body('lastName').exists().isString().trim().notEmpty(),
|
||||
body('protectedKey').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('publicKey').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKey').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('salt').exists().isString().trim().notEmpty(),
|
||||
body('verifier').exists().isString().trim().notEmpty(),
|
||||
body('organizationName').exists().isString().trim().notEmpty(),
|
||||
body("email").exists().isString().trim().notEmpty().isEmail(),
|
||||
body("firstName").exists().isString().trim().notEmpty(),
|
||||
body("lastName").exists().isString().trim().notEmpty(),
|
||||
body("protectedKey").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("publicKey").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKey").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("salt").exists().isString().trim().notEmpty(),
|
||||
body("verifier").exists().isString().trim().notEmpty(),
|
||||
body("organizationName").exists().isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
signupController.completeAccountSignup
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/complete-account/invite',
|
||||
"/complete-account/invite",
|
||||
authLimiter,
|
||||
requireSignupAuth,
|
||||
body('email').exists().isString().trim().notEmpty().isEmail(),
|
||||
body('firstName').exists().isString().trim().notEmpty(),
|
||||
body('lastName').exists().isString().trim().notEmpty(),
|
||||
body('protectedKey').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('publicKey').exists().trim().notEmpty(),
|
||||
body('encryptedPrivateKey').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('salt').exists().isString().trim().notEmpty(),
|
||||
body('verifier').exists().isString().trim().notEmpty(),
|
||||
body("email").exists().isString().trim().notEmpty().isEmail(),
|
||||
body("firstName").exists().isString().trim().notEmpty(),
|
||||
body("lastName").exists().isString().trim().notEmpty(),
|
||||
body("protectedKey").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("publicKey").exists().trim().notEmpty(),
|
||||
body("encryptedPrivateKey").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("salt").exists().isString().trim().notEmpty(),
|
||||
body("verifier").exists().isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
signupController.completeAccountInvite
|
||||
);
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
import express, { Response, Request } from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param } from 'express-validator';
|
||||
import { tagController } from '../../controllers/v2';
|
||||
import { body, param } from "express-validator";
|
||||
import { tagController } from "../../controllers/v2";
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import {
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
MEMBER,
|
||||
AUTH_MODE_JWT
|
||||
} from '../../variables';
|
||||
} from "../../variables";
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/tags',
|
||||
"/:workspaceId/tags",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [MEMBER, ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
tagController.getWorkspaceTags
|
||||
);
|
||||
|
||||
router.delete(
|
||||
'/tags/:tagId',
|
||||
"/tags/:tagId",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
param('tagId').exists().trim(),
|
||||
param("tagId").exists().trim(),
|
||||
validateRequest,
|
||||
tagController.deleteWorkspaceTag
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/:workspaceId/tags',
|
||||
"/:workspaceId/tags",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [MEMBER, ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('name').exists().trim(),
|
||||
body('slug').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("name").exists().trim(),
|
||||
body("slug").exists().trim(),
|
||||
validateRequest,
|
||||
tagController.createWorkspaceTag
|
||||
);
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { body } from 'express-validator';
|
||||
import { usersController } from '../../controllers/v2';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { body } from "express-validator";
|
||||
import { usersController } from "../../controllers/v2";
|
||||
import {
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_API_KEY
|
||||
} from '../../variables';
|
||||
} from "../../variables";
|
||||
|
||||
router.get(
|
||||
'/me',
|
||||
"/me",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
usersController.getMe
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/me/mfa',
|
||||
"/me/mfa",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
body('isMfaEnabled').exists().isBoolean(),
|
||||
body("isMfaEnabled").exists().isBoolean(),
|
||||
validateRequest,
|
||||
usersController.updateMyMfaEnabled
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/me/organizations',
|
||||
"/me/organizations",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
usersController.getMyOrganizations
|
||||
);
|
||||
|
||||
@@ -1,147 +1,147 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body, param, query } from 'express-validator';
|
||||
import { body, param, query } from "express-validator";
|
||||
import {
|
||||
requireAuth,
|
||||
requireMembershipAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import {
|
||||
ADMIN,
|
||||
MEMBER,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_SERVICE_TOKEN,
|
||||
AUTH_MODE_API_KEY
|
||||
} from '../../variables';
|
||||
import { workspaceController } from '../../controllers/v2';
|
||||
MEMBER,
|
||||
} from "../../variables";
|
||||
import { workspaceController } from "../../controllers/v2";
|
||||
|
||||
router.post(
|
||||
'/:workspaceId/secrets',
|
||||
"/:workspaceId/secrets",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
body('secrets').exists(),
|
||||
body('keys').exists(),
|
||||
body('environment').exists().trim().notEmpty(),
|
||||
body('channel'),
|
||||
param('workspaceId').exists().trim(),
|
||||
body("secrets").exists(),
|
||||
body("keys").exists(),
|
||||
body("environment").exists().trim().notEmpty(),
|
||||
body("channel"),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.pushWorkspaceSecrets
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/secrets',
|
||||
"/:workspaceId/secrets",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_TOKEN]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_SERVICE_TOKEN],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
query('environment').exists().trim(),
|
||||
query('channel'),
|
||||
param('workspaceId').exists().trim(),
|
||||
query("environment").exists().trim(),
|
||||
query("channel"),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.pullSecrets
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/encrypted-key',
|
||||
"/:workspaceId/encrypted-key",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspaceKey
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/service-token-data',
|
||||
"/:workspaceId/service-token-data",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
workspaceController.getWorkspaceServiceTokenData
|
||||
);
|
||||
|
||||
router.get( // new - TODO: rewire dashboard to this route
|
||||
'/:workspaceId/memberships',
|
||||
param('workspaceId').exists().trim(),
|
||||
"/:workspaceId/memberships",
|
||||
param("workspaceId").exists().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
workspaceController.getWorkspaceMemberships
|
||||
);
|
||||
|
||||
router.patch( // TODO - rewire dashboard to this route
|
||||
'/:workspaceId/memberships/:membershipId',
|
||||
param('workspaceId').exists().trim(),
|
||||
param('membershipId').exists().trim(),
|
||||
body('role').exists().isString().trim().isIn([ADMIN, MEMBER]),
|
||||
"/:workspaceId/memberships/:membershipId",
|
||||
param("workspaceId").exists().trim(),
|
||||
param("membershipId").exists().trim(),
|
||||
body("role").exists().isString().trim().isIn([ADMIN, MEMBER]),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
requireMembershipAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationMembershipId: 'params'
|
||||
locationMembershipId: "params",
|
||||
}),
|
||||
workspaceController.updateWorkspaceMembership
|
||||
);
|
||||
|
||||
router.delete( // TODO - rewire dashboard to this route
|
||||
'/:workspaceId/memberships/:membershipId',
|
||||
param('workspaceId').exists().trim(),
|
||||
param('membershipId').exists().trim(),
|
||||
"/:workspaceId/memberships/:membershipId",
|
||||
param("workspaceId").exists().trim(),
|
||||
param("membershipId").exists().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT, AUTH_MODE_API_KEY],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
requireMembershipAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationMembershipId: 'params'
|
||||
locationMembershipId: "params",
|
||||
}),
|
||||
workspaceController.deleteWorkspaceMembership
|
||||
);
|
||||
|
||||
router.patch(
|
||||
'/:workspaceId/auto-capitalization',
|
||||
"/:workspaceId/auto-capitalization",
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN, MEMBER],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
param('workspaceId').exists().trim(),
|
||||
body('autoCapitalization').exists().trim().notEmpty(),
|
||||
param("workspaceId").exists().trim(),
|
||||
body("autoCapitalization").exists().trim().notEmpty(),
|
||||
validateRequest,
|
||||
workspaceController.toggleAutoCapitalization
|
||||
);
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import express from 'express';
|
||||
import { body } from 'express-validator';
|
||||
import { validateRequest } from '../../middleware';
|
||||
import { authController } from '../../controllers/v3';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
import express from "express";
|
||||
import { body } from "express-validator";
|
||||
import { validateRequest } from "../../middleware";
|
||||
import { authController } from "../../controllers/v3";
|
||||
import { authLimiter } from "../../helpers/rateLimiter";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post(
|
||||
'/login1',
|
||||
"/login1",
|
||||
authLimiter,
|
||||
body('email').isString().trim(),
|
||||
body('providerAuthToken').isString().trim().optional({nullable: true}),
|
||||
body('clientPublicKey').isString().trim().notEmpty(),
|
||||
body("email").isString().trim(),
|
||||
body("providerAuthToken").isString().trim().optional({nullable: true}),
|
||||
body("clientPublicKey").isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.login1
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/login2',
|
||||
"/login2",
|
||||
authLimiter,
|
||||
body('email').isString().trim(),
|
||||
body('providerAuthToken').isString().trim().optional({nullable: true}),
|
||||
body('clientProof').isString().trim().notEmpty(),
|
||||
body("email").isString().trim(),
|
||||
body("providerAuthToken").isString().trim().optional({nullable: true}),
|
||||
body("clientProof").isString().trim().notEmpty(),
|
||||
validateRequest,
|
||||
authController.login2
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import auth from './auth';
|
||||
import secrets from './secrets';
|
||||
import workspaces from './workspaces';
|
||||
import signup from './signup';
|
||||
import auth from "./auth";
|
||||
import secrets from "./secrets";
|
||||
import workspaces from "./workspaces";
|
||||
import signup from "./signup";
|
||||
|
||||
export {
|
||||
auth,
|
||||
|
||||
@@ -8,16 +8,16 @@ import {
|
||||
import { body, param, query } from "express-validator";
|
||||
import { secretsController } from "../../controllers/v3";
|
||||
import {
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_SERVICE_TOKEN,
|
||||
AUTH_MODE_SERVICE_ACCOUNT,
|
||||
ADMIN,
|
||||
AUTH_MODE_API_KEY,
|
||||
AUTH_MODE_JWT,
|
||||
AUTH_MODE_SERVICE_ACCOUNT,
|
||||
AUTH_MODE_SERVICE_TOKEN,
|
||||
MEMBER,
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
SECRET_SHARED,
|
||||
SECRET_PERSONAL,
|
||||
PERMISSION_READ_SECRETS,
|
||||
PERMISSION_WRITE_SECRETS,
|
||||
SECRET_PERSONAL,
|
||||
SECRET_SHARED,
|
||||
} from "../../variables";
|
||||
|
||||
router.get(
|
||||
@@ -40,7 +40,7 @@ router.get(
|
||||
locationEnvironment: "query",
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: true
|
||||
requireE2EEOff: true,
|
||||
}),
|
||||
secretsController.getSecretsRaw
|
||||
);
|
||||
@@ -67,7 +67,7 @@ router.get(
|
||||
locationEnvironment: "query",
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: true
|
||||
requireE2EEOff: true,
|
||||
}),
|
||||
secretsController.getSecretByNameRaw
|
||||
);
|
||||
@@ -95,7 +95,7 @@ router.post(
|
||||
locationEnvironment: "body",
|
||||
requiredPermissions: [PERMISSION_WRITE_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: true
|
||||
requireE2EEOff: true,
|
||||
}),
|
||||
secretsController.createSecretRaw
|
||||
);
|
||||
@@ -123,7 +123,7 @@ router.patch(
|
||||
locationEnvironment: "body",
|
||||
requiredPermissions: [PERMISSION_WRITE_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: true
|
||||
requireE2EEOff: true,
|
||||
}),
|
||||
secretsController.updateSecretByNameRaw
|
||||
);
|
||||
@@ -150,7 +150,7 @@ router.delete(
|
||||
locationEnvironment: "body",
|
||||
requiredPermissions: [PERMISSION_WRITE_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: true
|
||||
requireE2EEOff: true,
|
||||
}),
|
||||
secretsController.deleteSecretByNameRaw
|
||||
);
|
||||
@@ -175,7 +175,7 @@ router.get(
|
||||
locationEnvironment: "query",
|
||||
requiredPermissions: [PERMISSION_READ_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: false
|
||||
requireE2EEOff: false,
|
||||
}),
|
||||
secretsController.getSecrets
|
||||
);
|
||||
@@ -210,7 +210,7 @@ router.post(
|
||||
locationEnvironment: "body",
|
||||
requiredPermissions: [PERMISSION_WRITE_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: false
|
||||
requireE2EEOff: false,
|
||||
}),
|
||||
secretsController.createSecret
|
||||
);
|
||||
@@ -266,7 +266,7 @@ router.patch(
|
||||
locationEnvironment: "body",
|
||||
requiredPermissions: [PERMISSION_WRITE_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: false
|
||||
requireE2EEOff: false,
|
||||
}),
|
||||
secretsController.updateSecretByName
|
||||
);
|
||||
@@ -293,7 +293,7 @@ router.delete(
|
||||
locationEnvironment: "body",
|
||||
requiredPermissions: [PERMISSION_WRITE_SECRETS],
|
||||
requireBlindIndicesEnabled: true,
|
||||
requireE2EEOff: false
|
||||
requireE2EEOff: false,
|
||||
}),
|
||||
secretsController.deleteSecretByName
|
||||
);
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import { body } from 'express-validator';
|
||||
import { signupController } from '../../controllers/v3';
|
||||
import { authLimiter } from '../../helpers/rateLimiter';
|
||||
import { validateRequest } from '../../middleware';
|
||||
import { body } from "express-validator";
|
||||
import { signupController } from "../../controllers/v3";
|
||||
import { authLimiter } from "../../helpers/rateLimiter";
|
||||
import { validateRequest } from "../../middleware";
|
||||
|
||||
router.post(
|
||||
'/complete-account/signup',
|
||||
"/complete-account/signup",
|
||||
authLimiter,
|
||||
body('email').exists().isString().trim().notEmpty().isEmail(),
|
||||
body('firstName').exists().isString().trim().notEmpty(),
|
||||
body('lastName').exists().isString().trim().optional({nullable: true}),
|
||||
body('protectedKey').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('protectedKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('publicKey').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKey').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKeyIV').exists().isString().trim().notEmpty(),
|
||||
body('encryptedPrivateKeyTag').exists().isString().trim().notEmpty(),
|
||||
body('salt').exists().isString().trim().notEmpty(),
|
||||
body('verifier').exists().isString().trim().notEmpty(),
|
||||
body('organizationName').exists().isString().trim().notEmpty(),
|
||||
body('providerAuthToken').isString().trim().optional({nullable: true}),
|
||||
body("email").exists().isString().trim().notEmpty().isEmail(),
|
||||
body("firstName").exists().isString().trim().notEmpty(),
|
||||
body("lastName").exists().isString().trim().optional({nullable: true}),
|
||||
body("protectedKey").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("protectedKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("publicKey").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKey").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKeyIV").exists().isString().trim().notEmpty(),
|
||||
body("encryptedPrivateKeyTag").exists().isString().trim().notEmpty(),
|
||||
body("salt").exists().isString().trim().notEmpty(),
|
||||
body("verifier").exists().isString().trim().notEmpty(),
|
||||
body("organizationName").exists().isString().trim().notEmpty(),
|
||||
body("providerAuthToken").isString().trim().optional({nullable: true}),
|
||||
validateRequest,
|
||||
signupController.completeAccountSignup,
|
||||
);
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
import express from 'express';
|
||||
import express from "express";
|
||||
const router = express.Router();
|
||||
import {
|
||||
requireAuth,
|
||||
requireWorkspaceAuth,
|
||||
validateRequest
|
||||
} from '../../middleware';
|
||||
import { workspacesController } from '../../controllers/v3';
|
||||
validateRequest,
|
||||
} from "../../middleware";
|
||||
import { workspacesController } from "../../controllers/v3";
|
||||
import {
|
||||
ADMIN,
|
||||
AUTH_MODE_JWT,
|
||||
ADMIN
|
||||
} from '../../variables';
|
||||
import { param, body } from 'express-validator';
|
||||
} from "../../variables";
|
||||
import { body, param } from "express-validator";
|
||||
|
||||
// -- migration to blind indices endpoints
|
||||
|
||||
router.get(
|
||||
'/:workspaceId/secrets/blind-index-status',
|
||||
param('workspaceId').exists().isString().trim(),
|
||||
"/:workspaceId/secrets/blind-index-status",
|
||||
param("workspaceId").exists().isString().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params',
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
workspacesController.getWorkspaceBlindIndexStatus
|
||||
);
|
||||
|
||||
router.get( // allow admins to get all workspace secrets (part of blind indices migration)
|
||||
'/:workspaceId/secrets',
|
||||
param('workspaceId').exists().isString().trim(),
|
||||
"/:workspaceId/secrets",
|
||||
param("workspaceId").exists().isString().trim(),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params',
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
workspacesController.getWorkspaceSecrets
|
||||
);
|
||||
|
||||
router.post( // allow admins to name all workspace secrets (part of blind indices migration)
|
||||
'/:workspaceId/secrets/names',
|
||||
param('workspaceId').exists().isString().trim(),
|
||||
body('secretsToUpdate')
|
||||
"/:workspaceId/secrets/names",
|
||||
param("workspaceId").exists().isString().trim(),
|
||||
body("secretsToUpdate")
|
||||
.exists()
|
||||
.isArray()
|
||||
.withMessage('secretsToUpdate must be an array')
|
||||
.withMessage("secretsToUpdate must be an array")
|
||||
.customSanitizer((value) => {
|
||||
return value.map((secret: any) => ({
|
||||
secretName: secret.secretName,
|
||||
_id: secret._id
|
||||
_id: secret._id,
|
||||
}));
|
||||
}),
|
||||
body('secretsToUpdate.*.secretName')
|
||||
body("secretsToUpdate.*.secretName")
|
||||
.exists()
|
||||
.isString()
|
||||
.withMessage('secretName must be a string'),
|
||||
body('secretsToUpdate.*._id')
|
||||
.withMessage("secretName must be a string"),
|
||||
body("secretsToUpdate.*._id")
|
||||
.exists()
|
||||
.isString()
|
||||
.withMessage('secretId must be a string'),
|
||||
.withMessage("secretId must be a string"),
|
||||
validateRequest,
|
||||
requireAuth({
|
||||
acceptedAuthModes: [AUTH_MODE_JWT]
|
||||
acceptedAuthModes: [AUTH_MODE_JWT],
|
||||
}),
|
||||
requireWorkspaceAuth({
|
||||
acceptedRoles: [ADMIN],
|
||||
locationWorkspaceId: 'params'
|
||||
locationWorkspaceId: "params",
|
||||
}),
|
||||
workspacesController.nameWorkspaceSecrets
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user