mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 03:27:38 +00:00
Continue API reference development
This commit is contained in:
+32
-4
@@ -175,7 +175,8 @@
|
|||||||
},
|
},
|
||||||
"/api/v1/workspace/{workspaceId}/secret-snapshots/rollback": {
|
"/api/v1/workspace/{workspaceId}/secret-snapshots/rollback": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "",
|
"summary": "Roll back project secrets to those captured in a secret snapshot version",
|
||||||
|
"description": "Roll back project secrets to those captured in a secret snapshot version",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "workspaceId",
|
"name": "workspaceId",
|
||||||
@@ -183,25 +184,44 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
},
|
||||||
|
"description": "ID of project"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK"
|
"description": "OK",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Secret"
|
||||||
|
},
|
||||||
|
"description": "Array of secrets captured in the secret snapshot"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "Bad Request"
|
"description": "Bad Request"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"apiKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"version": {
|
"version": {
|
||||||
"example": "any"
|
"type": "integer",
|
||||||
|
"description": "Version of secret snapshot to roll back to"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2904,6 +2924,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": ""
|
"example": ""
|
||||||
},
|
},
|
||||||
|
"iv": {
|
||||||
|
"type": "string",
|
||||||
|
"example": ""
|
||||||
|
},
|
||||||
|
"tag": {
|
||||||
|
"type": "string",
|
||||||
|
"example": ""
|
||||||
|
},
|
||||||
"updatedAt": {
|
"updatedAt": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": ""
|
"example": ""
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const getMe = async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
user = await User
|
user = await User
|
||||||
.findById(req.user._id)
|
.findById(req.user._id)
|
||||||
.select('+publicKey +encryptedPrivateKey');
|
.select('+publicKey +encryptedPrivateKey +iv +tag');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Sentry.setUser({ email: req.user.email });
|
Sentry.setUser({ email: req.user.email });
|
||||||
Sentry.captureException(err);
|
Sentry.captureException(err);
|
||||||
|
|||||||
@@ -78,16 +78,61 @@ export const getWorkspaceSecretSnapshotsCount = async (req: Request, res: Respon
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const rollbackWorkspaceSecretSnapshot = async (req: Request, res: Response) => {
|
export const rollbackWorkspaceSecretSnapshot = async (req: Request, res: Response) => {
|
||||||
|
/*
|
||||||
|
#swagger.summary = 'Roll back project secrets to those captured in a secret snapshot version'
|
||||||
|
#swagger.description = 'Roll back project secrets to those captured in a secret snapshot version'
|
||||||
|
|
||||||
|
#swagger.security = [{
|
||||||
|
"apiKeyAuth": []
|
||||||
|
}]
|
||||||
|
|
||||||
|
#swagger.parameters['workspaceId'] = {
|
||||||
|
"description": "ID of project",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
|
||||||
|
#swagger.requestBody = {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"version": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Version of secret snapshot to roll back to",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#swagger.responses[200] = {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
$ref: "#/components/schemas/Secret"
|
||||||
|
},
|
||||||
|
"description": "Array of secrets captured in the secret snapshot"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
let secrets;
|
let secrets;
|
||||||
try {
|
try {
|
||||||
const { workspaceId } = req.params;
|
const { workspaceId } = req.params;
|
||||||
const { version } = req.body;
|
const { version } = req.body;
|
||||||
|
|
||||||
// validate secret snapshot
|
// validate secret snapshot
|
||||||
const secretSnapshot = await SecretSnapshot.findOne({
|
const secretSnapshot = await SecretSnapshot.findOne({
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
version
|
version
|
||||||
}).populate<{ secretVersions: ISecretVersion[]}>('secretVersions');
|
}).populate<{ secretVersions: ISecretVersion[]}>('secretVersions');
|
||||||
|
|
||||||
if (!secretSnapshot) throw new Error('Failed to find secret snapshot');
|
if (!secretSnapshot) throw new Error('Failed to find secret snapshot');
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ const generateOpenAPISpec = async () => {
|
|||||||
lastName: '',
|
lastName: '',
|
||||||
publicKey: '',
|
publicKey: '',
|
||||||
encryptedPrivateKey: '',
|
encryptedPrivateKey: '',
|
||||||
|
iv: '',
|
||||||
|
tag: '',
|
||||||
updatedAt: '',
|
updatedAt: '',
|
||||||
createdAt: ''
|
createdAt: ''
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user