updates to events

This commit is contained in:
Kiran K 2023-05-09 15:11:47 +05:30
parent 49f63627e6
commit ebad04c7b3
14 changed files with 176 additions and 97 deletions

View File

@ -41,12 +41,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
const app = await samlFederatedController.app.get(id);
const metadata = await samlFederatedController.app.getMetadata();
sendAudit({
action: 'federation.app.view',
crud: 'r',
req,
});
return res.status(200).json({
data: {
...app,

View File

@ -72,12 +72,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
res.setHeader('jackson-pagetoken', apps.pageToken);
}
sendAudit({
action: 'federation.app.view',
crud: 'r',
req,
});
return res.json({ data: apps.data });
};

View File

@ -27,13 +27,9 @@ export const redactApiKey = (apiKey: string | null) => {
throw new Error('API key must be provided');
}
const redactLength = Math.floor(apiKey.length / 3);
const redactedLength = 4;
const apiKeyLength = apiKey.length;
const redactedPart = '*'.repeat(redactedLength);
if (redactLength === 0) {
throw new Error('API key is too short to redact');
}
const redactedPart = '*'.repeat(redactLength);
return apiKey.substring(0, apiKey.length - redactLength) + redactedPart;
return apiKey.substring(0, apiKeyLength - 4) + redactedPart;
};

168
package-lock.json generated
View File

@ -20420,6 +20420,126 @@
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.3.0.tgz",
"integrity": "sha512-oQoqFa88OGgwnYlnAGHVct618FRI/749se0N3S8t9Bzdv5CRbscnO0RcX901+YnNK4Q6yeiizfgO3b7kogtsZg==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.3.0.tgz",
"integrity": "sha512-Wzz2p/WqAJUqTVoLo6H18WMeAXo3i+9DkPDae4oQG8LMloJ3if4NEZTnOnTUlro6cq+S/W4pTGa97nWTrOjbGw==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.3.0.tgz",
"integrity": "sha512-xPVrIQOQo9WXJYgmoTlMnAD/HlR/1e1ZIWGbwIzEirXBVBqMARUulBEIKdC19zuvoJ477qZJgBDCKtKEykCpyQ==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.3.0.tgz",
"integrity": "sha512-jOFlpGuPD7W2tuXVJP4wt9a3cpNxWAPcloq5EfMJRiXsBBOjLVFZA7boXYxEBzSVgUiVVr1V9T0HFM7pULJ1qA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.3.0.tgz",
"integrity": "sha512-2OwKlzaBgmuet9XYHc3KwsEilzb04F540rlRXkAcjMHL7eCxB7uZIGtsVvKOnQLvC/elrUegwSw1+5f7WmfyOw==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.3.0.tgz",
"integrity": "sha512-OeHiA6YEvndxT46g+rzFK/MQTfftKxJmzslERMu9LDdC6Kez0bdrgEYed5eXFK2Z1viKZJCGRlhd06rBusyztA==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.3.0.tgz",
"integrity": "sha512-4aB7K9mcVK1lYEzpOpqWrXHEZympU3oK65fnNcY1Qc4HLJFLJj8AViuqQd4jjjPNuV4sl8jAwTz3gN5VNGWB7w==",
"cpu": [
"ia32"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.3.0.tgz",
"integrity": "sha512-Reer6rkLLcoOvB0dd66+Y7WrWVFH7sEEkF/4bJCIfsSKnTStTYaHtwIJAwbqnt9I392Tqvku0KkoqZOryWV9LQ==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
}
},
"dependencies": {
@ -32830,6 +32950,54 @@
"optional": true
}
}
},
"@next/swc-darwin-x64": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.3.0.tgz",
"integrity": "sha512-oQoqFa88OGgwnYlnAGHVct618FRI/749se0N3S8t9Bzdv5CRbscnO0RcX901+YnNK4Q6yeiizfgO3b7kogtsZg==",
"optional": true
},
"@next/swc-linux-arm64-gnu": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.3.0.tgz",
"integrity": "sha512-Wzz2p/WqAJUqTVoLo6H18WMeAXo3i+9DkPDae4oQG8LMloJ3if4NEZTnOnTUlro6cq+S/W4pTGa97nWTrOjbGw==",
"optional": true
},
"@next/swc-linux-arm64-musl": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.3.0.tgz",
"integrity": "sha512-xPVrIQOQo9WXJYgmoTlMnAD/HlR/1e1ZIWGbwIzEirXBVBqMARUulBEIKdC19zuvoJ477qZJgBDCKtKEykCpyQ==",
"optional": true
},
"@next/swc-linux-x64-gnu": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.3.0.tgz",
"integrity": "sha512-jOFlpGuPD7W2tuXVJP4wt9a3cpNxWAPcloq5EfMJRiXsBBOjLVFZA7boXYxEBzSVgUiVVr1V9T0HFM7pULJ1qA==",
"optional": true
},
"@next/swc-linux-x64-musl": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.3.0.tgz",
"integrity": "sha512-2OwKlzaBgmuet9XYHc3KwsEilzb04F540rlRXkAcjMHL7eCxB7uZIGtsVvKOnQLvC/elrUegwSw1+5f7WmfyOw==",
"optional": true
},
"@next/swc-win32-arm64-msvc": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.3.0.tgz",
"integrity": "sha512-OeHiA6YEvndxT46g+rzFK/MQTfftKxJmzslERMu9LDdC6Kez0bdrgEYed5eXFK2Z1viKZJCGRlhd06rBusyztA==",
"optional": true
},
"@next/swc-win32-ia32-msvc": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.3.0.tgz",
"integrity": "sha512-4aB7K9mcVK1lYEzpOpqWrXHEZympU3oK65fnNcY1Qc4HLJFLJj8AViuqQd4jjjPNuV4sl8jAwTz3gN5VNGWB7w==",
"optional": true
},
"@next/swc-win32-x64-msvc": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.3.0.tgz",
"integrity": "sha512-Reer6rkLLcoOvB0dd66+Y7WrWVFH7sEEkF/4bJCIfsSKnTStTYaHtwIJAwbqnt9I392Tqvku0KkoqZOryWV9LQ==",
"optional": true
}
}
}

