Checkpoint service accounts

This commit is contained in:
Tuan Dang
2023-03-18 13:34:06 +07:00
parent 273f4228d7
commit ebdcccb6ca
18 changed files with 404 additions and 64 deletions
+2
View File
@@ -6,6 +6,7 @@ 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"
@@ -19,6 +20,7 @@ export {
secret,
secrets,
serviceTokenData,
serviceAccounts,
apiKeyData,
environment,
tags
+15 -1
View File
@@ -6,7 +6,7 @@ import {
requireMembershipOrgAuth,
validateRequest
} from '../../middleware';
import { body, param, query } from 'express-validator';
import { body, param } from 'express-validator';
import { OWNER, ADMIN, MEMBER, ACCEPTED } from '../../variables';
import { organizationsController } from '../../controllers/v2';
@@ -77,4 +77,18 @@ router.get(
organizationsController.getOrganizationWorkspaces
);
router.get(
'/:organizationId/service-accounts',
param('organizationId').exists().trim(),
validateRequest,
requireAuth({
acceptedAuthModes: ['jwt']
}),
requireOrganizationAuth({
acceptedRoles: [OWNER, ADMIN],
acceptedStatuses: [ACCEPTED]
}),
organizationsController.getOrganizationServiceAccounts
);
export default router;
+53
View File
@@ -0,0 +1,53 @@
import express from 'express';
const router = express.Router();
import {
requireOrganizationAuth,
requireServiceAccountAuth
} from '../../middleware';
import { body } from 'express-validator';
import {
OWNER,
ADMIN,
MEMBER,
ACCEPTED
} from '../../variables';
import { serviceAccountsController } from '../../controllers/v2';
router.post(
'/',
body('organizationId').exists().isString().trim(),
body('name').exists().isString().trim(),
body('publicKey').exists().isString().trim(),
body('expiresIn'), // measured in ms
requireOrganizationAuth({
acceptedRoles: [OWNER, ADMIN, MEMBER],
acceptedStatuses: [ACCEPTED],
location: 'body'
}),
serviceAccountsController.createServiceAccount
);
// router.post(
// '/:serviceAccountId/key',
// body('workspaceId').exists().isString().trim(),
// body('encryptedKey').exists().isString().trim(),
// body('nonce').exists().isString().trim(),
// requireServiceAccountAuth({
// acceptedRoles: [OWNER, ADMIN, MEMBER],
// acceptedStatuses: [ACCEPTED]
// }),
// serviceAccountsController.addServiceAccountKey
// );
router.delete(
'/:serviceAccountId/key/:serviceAccountKeyId',
requireServiceAccountAuth({
acceptedRoles: [OWNER, ADMIN, MEMBER],
acceptedStatuses: [ACCEPTED]
}),
async (req, res) => {
// TODO: delete service account key id
}
);
export default router;