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
+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;