Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

display the partial client secret

Kiran K5b78dcb89b53
diff --git a/apps/web/app/api/oauth/apps/route.ts b/apps/web/app/api/oauth/apps/route.ts
index 2094b72337..2fa9a86c1f 100644
--- a/apps/web/app/api/oauth/apps/route.ts
+++ b/apps/web/app/api/oauth/apps/route.ts
@@ -86,6 +86,7 @@ export const POST = withWorkspace(
logo,
clientId,
hashedClientSecret: await hashToken(clientSecret),
+ partialClientSecret: `${clientSecret.slice(0, 3)}...${clientSecret.slice(-4)}`,
userId: session.user.id,
pkce,
},
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/manage/[integrationId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/manage/[integrationId]/page-client.tsx
index 7b68d0b5aa..197eebe56e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/manage/[integrationId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/manage/[integrationId]/page-client.tsx
@@ -140,7 +140,7 @@ export default function IntegrationManagePageClient({
</div>
</MaxWidthWrapper>
- <MaxWidthWrapper className="max-w-screen-lg space-y-10">
+ <MaxWidthWrapper className="max-w-screen-lg space-y-6">
<OAuthAppCredentials
clientId={integration.clientId}
clientSecret={
@@ -148,7 +148,9 @@ export default function IntegrationManagePageClient({
searchParams.get("client_secret") ||
null
}
+ partialClientSecret={integration.partialClientSecret || null}
/>
+ <hr />
<AddEditIntegrationForm integration={integration} />
</MaxWidthWrapper>
</>
diff --git a/apps/web/lib/actions/generate-client-secret.ts b/apps/web/lib/actions/generate-client-secret.ts
index 07392b2a60..bbb77347c9 100644
--- a/apps/web/lib/actions/generate-client-secret.ts
+++ b/apps/web/lib/actions/generate-client-secret.ts
@@ -37,6 +37,7 @@ export const generateClientSecret = authActionClient
},
data: {
hashedClientSecret: await hashToken(clientSecret),
+ partialClientSecret: `${clientSecret.slice(0, 3)}...${clientSecret.slice(-4)}`,
},
});
diff --git a/apps/web/lib/zod/schemas/oauth.ts b/apps/web/lib/zod/schemas/oauth.ts
index e6a35582d1..7f2b3f6de9 100644
--- a/apps/web/lib/zod/schemas/oauth.ts
+++ b/apps/web/lib/zod/schemas/oauth.ts
@@ -60,6 +60,7 @@ export const oAuthAppSchema = z.object({
id: z.string(),
clientId: z.string(),
clientSecret: z.string().optional(),
+ partialClientSecret: z.string().optional(),
name: z.string(),
slug: z.string(),
description: z.string().nullish(),
diff --git a/apps/web/prisma/schema/oauth.prisma b/apps/web/prisma/schema/oauth.prisma
index bc6fc20bfd..303c9d7ea2 100644
--- a/apps/web/prisma/schema/oauth.prisma
+++ b/apps/web/prisma/schema/oauth.prisma
@@ -1,21 +1,22 @@
model OAuthApp {
- id String @id @default(cuid())
- clientId String @unique
- name String
- slug String @unique
- description String?
- readme String? @db.LongText
- developer String
- website String
- hashedClientSecret String
- redirectUris Json
- logo String?
- pkce Boolean @default(false)
- verified Boolean @default(false)
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- userId String?
- projectId String
+ id String @id @default(cuid())
+ clientId String @unique
+ name String
+ slug String @unique
+ description String?
+ readme String? @db.LongText
+ developer String
+ website String
+ hashedClientSecret String
+ partialClientSecret String?
+ redirectUris Json
+ logo String?
+ pkce Boolean @default(false)
+ verified Boolean @default(false)
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ userId String?
+ projectId String
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
diff --git a/apps/web/ui/integrations/oauth-app-credentials.tsx b/apps/web/ui/integrations/oauth-app-credentials.tsx
index 0aa6a12470..dc2c7d0f9a 100644
--- a/apps/web/ui/integrations/oauth-app-credentials.tsx
+++ b/apps/web/ui/integrations/oauth-app-credentials.tsx
@@ -5,16 +5,18 @@ import { CopyButton } from "@dub/ui";
export default function OAuthAppCredentials({
clientId,
clientSecret,
+ partialClientSecret,
}: {
clientId: string | null;
clientSecret: string | null;
+ partialClientSecret: string | null;
}) {
if (!clientId) {
return null;
}
return (
- <div className="flex flex-col space-y-4 bg-gray-50 text-left">
+ <div className="flex flex-col space-y-3 bg-gray-50 text-left">
<div className="space-y-2">
<label className="text-sm font-medium text-gray-500">Client ID</label>
<div className="flex items-center justify-between rounded-md border border-gray-300 bg-white p-3">
@@ -44,6 +46,19 @@ export default function OAuthAppCredentials({
</span>
</div>
)}
+
+ {!clientSecret && partialClientSecret && (
+ <div className="space-y-2">
+ <label className="text-sm font-medium text-gray-500">
+ Client Secret
+ </label>
+ <div className="flex items-center justify-between rounded-md border border-gray-300 bg-white p-3">
+ <p className="text-nowrap font-mono text-sm text-gray-500">
+ {partialClientSecret}
+ </p>
+ </div>
+ </div>
+ )}
</div>
);
}