Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Continue API reference development

Tuan Dangb63360813a8d
diff --git a/backend/spec.json b/backend/spec.json
index 1883652905..baad21e7e0 100644
--- a/backend/spec.json
+++ b/backend/spec.json
@@ -175,7 +175,8 @@
},
"/api/v1/workspace/{workspaceId}/secret-snapshots/rollback": {
"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": [
{
"name": "workspaceId",
@@ -183,25 +184,44 @@
"required": true,
"schema": {
"type": "string"
- }
+ },
+ "description": "ID of project"
}
],
"responses": {
"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": {
"description": "Bad Request"
}
},
+ "security": [
+ {
+ "apiKeyAuth": []
+ }
+ ],
"requestBody": {
+ "required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"version": {
- "example": "any"
+ "type": "integer",
+ "description": "Version of secret snapshot to roll back to"
}
}
}
@@ -2904,6 +2924,14 @@
"type": "string",
"example": ""
},
+ "iv": {
+ "type": "string",
+ "example": ""
+ },
+ "tag": {
+ "type": "string",
+ "example": ""
+ },
"updatedAt": {
"type": "string",
"example": ""
diff --git a/backend/src/controllers/v2/usersController.ts b/backend/src/controllers/v2/usersController.ts
index faac8f646b..194e508b35 100644
--- a/backend/src/controllers/v2/usersController.ts
+++ b/backend/src/controllers/v2/usersController.ts
@@ -29,7 +29,7 @@ export const getMe = async (req: Request, res: Response) => {
try {
user = await User
.findById(req.user._id)
- .select('+publicKey +encryptedPrivateKey');
+ .select('+publicKey +encryptedPrivateKey +iv +tag');
} catch (err) {
Sentry.setUser({ email: req.user.email });
Sentry.captureException(err);
diff --git a/backend/src/ee/controllers/v1/workspaceController.ts b/backend/src/ee/controllers/v1/workspaceController.ts
index 8fd7c87464..f29c428612 100644
--- a/backend/src/ee/controllers/v1/workspaceController.ts
+++ b/backend/src/ee/controllers/v1/workspaceController.ts
@@ -78,16 +78,61 @@ export const getWorkspaceSecretSnapshotsCount = async (req: Request, res: Respon
* @returns
*/
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;
try {
const { workspaceId } = req.params;
const { version } = req.body;
// validate secret snapshot
- const secretSnapshot = await SecretSnapshot.findOne({
- workspace: workspaceId,
- version
- }).populate<{ secretVersions: ISecretVersion[]}>('secretVersions');
+ const secretSnapshot = await SecretSnapshot.findOne({
+ workspace: workspaceId,
+ version
+ }).populate<{ secretVersions: ISecretVersion[]}>('secretVersions');
if (!secretSnapshot) throw new Error('Failed to find secret snapshot');
diff --git a/backend/swagger/index.ts b/backend/swagger/index.ts
index 2b8bc4f623..91f27da446 100644
--- a/backend/swagger/index.ts
+++ b/backend/swagger/index.ts
@@ -48,6 +48,8 @@ const generateOpenAPISpec = async () => {
lastName: '',
publicKey: '',
encryptedPrivateKey: '',
+ iv: '',
+ tag: '',
updatedAt: '',
createdAt: ''
},