Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 1 addition & 10 deletions src/api/routers/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import { decryptCredential } from '../../db/crypto.js';
import {
createCredential,
deleteCredential,
listAllCredentials,
listOrgCredentials,
updateCredential,
} from '../../db/repositories/credentialsRepository.js';
import { credentials } from '../../db/schema/index.js';
import { protectedProcedure, router, superAdminProcedure } from '../trpc.js';
import { protectedProcedure, router } from '../trpc.js';

function maskValue(value: string): string {
if (value.length <= 4) return '****';
Expand All @@ -28,14 +27,6 @@ export const credentialsRouter = router({
}));
}),

listAll: superAdminProcedure.query(async () => {
const rows = await listAllCredentials();
return rows.map((row) => ({
...row,
value: maskValue(row.value),
}));
}),

create: protectedProcedure
.input(
z.object({
Expand Down
40 changes: 1 addition & 39 deletions src/db/repositories/credentialsRepository.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,7 @@
import { and, eq } from 'drizzle-orm';
import { getDb } from '../client.js';
import { decryptCredential, encryptCredential } from '../crypto.js';
import {
credentials,
integrationCredentials,
organizations,
projectIntegrations,
} from '../schema/index.js';

// ============================================================================
// Global credential management (superadmin only)
// ============================================================================

/**
* List all credentials across all organizations.
* Joins with organizations to include org name.
*/
export async function listAllCredentials(): Promise<
(typeof credentials.$inferSelect & { orgName: string })[]
> {
const db = getDb();
const rows = await db
.select({
id: credentials.id,
orgId: credentials.orgId,
orgName: organizations.name,
name: credentials.name,
envVarKey: credentials.envVarKey,
value: credentials.value,
isDefault: credentials.isDefault,
createdAt: credentials.createdAt,
updatedAt: credentials.updatedAt,
})
.from(credentials)
.innerJoin(organizations, eq(credentials.orgId, organizations.id));

return rows.map((row) => ({
...row,
value: decryptCredential(row.value, row.orgId),
}));
}
import { credentials, integrationCredentials, projectIntegrations } from '../schema/index.js';

// ============================================================================
// Integration credential resolution
Expand Down
1 change: 0 additions & 1 deletion web/src/components/layout/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const globalNav = [
{ to: '/global/defaults' as const, label: 'Cascade Defaults', icon: SlidersHorizontal },
{ to: '/global/definitions' as const, label: 'Agent Definitions', icon: BookOpen },
{ to: '/global/organizations' as const, label: 'Organizations', icon: Building },
{ to: '/global/credentials' as const, label: 'Global Credentials', icon: KeyRound },
];

const settingsNav = [
Expand Down
1 change: 0 additions & 1 deletion web/src/components/settings/credential-form-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function CredentialFormDialog({

const invalidate = () => {
queryClient.invalidateQueries({ queryKey: trpc.credentials.list.queryOptions().queryKey });
queryClient.invalidateQueries({ queryKey: trpc.credentials.listAll.queryOptions().queryKey });
};

const createMutation = useMutation({
Expand Down
26 changes: 2 additions & 24 deletions web/src/components/settings/credentials-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,13 @@ import { CredentialFormDialog } from './credential-form-dialog.js';
interface Credential {
id: number;
orgId: string;
orgName?: string;
name: string;
envVarKey: string;
value: string;
isDefault: boolean;
}

export function CredentialsTable({
credentials,
showOrg = false,
}: {
credentials: Credential[];
showOrg?: boolean;
}) {
export function CredentialsTable({ credentials }: { credentials: Credential[] }) {
const queryClient = useQueryClient();
const [deleteId, setDeleteId] = useState<number | null>(null);
const [editCredential, setEditCredential] = useState<Credential | null>(null);
Expand All @@ -48,7 +41,6 @@ export function CredentialsTable({
mutationFn: (id: number) => trpcClient.credentials.delete.mutate({ id }),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: trpc.credentials.list.queryOptions().queryKey });
queryClient.invalidateQueries({ queryKey: trpc.credentials.listAll.queryOptions().queryKey });
setDeleteId(null);
},
});
Expand All @@ -59,7 +51,6 @@ export function CredentialsTable({
<Table>
<TableHeader>
<TableRow>
{showOrg && <TableHead>Organization</TableHead>}
<TableHead>Name</TableHead>
<TableHead>Env Var Key</TableHead>
<TableHead className="hidden md:table-cell">Value</TableHead>
Expand All @@ -70,26 +61,13 @@ export function CredentialsTable({
<TableBody>
{credentials.length === 0 && (
<TableRow>
<TableCell
colSpan={showOrg ? 6 : 5}
className="text-center text-muted-foreground py-8"
>
<TableCell colSpan={5} className="text-center text-muted-foreground py-8">
No credentials yet
</TableCell>
</TableRow>
)}
{credentials.map((cred) => (
<TableRow key={cred.id}>
{showOrg && (
<TableCell>
<div className="flex flex-col">
<span className="font-medium">{cred.orgName}</span>
<span className="text-[10px] text-muted-foreground font-mono">
{cred.orgId}
</span>
</div>
</TableCell>
)}
<TableCell className="font-medium">{cred.name}</TableCell>
<TableCell className="font-mono text-xs">{cred.envVarKey}</TableCell>
<TableCell className="hidden md:table-cell font-mono text-xs text-muted-foreground">
Expand Down
42 changes: 0 additions & 42 deletions web/src/routes/global/credentials.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions web/src/routes/route-tree.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { rootRoute } from './__root.js';
import { globalAgentConfigsRoute } from './global/agent-configs.js';
import { globalCredentialsRoute } from './global/credentials.js';
import { globalDefaultsRoute } from './global/defaults.js';
import { globalDefinitionsRoute } from './global/definitions.js';
import { globalOrganizationsRoute } from './global/organizations.js';
Expand Down Expand Up @@ -31,7 +30,6 @@ export const routeTree = rootRoute.addChildren([
globalDefinitionsRoute,
globalWebhookLogsRoute,
globalOrganizationsRoute,
globalCredentialsRoute,
globalRunsRoute,
workItemRunsRoute,
prRunsRoute,
Expand Down
Loading