Skip to content

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

feat(audit-log): added doc for export endpoint

Akhil Mohan89ae3070cedb
diff --git a/backend/spec.json b/backend/spec.json
index ecb6977b5c..eb4a1d488e 100644
--- a/backend/spec.json
+++ b/backend/spec.json
@@ -306,12 +306,77 @@
},
"/api/v1/workspace/{workspaceId}/audit-logs": {
"get": {
- "description": "",
+ "summary": "Return audit logs",
+ "description": "Return audit logs",
"parameters": [
{
"name": "workspaceId",
"in": "path",
"required": true,
+ "schema": {
+ "type": "string"
+ },
+ "description": "ID of the workspace where to get folders from"
+ },
+ {
+ "name": "offset",
+ "description": "Number of versions to skip",
+ "required": false,
+ "in": "query",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "limit",
+ "description": "Maximum number of versions to return",
+ "required": false,
+ "in": "query",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "startDate",
+ "description": "Filter logs from the provided date",
+ "required": false,
+ "in": "query",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "endDate",
+ "description": "Filter logs till the provided date",
+ "required": false,
+ "in": "query",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "eventType",
+ "description": "Type of event",
+ "required": false,
+ "in": "query",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "userAgentType",
+ "description": "Type of event",
+ "required": false,
+ "in": "query",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "actor",
+ "description": "Source of operation. It can be user, service token etc",
+ "required": false,
+ "in": "query",
"schema": {
"type": "string"
}
@@ -319,9 +384,31 @@
],
"responses": {
"200": {
- "description": "OK"
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "auditLogs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/AuditLog"
+ },
+ "description": "List of audit log"
+ }
+ }
+ }
+ }
+ }
}
- }
+ },
+ "security": [
+ {
+ "apiKeyAuth": [],
+ "bearerAuth": []
+ }
+ ]
}
},
"/api/v1/workspace/{workspaceId}/audit-logs/filters/actors": {
@@ -1132,6 +1219,43 @@
}
}
},
+ "/api/v1/admin/config": {
+ "get": {
+ "description": "",
+ "responses": {
+ "200": {
+ "description": "OK"
+ }
+ }
+ },
+ "patch": {
+ "description": "",
+ "responses": {
+ "200": {
+ "description": "OK"
+ }
+ }
+ }
+ },
+ "/api/v1/admin/signup": {
+ "post": {
+ "description": "",
+ "parameters": [
+ {
+ "name": "user-agent",
+ "in": "header",
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK"
+ }
+ }
+ }
+ },
"/api/v1/bot/{workspaceId}": {
"get": {
"description": "",
@@ -6864,6 +6988,61 @@
"example": "2023-01-13T14:16:12.210Z"
}
}
+ },
+ "AuditLog": {
+ "type": "object",
+ "properties": {
+ "actor": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "example": ""
+ },
+ "metadata": {
+ "type": "object",
+ "properties": {}
+ }
+ }
+ },
+ "organization": {
+ "type": "string",
+ "example": ""
+ },
+ "workspace": {
+ "type": "string",
+ "example": ""
+ },
+ "ipAddress": {
+ "type": "string",
+ "example": ""
+ },
+ "event": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "example": ""
+ },
+ "metadata": {
+ "type": "object",
+ "properties": {}
+ }
+ }
+ },
+ "userAgent": {
+ "type": "string",
+ "example": ""
+ },
+ "userAgentType": {
+ "type": "string",
+ "example": ""
+ },
+ "expiresAt": {
+ "type": "string",
+ "example": ""
+ }
+ }
}
},
"securitySchemes": {
diff --git a/backend/src/ee/controllers/v1/workspaceController.ts b/backend/src/ee/controllers/v1/workspaceController.ts
index 9bcad4c8ee..a2b5b76366 100644
--- a/backend/src/ee/controllers/v1/workspaceController.ts
+++ b/backend/src/ee/controllers/v1/workspaceController.ts
@@ -567,6 +567,83 @@ export const rollbackWorkspaceSecretSnapshot = async (req: Request, res: Respons
* @param res
*/
export const getWorkspaceAuditLogs = async (req: Request, res: Response) => {
+ /*
+ #swagger.summary = 'Return audit logs'
+ #swagger.description = 'Return audit logs'
+
+ #swagger.security = [{
+ "apiKeyAuth": [],
+ "bearerAuth": []
+ }]
+
+ #swagger.parameters['workspaceId'] = {
+ "description": "ID of the workspace where to get folders from",
+ "required": true,
+ "type": "string",
+ "in": "path"
+ }
+
+ #swagger.parameters['offset'] = {
+ "description": "Number of versions to skip",
+ "required": false,
+ "type": "string"
+ }
+
+ #swagger.parameters['limit'] = {
+ "description": "Maximum number of versions to return",
+ "required": false,
+ "type": "string"
+ }
+
+ #swagger.parameters['startDate'] = {
+ "description": "Filter logs from the provided date",
+ "required": false,
+ "type": "string"
+ }
+
+ #swagger.parameters['endDate'] = {
+ "description": "Filter logs till the provided date",
+ "required": false,
+ "type": "string"
+ }
+
+ #swagger.parameters['eventType'] = {
+ "description": "Type of event",
+ "required": false,
+ "type": "string",
+ }
+
+ #swagger.parameters['userAgentType'] = {
+ "description": "Type of event",
+ "required": false,
+ "type": "string",
+ }
+
+ #swagger.parameters['actor'] = {
+ "description": "Source of operation. It can be user, service token etc",
+ "required": false,
+ "type": "string"
+ }
+
+ #swagger.responses[200] = {
+ content: {
+ "application/json": {
+ schema: {
+ "type": "object",
+ "properties": {
+ "auditLogs": {
+ "type": "array",
+ "items": {
+ $ref: "#/components/schemas/AuditLog",
+ },
+ "description": "List of audit log"
+ },
+ }
+ }
+ }
+ }
+ }
+ */
const {
query: { limit, offset, endDate, eventType, startDate, userAgentType, actor },
params: { workspaceId }
diff --git a/backend/swagger/index.ts b/backend/swagger/index.ts
index 7258c727a8..3c7a503d69 100644
--- a/backend/swagger/index.ts
+++ b/backend/swagger/index.ts
@@ -12,32 +12,32 @@ const generateOpenAPISpec = async () => {
const doc = {
info: {
title: "Infisical API",
- description: "List of all available APIs that can be consumed",
+ description: "List of all available APIs that can be consumed"
},
host: ["https://infisical.com"],
servers: [
{
url: "https://app.infisical.com",
- description: "Production server",
+ description: "Production server"
},
{
url: "http://localhost:8080",
- description: "Local server",
- },
+ description: "Local server"
+ }
],
securityDefinitions: {
bearerAuth: {
type: "http",
scheme: "bearer",
bearerFormat: "JWT",
- description: "A service token in Infisical",
+ description: "A service token in Infisical"
},
apiKeyAuth: {
type: "apiKey",
in: "header",
name: "X-API-Key",
- description: "An API Key in Infisical",
- },
+ description: "An API Key in Infisical"
+ }
},
definitions: {
CurrentUser: {
@@ -50,7 +50,7 @@ const generateOpenAPISpec = async () => {
iv: "iv_of_enc_nacl_private_key",
tag: "tag_of_enc_nacl_private_key",
updatedAt: "2023-01-13T14:16:12.210Z",
- createdAt: "2023-01-13T14:16:12.210Z",
+ createdAt: "2023-01-13T14:16:12.210Z"
},
Membership: {
user: {
@@ -60,10 +60,10 @@ const generateOpenAPISpec = async () => {
lastName: "Doe",
publicKey: "johns_nacl_public_key",
updatedAt: "2023-01-13T14:16:12.210Z",
- createdAt: "2023-01-13T14:16:12.210Z",
+ createdAt: "2023-01-13T14:16:12.210Z"
},
workspace: "",
- role: "admin",
+ role: "admin"
},
MembershipOrg: {
user: {
@@ -73,33 +73,35 @@ const generateOpenAPISpec = async () => {
lastName: "Doe",
publicKey: "johns_nacl_public_key",
updatedAt: "2023-01-13T14:16:12.210Z",
- createdAt: "2023-01-13T14:16:12.210Z",
+ createdAt: "2023-01-13T14:16:12.210Z"
},
organization: "",
role: "owner",
- status: "accepted",
+ status: "accepted"
},
Organization: {
_id: "",
name: "Acme Corp.",
- customerId: "",
+ customerId: ""
},
Project: {
name: "My Project",
organization: "",
- environments: [{
- name: "development",
- slug: "dev",
- }],
+ environments: [
+ {
+ name: "development",
+ slug: "dev"
+ }
+ ]
},
ProjectKey: {
encryptedkey: "",
nonce: "",
sender: {
- publicKey: "senders_nacl_public_key",
+ publicKey: "senders_nacl_public_key"
},
receiver: "",
- workspace: "",
+ workspace: ""
},
CreateSecret: {
type: "shared",
@@ -111,7 +113,7 @@ const generateOpenAPISpec = async () => {
secretValueTag: "",
secretCommentCiphertext: "",
secretCommentIV: "",
- secretCommentTag: "",
+ secretCommentTag: ""
},
UpdateSecret: {
id: "",
@@ -123,12 +125,12 @@ const generateOpenAPISpec = async () => {
secretValueTag: "",
secretCommentCiphertext: "",
secretCommentIV: "",
- secretCommentTag: "",
+ secretCommentTag: ""
},
Secret: {
_id: "",
version: 1,
- workspace : "",
+ workspace: "",
type: "shared",
user: null,
secretKeyCiphertext: "",
@@ -141,7 +143,7 @@ const generateOpenAPISpec = async () => {
secretCommentIV: "",
secretCommentTag: "",
updatedAt: "2023-01-13T14:16:12.210Z",
- createdAt: "2023-01-13T14:16:12.210Z",
+ createdAt: "2023-01-13T14:16:12.210Z"
},
RawSecret: {
_id: "abc123",
@@ -167,12 +169,10 @@ const generateOpenAPISpec = async () => {
_id: "",
firstName: "John",
- lastName: "Doe",
+ lastName: "Doe"
},
workspace: "",
- actionNames: [
- "addSecrets",
- ],
+ actionNames: ["addSecrets"],
actions: [
{
name: "addSecrets",
@@ -181,24 +181,24 @@ const generateOpenAPISpec = async () => {
payload: [
{
oldSecretVersion: "",
- newSecretVersion: "",
- },
- ],
- },
+ newSecretVersion: ""
+ }
+ ]
+ }
],
channel: "cli",
ipAddress: "192.168.0.1",
updatedAt: "2023-01-13T14:16:12.210Z",
- createdAt: "2023-01-13T14:16:12.210Z",
+ createdAt: "2023-01-13T14:16:12.210Z"
},
SecretSnapshot: {
workspace: "",
version: 1,
secretVersions: [
{
- _id: "",
- },
- ],
+ _id: ""
+ }
+ ]
},
SecretVersion: {
_id: "",
@@ -214,7 +214,7 @@ const generateOpenAPISpec = async () => {
secretKeyTag: "",
secretValueCiphertext: "",
secretValueIV: "",
- secretValueTag: "",
+ secretValueTag: ""
},
ServiceTokenData: {
_id: "",
@@ -224,16 +224,32 @@ const generateOpenAPISpec = async () => {
user: {
_id: "",
firstName: "",
- lastName: "",
+ lastName: ""
},
expiresAt: "2023-01-13T14:16:12.210Z",
encryptedKey: "",
iv: "",
tag: "",
updatedAt: "2023-01-13T14:16:12.210Z",
- createdAt: "2023-01-13T14:16:12.210Z",
+ createdAt: "2023-01-13T14:16:12.210Z"
},
- },
+ AuditLog: {
+ actor: {
+ type: "",
+ metadata: {}
+ },
+ organization: "",
+ workspace: "",
+ ipAddress: "",
+ event: {
+ type: "",
+ metadata: {}
+ },
+ userAgent: "",
+ userAgentType: "",
+ expiresAt: ""
+ }
+ }
};
const outputJSONFile = "../spec.json";
@@ -243,6 +259,6 @@ const generateOpenAPISpec = async () => {
const spec = await swaggerAutogen(outputJSONFile, endpointsFiles, doc);
await fs.writeFile(outputYAMLFile, yaml.dump(spec.data));
-}
+};
-generateOpenAPISpec();
\ No newline at end of file
+generateOpenAPISpec();
diff --git a/docs/api-reference/endpoints/audit-logs/export-audit-log.mdx b/docs/api-reference/endpoints/audit-logs/export-audit-log.mdx
new file mode 100644
index 0000000000..6dce23eefd
--- /dev/null
+++ b/docs/api-reference/endpoints/audit-logs/export-audit-log.mdx
@@ -0,0 +1,4 @@
+---
+title: "Export"
+openapi: "GET /api/v1/{workspaceId}/audit-logs"
+---
diff --git a/docs/api-reference/endpoints/environments/create.mdx b/docs/api-reference/endpoints/environments/create.mdx
index 2bb14167cf..826dcce3df 100644
--- a/docs/api-reference/endpoints/environments/create.mdx
+++ b/docs/api-reference/endpoints/environments/create.mdx
@@ -1,4 +1,4 @@
---
title: "Create"
-openapi: "POST /api/v2/workspace/{workspaceId}/environments"
----
\ No newline at end of file
+openapi: "POST /api/v1/workspace/{workspaceId}/environments"
+---
diff --git a/docs/mint.json b/docs/mint.json
index e46b6fa25e..3b0b2460d2 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -380,6 +380,10 @@
{
"group": "Service Tokens",
"pages": ["api-reference/endpoints/service-tokens/get"]
+ },
+ {
+ "group": "Audit Logs",
+ "pages": ["api-reference/endpoints/audit-logs/export-audit-log"]
}
]
},
diff --git a/docs/spec.yaml b/docs/spec.yaml
index 6f12cbdf3b..2d1d0292e5 100644
--- a/docs/spec.yaml
+++ b/docs/spec.yaml
@@ -192,16 +192,73 @@ paths:
description: Version of secret snapshot to roll back to
/api/v1/workspace/{workspaceId}/audit-logs:
get:
- description: ''
+ summary: Return audit logs
+ description: Return audit logs
parameters:
- name: workspaceId
in: path
required: true
schema:
type: string
+ description: ID of the workspace where to get folders from
+ - name: offset
+ description: Number of versions to skip
+ required: false
+ in: query
+ schema:
+ type: string
+ - name: limit
+ description: Maximum number of versions to return
+ required: false
+ in: query
+ schema:
+ type: string
+ - name: startDate
+ description: Filter logs from the provided date
+ required: false
+ in: query
+ schema:
+ type: string
+ - name: endDate
+ description: Filter logs till the provided date
+ required: false
+ in: query
+ schema:
+ type: string
+ - name: eventType
+ description: Type of event
+ required: false
+ in: query
+ schema:
+ type: string
+ - name: userAgentType
+ description: Type of event
+ required: false
+ in: query
+ schema:
+ type: string
+ - name: actor
+ description: Source of operation. It can be user, service token etc
+ required: false
+ in: query
+ schema:
+ type: string
responses:
'200':
description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ auditLogs:
+ type: array
+ items:
+ $ref: '#/components/schemas/AuditLog'
+ description: List of audit log
+ security:
+ - apiKeyAuth: []
+ bearerAuth: []
/api/v1/workspace/{workspaceId}/audit-logs/filters/actors:
get:
description: ''
@@ -691,6 +748,28 @@ paths:
responses:
'200':
description: OK
+ /api/v1/admin/config:
+ get:
+ description: ''
+ responses:
+ '200':
+ description: OK
+ patch:
+ description: ''
+ responses:
+ '200':
+ description: OK
+ /api/v1/admin/signup:
+ post:
+ description: ''
+ parameters:
+ - name: user-agent
+ in: header
+ schema:
+ type: string
+ responses:
+ '200':
+ description: OK
/api/v1/bot/{workspaceId}:
get:
description: ''
@@ -4342,6 +4421,45 @@ components:
createdAt:
type: string
example: '2023-01-13T14:16:12.210Z'
+ AuditLog:
+ type: object
+ properties:
+ actor:
+ type: object
+ properties:
+ type:
+ type: string
+ example: ''
+ metadata:
+ type: object
+ properties: {}
+ organization:
+ type: string
+ example: ''
+ workspace:
+ type: string
+ example: ''
+ ipAddress:
+ type: string
+ example: ''
+ event:
+ type: object
+ properties:
+ type:
+ type: string
+ example: ''
+ metadata:
+ type: object
+ properties: {}
+ userAgent:
+ type: string
+ example: ''
+ userAgentType:
+ type: string
+ example: ''
+ expiresAt:
+ type: string
+ example: ''
securitySchemes:
bearerAuth:
type: http