mirror of https://github.com/boxyhq/jackson.git
Add retraced event to dsync
This commit is contained in:
parent
70d7a21a0f
commit
0097cfe9b0
|
@ -15,12 +15,39 @@ export const adminPortalGroup = {
|
|||
|
||||
type AuditEventType =
|
||||
| 'sso.user.login'
|
||||
|
||||
// Single Sign On
|
||||
| 'sso.connection.create'
|
||||
| 'sso.connection.update'
|
||||
| 'sso.connection.delete'
|
||||
| 'sso.connection.list'
|
||||
| 'sso.connection.get'
|
||||
|
||||
// Directory Sync
|
||||
| 'dsync.connection.create'
|
||||
| 'dsync.connection.update'
|
||||
| 'dsync.connection.delete'
|
||||
| 'dsync.connection.list'
|
||||
| 'dsync.connection.get'
|
||||
| 'dsync.user.list'
|
||||
| 'dsync.user.get'
|
||||
| 'dsync.group.list'
|
||||
| 'dsync.group.get'
|
||||
| 'dsync.webhook_event.list'
|
||||
| 'dsync.webhook_event.get'
|
||||
| 'dsync.webhook_event.delete'
|
||||
|
||||
// Setup Link
|
||||
| 'sso.setuplink.create'
|
||||
| 'sso.setuplink.delete';
|
||||
| 'sso.setuplink.update'
|
||||
| 'sso.setuplink.delete'
|
||||
| 'sso.setuplink.list'
|
||||
| 'sso.setuplink.get'
|
||||
| 'dsync.setuplink.create'
|
||||
| 'dsync.setuplink.update'
|
||||
| 'dsync.setuplink.delete'
|
||||
| 'dsync.setuplink.list'
|
||||
| 'dsync.setuplink.get';
|
||||
|
||||
type ReportAdminEventParams = {
|
||||
action: AuditEventType;
|
||||
|
|
|
@ -27,7 +27,7 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
const connections = await connectionAPIController.getConnections({ clientID: clientId });
|
||||
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'sso.connection.list',
|
||||
action: 'sso.connection.get',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -37,6 +38,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
.setTenantAndProduct(directory.tenant, directory.product)
|
||||
.get(eventId);
|
||||
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.webhook_event.get',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: eventId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: event });
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -47,6 +48,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
directoryId,
|
||||
});
|
||||
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.webhook_event.list',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: events });
|
||||
};
|
||||
|
||||
|
@ -70,6 +80,15 @@ const handleDELETE = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
.setTenantAndProduct(directory.tenant, directory.product)
|
||||
.deleteAll(directoryId);
|
||||
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.webhook_event.delete',
|
||||
crud: 'd',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: null });
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -34,6 +35,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
}
|
||||
|
||||
if (group) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.group.get',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: groupId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: group });
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -37,6 +38,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
}
|
||||
|
||||
if (groups) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.group.list',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: groups });
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -26,6 +27,15 @@ const handlePATCH = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
const { data, error } = await directorySyncController.directories.update(directoryId, req.body);
|
||||
|
||||
if (data) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.connection.update',
|
||||
crud: 'u',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data });
|
||||
}
|
||||
|
||||
|
@ -43,6 +53,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
const { data, error } = await directorySyncController.directories.get(directoryId);
|
||||
|
||||
if (data) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.connection.get',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data });
|
||||
}
|
||||
|
||||
|
@ -63,6 +82,15 @@ const handleDELETE = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
return res.status(error.code).json({ error });
|
||||
}
|
||||
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.connection.delete',
|
||||
crud: 'd',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.json({ data: null });
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -34,6 +35,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
}
|
||||
|
||||
if (user) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.user.get',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: userId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: user });
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -37,6 +38,15 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
}
|
||||
|
||||
if (users) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.user.list',
|
||||
crud: 'r',
|
||||
req,
|
||||
target: {
|
||||
id: directoryId,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({ data: users });
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import type { DirectoryType } from '@boxyhq/saml-jackson';
|
||||
import jackson from '@lib/jackson';
|
||||
import retraced from '@ee/retraced';
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { method } = req;
|
||||
|
@ -32,6 +33,15 @@ const handlePOST = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
});
|
||||
|
||||
if (data) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.connection.create',
|
||||
crud: 'c',
|
||||
req,
|
||||
target: {
|
||||
id: data.id,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(201).json({ data });
|
||||
}
|
||||
|
||||
|
@ -59,6 +69,12 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
});
|
||||
|
||||
if (nextPageToken) {
|
||||
retraced.reportAdminPortalEvent({
|
||||
action: 'dsync.connection.list',
|
||||
crud: 'r',
|
||||
req,
|
||||
});
|
||||
|
||||
res.setHeader('jackson-pagetoken', nextPageToken);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue