Skip to content

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

Merge remote-tracking branch 'origin/main' into ENG-3546

Carlos Monastyrski1909fae07676
diff --cc backend/src/@types/fastify.d.ts
index a059eaf72c,c25d8d4d15..47973cc096
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@@ -83,6 -83,6 +83,7 @@@ import { TIdentityUaServiceFactory } fr
import { TIntegrationServiceFactory } from "@app/services/integration/integration-service";
import { TIntegrationAuthServiceFactory } from "@app/services/integration-auth/integration-auth-service";
import { TMicrosoftTeamsServiceFactory } from "@app/services/microsoft-teams/microsoft-teams-service";
++import { TOfflineUsageReportServiceFactory } from "@app/services/offline-usage-report/offline-usage-report-service";
import { TOrgRoleServiceFactory } from "@app/services/org/org-role-service";
import { TOrgServiceFactory } from "@app/services/org/org-service";
import { TOrgAdminServiceFactory } from "@app/services/org-admin/org-admin-service";
diff --cc backend/src/server/routes/index.ts
index 88ab64847c,c5387a0f6c..9af4f6adef
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@@ -844,14 -842,11 +845,16 @@@ export const registerRoutes = async
licenseService,
kmsService,
microsoftTeamsService,
- invalidateCacheQueue
+ invalidateCacheQueue,
+ smtpService,
+ tokenService
});
+ const offlineUsageReportService = offlineUsageReportServiceFactory({
+ offlineUsageReportDAL,
+ licenseService
+ });
+
const orgAdminService = orgAdminServiceFactory({
smtpService,
projectDAL,
diff --cc backend/src/server/routes/v1/admin-router.ts
index 0b19906ba0,d4f5eb8b03..7f5a2f3745
--- a/backend/src/server/routes/v1/admin-router.ts
+++ b/backend/src/server/routes/v1/admin-router.ts
@@@ -841,35 -841,89 +843,120 @@@ export const registerAdminRouter = asyn
}
});
- // Usage Report Routes
+ server.route({
+ method: "POST",
+ url: "/organization-management/organizations",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ body: z.object({
+ name: GenericResourceNameSchema,
+ inviteAdminEmails: z.string().email().array().min(1)
+ }),
+ response: {
+ 200: z.object({
+ organization: OrganizationsSchema
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async (req) => {
+ const organization = await server.services.superAdmin.createOrganization(req.body, req.permission);
+ return { organization };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/organization-management/organizations/:organizationId/memberships/:membershipId/resend-invite",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ organizationId: z.string(),
+ membershipId: z.string()
+ }),
+ response: {
+ 200: z.object({
+ organizationMembership: OrgMembershipsSchema
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async (req) => {
+ const organizationMembership = await server.services.superAdmin.resendOrgInvite(req.params, req.permission);
+ return { organizationMembership };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/organization-management/organizations/:organizationId/access",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ organizationId: z.string()
+ }),
+ response: {
+ 200: z.object({
+ organizationMembership: OrgMembershipsSchema
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async (req) => {
+ const organizationMembership = await server.services.superAdmin.joinOrganization(
+ req.params.organizationId,
+ req.permission
+ );
+ return { organizationMembership };
+ }
+ });
++
+ server.route({
+ method: "POST",
+ url: "/usage-report/generate",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ response: {
+ 200: z.object({
+ csvContent: z.string(),
+ signature: z.string(),
+ filename: z.string()
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async () => {
+ const result = await server.services.offlineUsageReport.generateUsageReportCSV();
+
+ return {
+ csvContent: result.csvContent,
+ signature: result.signature,
+ filename: result.filename
+ };
+ }
+ });
};
diff --cc frontend/src/hooks/api/admin/mutation.ts
index 5ea351c340,b7ab0ea6fe..918a0ecd5e
--- a/frontend/src/hooks/api/admin/mutation.ts
+++ b/frontend/src/hooks/api/admin/mutation.ts
@@@ -8,10 -9,11 +9,12 @@@ import { adminQueryKeys, adminStandalon
import {
RootKeyEncryptionStrategy,
TCreateAdminUserDTO,
+ TCreateOrganizationDTO,
TInvalidateCacheDTO,
+ TResendOrgInviteDTO,
TServerConfig,
- TUpdateServerConfigDTO
+ TUpdateServerConfigDTO,
+ TUsageReportResponse
} from "./types";
export const useCreateAdminUser = () => {
@@@ -195,13 -197,46 +198,57 @@@ export const useInvalidateCache = () =
});
};
+ export const useServerAdminCreateOrganization = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (opt: TCreateOrganizationDTO) => {
+ const { data } = await apiRequest.post<{ organization: Organization }>(
+ "/api/v1/admin/organization-management/organizations",
+ opt
+ );
+ return data;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: adminQueryKeys.getOrganizations() });
+ }
+ });
+ };
+
+ export const useServerAdminResendOrgInvite = () => {
+ return useMutation({
+ mutationFn: async ({ organizationId, membershipId }: TResendOrgInviteDTO) => {
+ await apiRequest.post(
+ `/api/v1/admin/organization-management/organizations/${organizationId}/memberships/${membershipId}/resend-invite`
+ );
+ }
+ });
+ };
+
+ export const useServerAdminAccessOrg = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (orgId: string) => {
+ const { data } = await apiRequest.post(
+ `/api/v1/admin/organization-management/organizations/${orgId}/access`
+ );
+ return data;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
+ queryClient.invalidateQueries({ queryKey: adminQueryKeys.getOrganizations() });
+ }
+ });
+ };
++
+export const useGenerateUsageReport = () => {
+ return useMutation<TUsageReportResponse, object, void>({
+ mutationFn: async () => {
+ const { data } = await apiRequest.post<TUsageReportResponse>(
+ "/api/v1/admin/usage-report/generate"
+ );
+ return data;
+ }
+ });
+};
diff --cc frontend/src/hooks/api/admin/types.ts
index 769aaccfc1,f6c2f1a23c..f8336fcacf
--- a/frontend/src/hooks/api/admin/types.ts
+++ b/frontend/src/hooks/api/admin/types.ts
@@@ -144,8 -146,12 +147,18 @@@ export interface TGetEnvOverrides
};
}
+export type TUsageReportResponse = {
+ filename: string;
+ csvContent: string;
+ signature: string;
+};
++
+ export type TCreateOrganizationDTO = {
+ name: string;
+ inviteAdminEmails: string[];
+ };
+
+ export type TResendOrgInviteDTO = {
+ organizationId: string;
+ membershipId: string;
+ };