mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 12:27:31 +00:00
Remove accept statuses
This commit is contained in:
@@ -2,7 +2,6 @@ import { Request, Response } from 'express';
|
|||||||
import * as Sentry from '@sentry/node';
|
import * as Sentry from '@sentry/node';
|
||||||
import { Key } from '../../models';
|
import { Key } from '../../models';
|
||||||
import { findMembership } from '../../helpers/membership';
|
import { findMembership } from '../../helpers/membership';
|
||||||
import { GRANTED } from '../../variables';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (encrypted) copy of workspace key for workspace with id [workspaceId] for user with
|
* Add (encrypted) copy of workspace key for workspace with id [workspaceId] for user with
|
||||||
@@ -26,9 +25,6 @@ export const uploadKey = async (req: Request, res: Response) => {
|
|||||||
throw new Error('Failed receiver membership validation for workspace');
|
throw new Error('Failed receiver membership validation for workspace');
|
||||||
}
|
}
|
||||||
|
|
||||||
receiverMembership.status = GRANTED;
|
|
||||||
await receiverMembership.save();
|
|
||||||
|
|
||||||
await new Key({
|
await new Key({
|
||||||
encryptedKey: key.encryptedKey,
|
encryptedKey: key.encryptedKey,
|
||||||
nonce: key.nonce,
|
nonce: key.nonce,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from '../../helpers/membership';
|
} from '../../helpers/membership';
|
||||||
import { sendMail } from '../../helpers/nodemailer';
|
import { sendMail } from '../../helpers/nodemailer';
|
||||||
import { SITE_URL } from '../../config';
|
import { SITE_URL } from '../../config';
|
||||||
import { ADMIN, MEMBER, GRANTED, ACCEPTED } from '../../variables';
|
import { ADMIN, MEMBER, ACCEPTED } from '../../variables';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that user is a member of workspace with id [workspaceId]
|
* Check that user is a member of workspace with id [workspaceId]
|
||||||
@@ -175,8 +175,7 @@ export const inviteUserToWorkspace = async (req: Request, res: Response) => {
|
|||||||
// already a member of the workspace
|
// already a member of the workspace
|
||||||
const inviteeMembership = await Membership.findOne({
|
const inviteeMembership = await Membership.findOne({
|
||||||
user: invitee._id,
|
user: invitee._id,
|
||||||
workspace: workspaceId,
|
workspace: workspaceId
|
||||||
status: GRANTED
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (inviteeMembership)
|
if (inviteeMembership)
|
||||||
@@ -205,8 +204,7 @@ export const inviteUserToWorkspace = async (req: Request, res: Response) => {
|
|||||||
const m = await new Membership({
|
const m = await new Membership({
|
||||||
user: invitee._id,
|
user: invitee._id,
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
role: MEMBER,
|
role: MEMBER
|
||||||
status: GRANTED
|
|
||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
await sendMail({
|
await sendMail({
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
deleteWorkspace as deleteWork
|
deleteWorkspace as deleteWork
|
||||||
} from '../../helpers/workspace';
|
} from '../../helpers/workspace';
|
||||||
import { addMemberships } from '../../helpers/membership';
|
import { addMemberships } from '../../helpers/membership';
|
||||||
import { ADMIN, COMPLETED, GRANTED } from '../../variables';
|
import { ADMIN } from '../../variables';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return public keys of members of workspace with id [workspaceId]
|
* Return public keys of members of workspace with id [workspaceId]
|
||||||
@@ -33,13 +33,12 @@ export const getWorkspacePublicKeys = async (req: Request, res: Response) => {
|
|||||||
workspace: workspaceId
|
workspace: workspaceId
|
||||||
}).populate<{ user: IUser }>('user', 'publicKey')
|
}).populate<{ user: IUser }>('user', 'publicKey')
|
||||||
)
|
)
|
||||||
.filter((m) => m.status === COMPLETED || m.status === GRANTED)
|
.map((member) => {
|
||||||
.map((member) => {
|
return {
|
||||||
return {
|
publicKey: member.user.publicKey,
|
||||||
publicKey: member.user.publicKey,
|
userId: member.user._id
|
||||||
userId: member.user._id
|
};
|
||||||
};
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Sentry.setUser({ email: req.user.email });
|
Sentry.setUser({ email: req.user.email });
|
||||||
Sentry.captureException(err);
|
Sentry.captureException(err);
|
||||||
@@ -169,8 +168,7 @@ export const createWorkspace = async (req: Request, res: Response) => {
|
|||||||
await addMemberships({
|
await addMemberships({
|
||||||
userIds: [req.user._id],
|
userIds: [req.user._id],
|
||||||
workspaceId: workspace._id.toString(),
|
workspaceId: workspace._id.toString(),
|
||||||
roles: [ADMIN],
|
roles: [ADMIN]
|
||||||
statuses: [GRANTED]
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Sentry.setUser({ email: req.user.email });
|
Sentry.setUser({ email: req.user.email });
|
||||||
|
|||||||
@@ -21,10 +21,9 @@ import {
|
|||||||
reformatPullSecrets
|
reformatPullSecrets
|
||||||
} from '../../helpers/secret';
|
} from '../../helpers/secret';
|
||||||
import { pushKeys } from '../../helpers/key';
|
import { pushKeys } from '../../helpers/key';
|
||||||
import { addMemberships } from '../../helpers/membership';
|
|
||||||
import { postHogClient, EventService } from '../../services';
|
import { postHogClient, EventService } from '../../services';
|
||||||
import { eventPushSecrets } from '../../events';
|
import { eventPushSecrets } from '../../events';
|
||||||
import { ADMIN, COMPLETED, GRANTED, ENV_SET } from '../../variables';
|
import { ENV_SET } from '../../variables';
|
||||||
|
|
||||||
interface V2PushSecret {
|
interface V2PushSecret {
|
||||||
type: string; // personal or shared
|
type: string; // personal or shared
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import {
|
|||||||
requireSecretAuth,
|
requireSecretAuth,
|
||||||
validateRequest
|
validateRequest
|
||||||
} from '../../../middleware';
|
} from '../../../middleware';
|
||||||
import { body, query, param } from 'express-validator';
|
import { query, param } from 'express-validator';
|
||||||
import { secretController } from '../../controllers/v1';
|
import { secretController } from '../../controllers/v1';
|
||||||
import { ADMIN, MEMBER, COMPLETED, GRANTED } from '../../../variables';
|
import { ADMIN, MEMBER } from '../../../variables';
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/:secretId/secret-versions',
|
'/:secretId/secret-versions',
|
||||||
@@ -15,8 +15,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireSecretAuth({
|
requireSecretAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('secretId').exists().trim(),
|
param('secretId').exists().trim(),
|
||||||
query('offset').exists().isInt(),
|
query('offset').exists().isInt(),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
validateRequest
|
validateRequest
|
||||||
} from '../../../middleware';
|
} from '../../../middleware';
|
||||||
import { param, query } from 'express-validator';
|
import { param, query } from 'express-validator';
|
||||||
import { ADMIN, MEMBER, GRANTED } from '../../../variables';
|
import { ADMIN, MEMBER } from '../../../variables';
|
||||||
import { workspaceController } from '../../controllers/v1';
|
import { workspaceController } from '../../controllers/v1';
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
@@ -15,8 +15,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
query('offset').exists().isInt(),
|
query('offset').exists().isInt(),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Membership, Key } from '../models';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that user with id [userId] is a member of workspace with id [workspaceId]
|
* Validate that user with id [userId] is a member of workspace with id [workspaceId]
|
||||||
* and has at least one of the roles in [acceptedRoles] and statuses in [acceptedStatuses]
|
* and has at least one of the roles in [acceptedRoles]
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {String} obj.userId - id of user to validate
|
* @param {String} obj.userId - id of user to validate
|
||||||
* @param {String} obj.workspaceId - id of workspace
|
* @param {String} obj.workspaceId - id of workspace
|
||||||
@@ -12,12 +12,10 @@ const validateMembership = async ({
|
|||||||
userId,
|
userId,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
acceptedRoles,
|
acceptedRoles,
|
||||||
acceptedStatuses
|
|
||||||
}: {
|
}: {
|
||||||
userId: string;
|
userId: string;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
let membership;
|
let membership;
|
||||||
@@ -33,11 +31,6 @@ const validateMembership = async ({
|
|||||||
if (!acceptedRoles.includes(membership.role)) {
|
if (!acceptedRoles.includes(membership.role)) {
|
||||||
throw new Error('Failed to validate membership role');
|
throw new Error('Failed to validate membership role');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!acceptedStatuses.includes(membership.status)) {
|
|
||||||
throw new Error('Failed to validate membership status');
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Sentry.setUser(null);
|
Sentry.setUser(null);
|
||||||
Sentry.captureException(err);
|
Sentry.captureException(err);
|
||||||
@@ -72,18 +65,15 @@ const findMembership = async (queryObj: any) => {
|
|||||||
* @param {String[]} obj.userIds - id of users.
|
* @param {String[]} obj.userIds - id of users.
|
||||||
* @param {String} obj.workspaceId - id of workspace.
|
* @param {String} obj.workspaceId - id of workspace.
|
||||||
* @param {String[]} obj.roles - roles of users.
|
* @param {String[]} obj.roles - roles of users.
|
||||||
* @param {String[]} obj.statuses - statuses of users.
|
|
||||||
*/
|
*/
|
||||||
const addMemberships = async ({
|
const addMemberships = async ({
|
||||||
userIds,
|
userIds,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
roles,
|
roles
|
||||||
statuses
|
|
||||||
}: {
|
}: {
|
||||||
userIds: string[];
|
userIds: string[];
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
roles: string[];
|
roles: string[];
|
||||||
statuses: string[];
|
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const operations = userIds.map((userId, idx) => {
|
const operations = userIds.map((userId, idx) => {
|
||||||
@@ -92,14 +82,12 @@ const addMemberships = async ({
|
|||||||
filter: {
|
filter: {
|
||||||
user: userId,
|
user: userId,
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
role: roles[idx],
|
role: roles[idx]
|
||||||
status: statuses[idx]
|
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
user: userId,
|
user: userId,
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
role: roles[idx],
|
role: roles[idx]
|
||||||
status: statuses[idx]
|
|
||||||
},
|
},
|
||||||
upsert: true
|
upsert: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import rateLimit from 'express-rate-limit';
|
|||||||
// 300 requests per 15 minutes
|
// 300 requests per 15 minutes
|
||||||
const apiLimiter = rateLimit({
|
const apiLimiter = rateLimit({
|
||||||
windowMs: 15 * 60 * 1000,
|
windowMs: 15 * 60 * 1000,
|
||||||
max: 400,
|
max: 450,
|
||||||
standardHeaders: true,
|
standardHeaders: true,
|
||||||
legacyHeaders: false,
|
legacyHeaders: false,
|
||||||
skip: (request) => request.path === '/healthcheck'
|
skip: (request) => request.path === '/healthcheck'
|
||||||
@@ -20,7 +20,7 @@ const signupLimiter = rateLimit({
|
|||||||
// 10 requests per hour
|
// 10 requests per hour
|
||||||
const loginLimiter = rateLimit({
|
const loginLimiter = rateLimit({
|
||||||
windowMs: 60 * 60 * 1000,
|
windowMs: 60 * 60 * 1000,
|
||||||
max: 20,
|
max: 25,
|
||||||
standardHeaders: true,
|
standardHeaders: true,
|
||||||
legacyHeaders: false
|
legacyHeaders: false
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { createOrganization } from './organization';
|
|||||||
import { addMembershipsOrg } from './membershipOrg';
|
import { addMembershipsOrg } from './membershipOrg';
|
||||||
import { createWorkspace } from './workspace';
|
import { createWorkspace } from './workspace';
|
||||||
import { addMemberships } from './membership';
|
import { addMemberships } from './membership';
|
||||||
import { OWNER, ADMIN, ACCEPTED, GRANTED } from '../variables';
|
import { OWNER, ADMIN, ACCEPTED } from '../variables';
|
||||||
import { sendMail } from '../helpers/nodemailer';
|
import { sendMail } from '../helpers/nodemailer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,8 +113,7 @@ const initializeDefaultOrg = async ({
|
|||||||
await addMemberships({
|
await addMemberships({
|
||||||
userIds: [user._id.toString()],
|
userIds: [user._id.toString()],
|
||||||
workspaceId: workspace._id.toString(),
|
workspaceId: workspace._id.toString(),
|
||||||
roles: [ADMIN],
|
roles: [ADMIN]
|
||||||
statuses: [GRANTED]
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error('Failed to initialize default organization and workspace');
|
throw new Error('Failed to initialize default organization and workspace');
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ type req = 'params' | 'body' | 'query';
|
|||||||
|
|
||||||
const requireBotAuth = ({
|
const requireBotAuth = ({
|
||||||
acceptedRoles,
|
acceptedRoles,
|
||||||
acceptedStatuses,
|
|
||||||
location = 'params'
|
location = 'params'
|
||||||
}: {
|
}: {
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
location?: req;
|
location?: req;
|
||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
@@ -24,8 +22,7 @@ const requireBotAuth = ({
|
|||||||
await validateMembership({
|
await validateMembership({
|
||||||
userId: req.user._id.toString(),
|
userId: req.user._id.toString(),
|
||||||
workspaceId: bot.workspace.toString(),
|
workspaceId: bot.workspace.toString(),
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
});
|
});
|
||||||
|
|
||||||
req.bot = bot;
|
req.bot = bot;
|
||||||
|
|||||||
@@ -9,14 +9,11 @@ import { IntegrationNotFoundError, UnauthorizedRequestError } from '../utils/err
|
|||||||
* with the integration on request params.
|
* with the integration on request params.
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {String[]} obj.acceptedRoles - accepted workspace roles
|
* @param {String[]} obj.acceptedRoles - accepted workspace roles
|
||||||
* @param {String[]} obj.acceptedStatuses - accepted workspace statuses
|
|
||||||
*/
|
*/
|
||||||
const requireIntegrationAuth = ({
|
const requireIntegrationAuth = ({
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
}: {
|
}: {
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
// integration authorization middleware
|
// integration authorization middleware
|
||||||
@@ -35,8 +32,7 @@ const requireIntegrationAuth = ({
|
|||||||
await validateMembership({
|
await validateMembership({
|
||||||
userId: req.user._id.toString(),
|
userId: req.user._id.toString(),
|
||||||
workspaceId: integration.workspace.toString(),
|
workspaceId: integration.workspace.toString(),
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const integrationAuth = await IntegrationAuth.findOne({
|
const integrationAuth = await IntegrationAuth.findOne({
|
||||||
|
|||||||
@@ -10,16 +10,13 @@ import { UnauthorizedRequestError } from '../utils/errors';
|
|||||||
* with the integration authorization on request params.
|
* with the integration authorization on request params.
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {String[]} obj.acceptedRoles - accepted workspace roles
|
* @param {String[]} obj.acceptedRoles - accepted workspace roles
|
||||||
* @param {String[]} obj.acceptedStatuses - accepted workspace statuses
|
|
||||||
* @param {Boolean} obj.attachAccessToken - whether or not to decrypt and attach integration authorization access token onto request
|
* @param {Boolean} obj.attachAccessToken - whether or not to decrypt and attach integration authorization access token onto request
|
||||||
*/
|
*/
|
||||||
const requireIntegrationAuthorizationAuth = ({
|
const requireIntegrationAuthorizationAuth = ({
|
||||||
acceptedRoles,
|
acceptedRoles,
|
||||||
acceptedStatuses,
|
|
||||||
attachAccessToken = true
|
attachAccessToken = true
|
||||||
}: {
|
}: {
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
attachAccessToken?: boolean;
|
attachAccessToken?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
@@ -38,8 +35,7 @@ const requireIntegrationAuthorizationAuth = ({
|
|||||||
await validateMembership({
|
await validateMembership({
|
||||||
userId: req.user._id.toString(),
|
userId: req.user._id.toString(),
|
||||||
workspaceId: integrationAuth.workspace.toString(),
|
workspaceId: integrationAuth.workspace.toString(),
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
});
|
});
|
||||||
|
|
||||||
req.integrationAuth = integrationAuth;
|
req.integrationAuth = integrationAuth;
|
||||||
|
|||||||
@@ -9,15 +9,12 @@ import {
|
|||||||
* Validate if user on request has proper membership to modify secret.
|
* Validate if user on request has proper membership to modify secret.
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {String[]} obj.acceptedRoles - accepted workspace roles
|
* @param {String[]} obj.acceptedRoles - accepted workspace roles
|
||||||
* @param {String[]} obj.acceptedStatuses - accepted workspace statuses
|
|
||||||
* @param {String[]} obj.location - location of [workspaceId] on request (e.g. params, body) for parsing
|
* @param {String[]} obj.location - location of [workspaceId] on request (e.g. params, body) for parsing
|
||||||
*/
|
*/
|
||||||
const requireSecretAuth = ({
|
const requireSecretAuth = ({
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
}: {
|
}: {
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
@@ -34,8 +31,7 @@ const requireSecretAuth = ({
|
|||||||
await validateMembership({
|
await validateMembership({
|
||||||
userId: req.user._id.toString(),
|
userId: req.user._id.toString(),
|
||||||
workspaceId: secret.workspace.toString(),
|
workspaceId: secret.workspace.toString(),
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
});
|
});
|
||||||
|
|
||||||
req.secret = secret as any;
|
req.secret = secret as any;
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ type req = 'params' | 'body' | 'query';
|
|||||||
|
|
||||||
const requireServiceTokenDataAuth = ({
|
const requireServiceTokenDataAuth = ({
|
||||||
acceptedRoles,
|
acceptedRoles,
|
||||||
acceptedStatuses,
|
|
||||||
location = 'params'
|
location = 'params'
|
||||||
}: {
|
}: {
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
location?: req;
|
location?: req;
|
||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
@@ -30,8 +28,7 @@ const requireServiceTokenDataAuth = ({
|
|||||||
await validateMembership({
|
await validateMembership({
|
||||||
userId: req.user._id.toString(),
|
userId: req.user._id.toString(),
|
||||||
workspaceId: serviceTokenData.workspace.toString(),
|
workspaceId: serviceTokenData.workspace.toString(),
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,13 @@ type req = 'params' | 'body' | 'query';
|
|||||||
* on request params.
|
* on request params.
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {String[]} obj.acceptedRoles - accepted workspace roles for JWT auth
|
* @param {String[]} obj.acceptedRoles - accepted workspace roles for JWT auth
|
||||||
* @param {String[]} obj.acceptedStatuses - accepted workspace statuses for JWT auth
|
|
||||||
* @param {String[]} obj.location - location of [workspaceId] on request (e.g. params, body) for parsing
|
* @param {String[]} obj.location - location of [workspaceId] on request (e.g. params, body) for parsing
|
||||||
*/
|
*/
|
||||||
const requireWorkspaceAuth = ({
|
const requireWorkspaceAuth = ({
|
||||||
acceptedRoles,
|
acceptedRoles,
|
||||||
acceptedStatuses,
|
|
||||||
location = 'params'
|
location = 'params'
|
||||||
}: {
|
}: {
|
||||||
acceptedRoles: string[];
|
acceptedRoles: string[];
|
||||||
acceptedStatuses: string[];
|
|
||||||
location?: req;
|
location?: req;
|
||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
@@ -30,8 +27,7 @@ const requireWorkspaceAuth = ({
|
|||||||
const membership = await validateMembership({
|
const membership = await validateMembership({
|
||||||
userId: req.user._id.toString(),
|
userId: req.user._id.toString(),
|
||||||
workspaceId,
|
workspaceId,
|
||||||
acceptedRoles,
|
acceptedRoles
|
||||||
acceptedStatuses
|
|
||||||
});
|
});
|
||||||
|
|
||||||
req.membership = membership;
|
req.membership = membership;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Schema, model, Types } from 'mongoose';
|
import { Schema, model, Types } from 'mongoose';
|
||||||
import { ADMIN, MEMBER, INVITED, COMPLETED, GRANTED } from '../variables';
|
import { ADMIN, MEMBER } from '../variables';
|
||||||
|
|
||||||
export interface IMembership {
|
export interface IMembership {
|
||||||
_id: Types.ObjectId;
|
_id: Types.ObjectId;
|
||||||
@@ -7,7 +7,6 @@ export interface IMembership {
|
|||||||
inviteEmail?: string;
|
inviteEmail?: string;
|
||||||
workspace: Types.ObjectId;
|
workspace: Types.ObjectId;
|
||||||
role: 'admin' | 'member';
|
role: 'admin' | 'member';
|
||||||
status: 'invited' | 'completed' | 'granted';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const membershipSchema = new Schema(
|
const membershipSchema = new Schema(
|
||||||
@@ -28,12 +27,6 @@ const membershipSchema = new Schema(
|
|||||||
type: String,
|
type: String,
|
||||||
enum: [ADMIN, MEMBER],
|
enum: [ADMIN, MEMBER],
|
||||||
required: true
|
required: true
|
||||||
},
|
|
||||||
status: {
|
|
||||||
// INVITED, COMPLETED, GRANTED
|
|
||||||
type: String,
|
|
||||||
enum: [INVITED, COMPLETED, GRANTED],
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { botController } from '../../controllers/v1';
|
import { botController } from '../../controllers/v1';
|
||||||
import { ADMIN, MEMBER, COMPLETED, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/:workspaceId',
|
'/:workspaceId',
|
||||||
@@ -16,8 +16,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim().notEmpty(),
|
param('workspaceId').exists().trim().notEmpty(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -30,8 +29,7 @@ router.patch(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireBotAuth({
|
requireBotAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
body('isActive').isBoolean(),
|
body('isActive').isBoolean(),
|
||||||
body('botKey'),
|
body('botKey'),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
requireIntegrationAuth,
|
requireIntegrationAuth,
|
||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { ADMIN, MEMBER, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
import { body, param } from 'express-validator';
|
import { body, param } from 'express-validator';
|
||||||
import { integrationController } from '../../controllers/v1';
|
import { integrationController } from '../../controllers/v1';
|
||||||
|
|
||||||
@@ -15,8 +15,7 @@ router.patch(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireIntegrationAuth({
|
requireIntegrationAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('integrationId').exists().trim(),
|
param('integrationId').exists().trim(),
|
||||||
body('app').exists().trim(),
|
body('app').exists().trim(),
|
||||||
@@ -35,8 +34,7 @@ router.delete(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireIntegrationAuth({
|
requireIntegrationAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('integrationId').exists().trim(),
|
param('integrationId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
requireIntegrationAuthorizationAuth,
|
requireIntegrationAuthorizationAuth,
|
||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { ADMIN, MEMBER, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
import { integrationAuthController } from '../../controllers/v1';
|
import { integrationAuthController } from '../../controllers/v1';
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
@@ -25,7 +25,6 @@ router.post(
|
|||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER],
|
||||||
acceptedStatuses: [GRANTED],
|
|
||||||
location: 'body'
|
location: 'body'
|
||||||
}),
|
}),
|
||||||
body('workspaceId').exists().trim().notEmpty(),
|
body('workspaceId').exists().trim().notEmpty(),
|
||||||
@@ -41,8 +40,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireIntegrationAuthorizationAuth({
|
requireIntegrationAuthorizationAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('integrationAuthId'),
|
param('integrationAuthId'),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -56,7 +54,6 @@ router.delete(
|
|||||||
}),
|
}),
|
||||||
requireIntegrationAuthorizationAuth({
|
requireIntegrationAuthorizationAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER],
|
||||||
acceptedStatuses: [GRANTED],
|
|
||||||
attachAccessToken: false
|
attachAccessToken: false
|
||||||
}),
|
}),
|
||||||
param('integrationAuthId'),
|
param('integrationAuthId'),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { body, param } from 'express-validator';
|
import { body, param } from 'express-validator';
|
||||||
import { ADMIN, MEMBER, COMPLETED, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
import { keyController } from '../../controllers/v1';
|
import { keyController } from '../../controllers/v1';
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
@@ -15,8 +15,7 @@ router.post(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
body('key').exists(),
|
body('key').exists(),
|
||||||
@@ -30,8 +29,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId'),
|
param('workspaceId'),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { body, query, param } from 'express-validator';
|
import { body, query, param } from 'express-validator';
|
||||||
import { secretController } from '../../controllers/v1';
|
import { secretController } from '../../controllers/v1';
|
||||||
import { ADMIN, MEMBER, COMPLETED, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/:workspaceId',
|
'/:workspaceId',
|
||||||
@@ -16,8 +16,7 @@ router.post(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
body('secrets').exists(),
|
body('secrets').exists(),
|
||||||
body('keys').exists(),
|
body('keys').exists(),
|
||||||
@@ -34,8 +33,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
query('environment').exists().trim(),
|
query('environment').exists().trim(),
|
||||||
query('channel'),
|
query('channel'),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { body } from 'express-validator';
|
import { body } from 'express-validator';
|
||||||
import { ADMIN, MEMBER, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
import { serviceTokenController } from '../../controllers/v1';
|
import { serviceTokenController } from '../../controllers/v1';
|
||||||
|
|
||||||
// note: deprecate service-token routes in favor of service-token data routes/structure
|
// note: deprecate service-token routes in favor of service-token data routes/structure
|
||||||
@@ -25,7 +25,6 @@ router.post(
|
|||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER],
|
||||||
acceptedStatuses: [GRANTED],
|
|
||||||
location: 'body'
|
location: 'body'
|
||||||
}),
|
}),
|
||||||
body('name').exists().trim().notEmpty(),
|
body('name').exists().trim().notEmpty(),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
requireWorkspaceAuth,
|
requireWorkspaceAuth,
|
||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { ADMIN, MEMBER, COMPLETED, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
import { workspaceController, membershipController } from '../../controllers/v1';
|
import { workspaceController, membershipController } from '../../controllers/v1';
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
@@ -15,8 +15,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -30,7 +29,6 @@ router.get(
|
|||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER],
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -51,8 +49,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -76,8 +73,7 @@ router.delete(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN],
|
acceptedRoles: [ADMIN]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -90,8 +86,7 @@ router.post(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
body('name').exists().trim().notEmpty(),
|
body('name').exists().trim().notEmpty(),
|
||||||
@@ -105,8 +100,7 @@ router.post(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
body('email').exists().trim().notEmpty(),
|
body('email').exists().trim().notEmpty(),
|
||||||
@@ -120,8 +114,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -134,8 +127,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -148,8 +140,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import { param, body } from 'express-validator';
|
|||||||
import {
|
import {
|
||||||
ADMIN,
|
ADMIN,
|
||||||
MEMBER,
|
MEMBER,
|
||||||
COMPLETED,
|
|
||||||
GRANTED
|
|
||||||
} from '../../variables';
|
} from '../../variables';
|
||||||
import { serviceTokenDataController } from '../../controllers/v2';
|
import { serviceTokenDataController } from '../../controllers/v2';
|
||||||
|
|
||||||
@@ -30,7 +28,6 @@ router.post(
|
|||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER],
|
||||||
acceptedStatuses: [COMPLETED, GRANTED],
|
|
||||||
location: 'body'
|
location: 'body'
|
||||||
}),
|
}),
|
||||||
body('name').exists().trim(),
|
body('name').exists().trim(),
|
||||||
@@ -50,8 +47,7 @@ router.delete(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireServiceTokenDataAuth({
|
requireServiceTokenDataAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED],
|
|
||||||
}),
|
}),
|
||||||
param('serviceTokenDataId').exists().trim(),
|
param('serviceTokenDataId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
requireWorkspaceAuth,
|
requireWorkspaceAuth,
|
||||||
validateRequest
|
validateRequest
|
||||||
} from '../../middleware';
|
} from '../../middleware';
|
||||||
import { ADMIN, MEMBER, COMPLETED, GRANTED } from '../../variables';
|
import { ADMIN, MEMBER } from '../../variables';
|
||||||
import { workspaceController } from '../../controllers/v2';
|
import { workspaceController } from '../../controllers/v2';
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
@@ -15,8 +15,7 @@ router.post(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
body('secrets').exists(),
|
body('secrets').exists(),
|
||||||
body('keys').exists(),
|
body('keys').exists(),
|
||||||
@@ -33,8 +32,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt', 'serviceToken']
|
acceptedAuthModes: ['jwt', 'serviceToken']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
query('environment').exists().trim(),
|
query('environment').exists().trim(),
|
||||||
query('channel'),
|
query('channel'),
|
||||||
@@ -49,8 +47,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [COMPLETED, GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -63,8 +60,7 @@ router.get(
|
|||||||
acceptedAuthModes: ['jwt']
|
acceptedAuthModes: ['jwt']
|
||||||
}),
|
}),
|
||||||
requireWorkspaceAuth({
|
requireWorkspaceAuth({
|
||||||
acceptedRoles: [ADMIN, MEMBER],
|
acceptedRoles: [ADMIN, MEMBER]
|
||||||
acceptedStatuses: [GRANTED]
|
|
||||||
}),
|
}),
|
||||||
param('workspaceId').exists().trim(),
|
param('workspaceId').exists().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import {
|
|||||||
MEMBER,
|
MEMBER,
|
||||||
INVITED,
|
INVITED,
|
||||||
ACCEPTED,
|
ACCEPTED,
|
||||||
COMPLETED,
|
|
||||||
GRANTED
|
|
||||||
} from './organization';
|
} from './organization';
|
||||||
import { SECRET_SHARED, SECRET_PERSONAL } from './secret';
|
import { SECRET_SHARED, SECRET_PERSONAL } from './secret';
|
||||||
import { EVENT_PUSH_SECRETS, EVENT_PULL_SECRETS } from './event';
|
import { EVENT_PUSH_SECRETS, EVENT_PULL_SECRETS } from './event';
|
||||||
@@ -42,8 +40,6 @@ export {
|
|||||||
MEMBER,
|
MEMBER,
|
||||||
INVITED,
|
INVITED,
|
||||||
ACCEPTED,
|
ACCEPTED,
|
||||||
COMPLETED,
|
|
||||||
GRANTED,
|
|
||||||
SECRET_SHARED,
|
SECRET_SHARED,
|
||||||
SECRET_PERSONAL,
|
SECRET_PERSONAL,
|
||||||
ENV_DEV,
|
ENV_DEV,
|
||||||
|
|||||||
@@ -9,16 +9,10 @@ const INVITED = 'invited';
|
|||||||
// -- organization
|
// -- organization
|
||||||
const ACCEPTED = 'accepted';
|
const ACCEPTED = 'accepted';
|
||||||
|
|
||||||
// -- workspace
|
|
||||||
const COMPLETED = 'completed';
|
|
||||||
const GRANTED = 'granted';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
OWNER,
|
OWNER,
|
||||||
ADMIN,
|
ADMIN,
|
||||||
MEMBER,
|
MEMBER,
|
||||||
INVITED,
|
INVITED,
|
||||||
ACCEPTED,
|
ACCEPTED
|
||||||
COMPLETED,
|
|
||||||
GRANTED
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user