Skip to content

Commit

Permalink
fix: keys setting vulns
Browse files Browse the repository at this point in the history
  • Loading branch information
ogzhanolguncu committed Dec 6, 2024
1 parent bca5871 commit 78f9c47
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
const formSchema = z.object({
keyAuthId: z.string(),
workspaceId: z.string(),
defaultBytes: z
.number()
.min(8, "Byte size needs to be at least 8")
Expand All @@ -30,7 +29,6 @@ const formSchema = z.object({
type Props = {
keyAuth: {
id: string;
workspaceId: string;
defaultBytes: number | undefined | null;
};
};
Expand All @@ -42,7 +40,6 @@ export const DefaultBytes: React.FC<Props> = ({ keyAuth }) => {
defaultValues: {
defaultBytes: keyAuth.defaultBytes ?? undefined,
keyAuthId: keyAuth.id,
workspaceId: keyAuth.workspaceId,
},
});

Expand Down Expand Up @@ -78,7 +75,6 @@ export const DefaultBytes: React.FC<Props> = ({ keyAuth }) => {
</CardHeader>
<CardContent>
<div className="flex flex-col space-y-2">
<input type="hidden" name="workspaceId" value={keyAuth.workspaceId} />
<input type="hidden" name="keyAuthId" value={keyAuth.id} />
<label className="hidden sr-only">Default Bytes</label>
<FormField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useRouter } from "next/navigation";
import { useForm } from "react-hook-form";
import { z } from "zod";

const formSchema = z.object({
keyAuthId: z.string(),
workspaceId: z.string(),
defaultPrefix: z.string(),
});

type Props = {
keyAuth: {
id: string;
workspaceId: string;
defaultPrefix: string | undefined | null;
};
};
Expand All @@ -38,7 +37,6 @@ export const DefaultPrefix: React.FC<Props> = ({ keyAuth }) => {
defaultValues: {
defaultPrefix: keyAuth.defaultPrefix ?? undefined,
keyAuthId: keyAuth.id,
workspaceId: keyAuth.workspaceId,
},
});

Expand Down Expand Up @@ -71,7 +69,6 @@ export const DefaultPrefix: React.FC<Props> = ({ keyAuth }) => {
</CardHeader>
<CardContent>
<div className="flex flex-col space-y-2">
<input type="hidden" name="workspaceId" value={keyAuth.workspaceId} />
<input type="hidden" name="keyAuthId" value={keyAuth.id} />
<label className="hidden sr-only">Default Prefix</label>
<FormField
Expand Down
3 changes: 1 addition & 2 deletions apps/dashboard/lib/trpc/routers/api/setDefaultBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const setDefaultApiBytes = t.procedure
.max(255, "Byte size cannot exceed 255")
.optional(),
keyAuthId: z.string(),
workspaceId: z.string(),
}),
)
.mutation(async ({ ctx, input }) => {
Expand All @@ -30,7 +29,7 @@ export const setDefaultApiBytes = t.procedure
"We were unable to find the KeyAuth. Please try again or contact support@unkey.dev.",
});
});
if (!keyAuth || keyAuth.workspaceId !== input.workspaceId) {
if (!keyAuth) {
throw new TRPCError({
code: "NOT_FOUND",
message:
Expand Down
3 changes: 1 addition & 2 deletions apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const setDefaultApiPrefix = t.procedure
z.object({
defaultPrefix: z.string().max(8, "Prefix can be a maximum of 8 characters"),
keyAuthId: z.string(),
workspaceId: z.string(),
}),
)
.mutation(async ({ ctx, input }) => {
Expand All @@ -25,7 +24,7 @@ export const setDefaultApiPrefix = t.procedure
message: "We were unable to find KeyAuth. Please try again or contact support@unkey.dev.",
});
});
if (!keyAuth || keyAuth.workspaceId !== input.workspaceId) {
if (!keyAuth) {
throw new TRPCError({
code: "NOT_FOUND",
message:
Expand Down

0 comments on commit 78f9c47

Please sign in to comment.