Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keys setting vulns #2718

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
chronark marked this conversation as resolved.
Show resolved Hide resolved
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) {
chronark marked this conversation as resolved.
Show resolved Hide resolved
if (!keyAuth) {
throw new TRPCError({
code: "NOT_FOUND",
message:
Expand Down
Loading