View File

@ -1,7 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import jackson from '@lib/jackson';
import { sendAudit } from '@ee/audit-log/lib/retraced';
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { method } = req;
@ -26,12 +25,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
try {
const connections = await connectionAPIController.getConnections({ clientID: clientId });
sendAudit({
action: 'sso.connection.view',
crud: 'r',
req,
});
return res.json({ data: connections[0] });
} catch (error: any) {
const { message, statusCode = 500 } = error;

View File

@ -59,12 +59,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
res.setHeader('jackson-pagetoken', paginatedConnectionList.pageToken);
}
sendAudit({
action: 'sso.connection.view',
crud: 'r',
req,
});
return res.json({ data: connections });
};

View File

@ -49,12 +49,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
const { data, error } = await directorySyncController.directories.get(directoryId);
sendAudit({
action: 'dsync.connection.view',
crud: 'r',
req,
});
if (data) {
return res.status(200).json({ data });
}

View File

@ -68,12 +68,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
res.setHeader('jackson-pagetoken', nextPageToken);
}
sendAudit({
action: 'dsync.connection.view',
crud: 'r',
req,
});
if (data) {
return res.status(200).json({ data });
}

View File

@ -4,7 +4,6 @@ import axios from 'axios';
import type { Project } from 'types/retraced';
import { getToken } from '@lib/retraced';
import { retracedOptions } from '@lib/env';
import { sendAudit } from '@ee/audit-log/lib/retraced';
async function handler(req: NextApiRequest, res: NextApiResponse) {
const { method } = req;
@ -35,12 +34,6 @@ const getProject = async (req: NextApiRequest, res: NextApiResponse) => {
}
);
sendAudit({
action: 'retraced.project.view',
crud: 'r',
req,
});
return res.status(201).json({
data,
error: null,

View File

@ -68,12 +68,6 @@ const getProjects = async (req: NextApiRequest, res: NextApiResponse) => {
}
);
sendAudit({
action: 'retraced.project.view',
crud: 'r',
req,
});
return res.status(200).json({
data,
});

View File

@ -1,7 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import jackson from '@lib/jackson';
import type { IAdminController } from '@boxyhq/saml-jackson';
import { sendAudit } from '@ee/audit-log/lib/retraced';
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { method } = req;
@ -32,12 +31,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse, adminControl
return res.status(404).json({ error: { message: 'Trace not found.' } });
}
sendAudit({
action: 'saml.tracer.view',
crud: 'r',
req,
});
return res.json({ data: trace });
};

View File

@ -1,7 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import jackson from '@lib/jackson';
import type { IAdminController } from '@boxyhq/saml-jackson';
import { sendAudit } from '@ee/audit-log/lib/retraced';
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { method } = req;
@ -35,12 +34,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse, adminControl
res.setHeader('jackson-pagetoken', tracesPaginated.pageToken);
}
sendAudit({
action: 'saml.tracer.view',
crud: 'r',
req,
});
return res.json({ data: tracesPaginated.data });
};

View File

@ -93,12 +93,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
if (token) {
const setupLink = await setupLinkController.getByToken(token);
sendAudit({
action: setupLink.service === 'dsync' ? 'dsync.setuplink.view' : 'sso.setuplink.view',
crud: 'r',
req,
});
return res.json({ data: setupLink });
}
@ -115,12 +109,6 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
res.setHeader('jackson-pagetoken', setupLinksPaginated.pageToken);
}
sendAudit({
action: service === 'dsync' ? 'dsync.setuplink.view' : 'sso.setuplink.view',
crud: 'r',
req,
});
return res.json({ data: setupLinksPaginated.data });
}
};

View File

@ -50,33 +50,24 @@ export type AuditEventType =
| 'sso.connection.create'
| 'sso.connection.update'
| 'sso.connection.delete'
| 'sso.connection.view'
| 'sso.setuplink.create'
| 'sso.setuplink.delete'
| 'sso.setuplink.view'
// Directory Sync
| 'dsync.connection.create'
| 'dsync.connection.update'
| 'dsync.connection.delete'
| 'dsync.connection.view'
| 'dsync.setuplink.create'
| 'dsync.setuplink.delete'
| 'dsync.setuplink.view'
// Federated SAML
| 'federation.app.create'
| 'federation.app.update'
| 'federation.app.delete'
| 'federation.app.view'
// SAML Tracer
| 'saml.tracer.view'
// Retraced
| 'retraced.project.create'
| 'retraced.project.view'
// Admin
| 'admin.branding.update'
| 'admin.auth.login';
| 'admin.auth.login'
// Retraced
| 'retraced.project.create';