mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-22 01:28:22 +00:00
feat(infisical-pg): added routes for workspaces and updated frontend
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { registerMfaRouter } from "./mfa-router";
|
||||
import { registerProjectRouter } from "./project-router";
|
||||
import { registerUserRouter } from "./user-router";
|
||||
|
||||
export const registerV2Routes = async (server: FastifyZodProvider) => {
|
||||
await server.register(registerMfaRouter, { prefix: "/auth" });
|
||||
await server.register(registerUserRouter, { prefix: "/users" });
|
||||
await server.register(
|
||||
async (projectServer) => {
|
||||
projectServer.register(registerProjectRouter);
|
||||
},
|
||||
{ prefix: "/workspace" }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { ProjectKeysSchema } from "@app/db/schemas";
|
||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||
import { AuthMode } from "@app/services/auth/auth-type";
|
||||
import { z } from "zod";
|
||||
|
||||
export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
||||
server.route({
|
||||
url: "/:workspaceId/encrypted-key",
|
||||
method: "GET",
|
||||
schema: {
|
||||
params: z.object({
|
||||
workspaceId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: ProjectKeysSchema.merge(
|
||||
z.object({
|
||||
sender: z.object({
|
||||
publicKey: z.string()
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
},
|
||||
onResponse: verifyAuth([AuthMode.JWT, AuthMode.API_KEY]),
|
||||
handler: async (req) => {
|
||||
const key = await server.services.projectKey.getLatestProjectKey({
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
projectId: req.params.workspaceId
|
||||
});
|
||||
|
||||
return key;
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user