Skip to content

Commit 4a1b428

Browse files
authored
Merge pull request #4168 from Dokploy/fix/ssh-key-member-access
fix: allow members to use SSH keys for deployments without full access
2 parents 3606761 + 343514d commit 4a1b428

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)