Skip to content

Commit 343514d

Browse files
committed
fix: allow members to use SSH keys for deployments without full SSH key access
Add allForApps endpoint that returns only sshKeyId and name using protectedProcedure instead of withPermission, so members can select SSH keys in the git provider dropdown without needing access to the SSH Keys management panel. closes #4069
1 parent 3606761 commit 343514d

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

apps/dokploy/components/dashboard/application/general/generic/save-git-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interface Props {
5555

5656
export const SaveGitProvider = ({ applicationId }: Props) => {
5757
const { data, refetch } = api.application.one.useQuery({ applicationId });
58-
const { data: sshKeys } = api.sshKey.all.useQuery();
58+
const { data: sshKeys } = api.sshKey.allForApps.useQuery();
5959
const router = useRouter();
6060

6161
const { mutateAsync, isPending } =

apps/dokploy/components/dashboard/compose/general/generic/save-git-provider-compose.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interface Props {
5555

5656
export const SaveGitProviderCompose = ({ composeId }: Props) => {
5757
const { data, refetch } = api.compose.one.useQuery({ composeId });
58-
const { data: sshKeys } = api.sshKey.all.useQuery();
58+
const { data: sshKeys } = api.sshKey.allForApps.useQuery();
5959
const router = useRouter();
6060

6161
const { mutateAsync, isPending } = api.compose.update.useMutation();

apps/dokploy/server/api/routers/ssh-key.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
import { db } from "@dokploy/server/db";
99
import { TRPCError } from "@trpc/server";
1010
import { desc, eq } from "drizzle-orm";
11-
import { createTRPCRouter, withPermission } from "@/server/api/trpc";
11+
import {
12+
createTRPCRouter,
13+
protectedProcedure,
14+
withPermission,
15+
} from "@/server/api/trpc";
1216
import { audit } from "@/server/api/utils/audit";
1317
import {
1418
apiCreateSshKey,
@@ -83,6 +87,16 @@ export const sshRouter = createTRPCRouter({
8387
orderBy: desc(sshKeys.createdAt),
8488
});
8589
}),
90+
allForApps: protectedProcedure.query(async ({ ctx }) => {
91+
return await db.query.sshKeys.findMany({
92+
columns: {
93+
sshKeyId: true,
94+
name: true,
95+
},
96+
where: eq(sshKeys.organizationId, ctx.session.activeOrganizationId),
97+
orderBy: desc(sshKeys.createdAt),
98+
});
99+
}),
86100
generate: withPermission("sshKeys", "read")
87101
.input(apiGenerateSSHKey)
88102
.mutation(async ({ input }) => {

0 commit comments

Comments
 (0)