Skip to content

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

feat(ui): added new scim event table

=46f621bca47f
diff --git a/frontend/src/hooks/api/scim/queries.tsx b/frontend/src/hooks/api/scim/queries.tsx
index 3aa578efb3..0bfb906c33 100644
--- a/frontend/src/hooks/api/scim/queries.tsx
+++ b/frontend/src/hooks/api/scim/queries.tsx
@@ -1,11 +1,12 @@
-import { useQuery } from "@tanstack/react-query";
+import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
-import { ScimTokenData } from "./types";
+import { GetScimEventsDTO, ScimEventData, ScimTokenData } from "./types";
export const scimKeys = {
- getScimTokens: (orgId: string) => [{ orgId }, "organization-scim-token"] as const
+ getScimTokens: (orgId: string) => [{ orgId }, "organization-scim-token"] as const,
+ getScimEvents: (params: GetScimEventsDTO) => [{ ...params }, "organization-scim-events"] as const
};
export const useGetScimTokens = (organizationId: string) => {
@@ -27,3 +28,27 @@ export const useGetScimTokens = (organizationId: string) => {
enabled: true
});
};
+
+export const useGetScimEvents = ({ fromDate, limit = 10, offset, disabled }: GetScimEventsDTO) => {
+ return useInfiniteQuery({
+ initialPageParam: 0,
+ queryKey: scimKeys.getScimEvents({ fromDate, limit, offset }),
+ queryFn: async ({ pageParam }) => {
+ const {
+ data: { scimEvents }
+ } = await apiRequest.get<{ scimEvents: ScimEventData[] }>("/api/v1/scim/scim-events", {
+ params: {
+ fromDate,
+ limit,
+ offset: pageParam
+ }
+ });
+
+ return scimEvents;
+ },
+ enabled: !disabled,
+ getNextPageParam: (lastPage, pages) =>
+ lastPage.length !== 0 ? pages.length * limit : undefined,
+ placeholderData: (prev) => prev
+ });
+};
diff --git a/frontend/src/hooks/api/scim/types.ts b/frontend/src/hooks/api/scim/types.ts
index 45bdf2f4c9..b9392417c9 100644
--- a/frontend/src/hooks/api/scim/types.ts
+++ b/frontend/src/hooks/api/scim/types.ts
@@ -1,3 +1,19 @@
+export enum ScimEvent {
+ LIST_USERS = "list-users",
+ GET_USER = "get-user",
+ CREATE_USER = "create-user",
+ UPDATE_USER = "update-user",
+ REPLACE_USER = "replace-user",
+ DELETE_USER = "delete-user",
+
+ LIST_GROUPS = "list-groups",
+ GET_GROUP = "get-group",
+ CREATE_GROUP = "create-group",
+ UPDATE_GROUP = "update-group",
+ REPLACE_GROUP = "replace-group",
+ DELETE_GROUP = "delete-group"
+}
+
export type ScimTokenData = {
id: string;
ttlDays: number;
@@ -22,3 +38,19 @@ export type DeleteScimTokenDTO = {
export type CreateScimTokenRes = {
scimToken: string;
};
+
+export type ScimEventData = {
+ id: string;
+ orgId: string;
+ eventType: ScimEvent;
+ event?: any | null;
+ createdAt: string;
+ updatedAt: string;
+};
+
+export type GetScimEventsDTO = {
+ fromDate?: string;
+ limit?: number;
+ offset?: number;
+ disabled?: boolean;
+};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgProvisioningTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgProvisioningTab.tsx
index 43822aaff6..9772aa2d42 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgProvisioningTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgProvisioningTab.tsx
@@ -3,6 +3,7 @@ import { withPermission } from "@app/hoc";
import { OrgGithubSyncSection } from "./OrgGithubSyncSection";
import { OrgScimSection } from "./OrgSCIMSection";
+import { ScimEvents } from "./ScimEvents";
export const OrgProvisioningTab = withPermission(
() => {
@@ -10,6 +11,7 @@ export const OrgProvisioningTab = withPermission(
<>
<OrgScimSection />
<OrgGithubSyncSection />
+ <ScimEvents />
</>
);
},
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/ScimEvents.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/ScimEvents.tsx
new file mode 100644
index 0000000000..9583f2793f
--- /dev/null
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/ScimEvents.tsx
@@ -0,0 +1,139 @@
+import { Fragment } from "react/jsx-runtime";
+import { faFile, faInfoCircle } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import {
+ Button,
+ EmptyState,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tooltip,
+ Tr
+} from "@app/components/v2";
+import { useOrganization } from "@app/context";
+import { formatDateTime } from "@app/helpers/datetime";
+import { useGetScimEvents } from "@app/hooks/api/scim/queries";
+import { ScimEvent, ScimEventData } from "@app/hooks/api/scim/types";
+
+export const ScimEvents = () => {
+ const { currentOrg } = useOrganization();
+ const {
+ data: scimEvents,
+ isPending,
+ isFetchingNextPage,
+ hasNextPage,
+ fetchNextPage
+ } = useGetScimEvents({
+ fromDate: "30d",
+ disabled: !currentOrg?.scimEnabled
+ });
+
+ if (!currentOrg?.scimEnabled) return null;
+
+ const isEmpty = !isPending && !scimEvents?.pages?.[0].length;
+
+ const getEntityDetails = (event: ScimEventData) => {
+ if (event.eventType.includes("users")) {
+ if (event.eventType === ScimEvent.LIST_USERS)
+ return `Number of users: ${event.event?.numberOfUsers}`;
+
+ return event.event?.email;
+ }
+ if (event.eventType.includes("group")) {
+ if (event.eventType === ScimEvent.LIST_GROUPS)
+ return `Number of groups: ${event.event?.numberOfGroups}`;
+
+ return event.event?.groupName;
+ }
+ return "";
+ };
+
+ return (
+ <div className="mt-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ <div>
+ <p className="text-xl font-medium text-gray-200">SCIM Events</p>
+ <p className="mt-1 mb-4 text-sm text-gray-400">
+ List of all SCIM events that were successfully provisioned from the SCIM server
+ </p>
+ </div>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-64">Timestamp</Th>
+ <Th>Event</Th>
+ <Th>Entity</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {!isPending &&
+ scimEvents?.pages?.map((group, i) => (
+ <Fragment key={`audit-log-fragment-${i + 1}`}>
+ {group.map((scimEvent) => (
+ <Tr
+ key={`audit-log-${scimEvent.id}`}
+ className="group h-10 cursor-pointer border-x-0 border-t-0 border-b hover:bg-mineshaft-700"
+ role="button"
+ tabIndex={0}
+ >
+ <Td className="align-top">
+ {formatDateTime({ timestamp: scimEvent.createdAt })}
+ </Td>
+ <Td>
+ <div className="flex flex-wrap gap-4 text-sm">{scimEvent.eventType}</div>
+ </Td>
+ <Td>
+ <div className="flex flex-wrap gap-4 text-sm">
+ {getEntityDetails(scimEvent)}
+ <div>
+ <Tooltip
+ content={
+ <div className="my-1 max-h-96 thin-scrollbar overflow-auto rounded-sm border border-mineshaft-600 bg-bunker-800 p-2 font-mono leading-6 whitespace-pre-wrap">
+ {JSON.stringify(scimEvent, null, 4)}
+ </div>
+ }
+ className="max-w-xl"
+ >
+ <FontAwesomeIcon
+ icon={faInfoCircle}
+ className="opacity-0 transition-all group-hover:opacity-100"
+ />
+ </Tooltip>
+ </div>
+ </div>
+ </Td>
+ </Tr>
+ ))}
+ </Fragment>
+ ))}
+ {isPending && <TableSkeleton innerKey="logs-table" columns={3} key="logs-loading" />}
+ {isEmpty && (
+ <Tr>
+ <Td colSpan={3}>
+ <EmptyState title="No scim events on file" icon={faFile} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ {!isEmpty && (
+ <Button
+ className="mt-4 px-4 py-3 text-sm"
+ isFullWidth
+ variant="outline_bg"
+ isLoading={isFetchingNextPage}
+ isDisabled={isFetchingNextPage || !hasNextPage}
+ onClick={() => fetchNextPage()}
+ >
+ {hasNextPage ? "Load More" : "End of logs"}
+ </Button>
+ )}
+ </div>
+ );
+};