From 0e981a461774bdb74908958b89fc578095371020 Mon Sep 17 00:00:00 2001 From: alphaeusmote <41258468-alphaeusmote@users.noreply.replit.com> Date: Fri, 11 Apr 2025 16:19:26 +0000 Subject: [PATCH] Add API token roles to enhance access control Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/262170ae-5240-4866-86d5-1e4164217124.jpg --- client/src/pages/api-tokens.tsx | 54 +++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/client/src/pages/api-tokens.tsx b/client/src/pages/api-tokens.tsx index 1d576d7..e2da0c6 100644 --- a/client/src/pages/api-tokens.tsx +++ b/client/src/pages/api-tokens.tsx @@ -61,6 +61,13 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Checkbox } from "@/components/ui/checkbox"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; import { Loader2, Key, MoreVertical, Calendar, Copy, Info } from "lucide-react"; import { formatDistanceToNow, format } from "date-fns"; @@ -105,8 +112,9 @@ export default function ApiTokensPage() { mutationFn: async (data: z.infer) => { const tokenData: Partial = { name: data.name, - organizationId: currentOrganization?.id || 0, + organizationId: currentOrganization?.id || "", permissions: data.permissions, + role: data.role, isActive: true, }; @@ -226,6 +234,7 @@ export default function ApiTokensPage() { Name Token + Role Permissions Expires Status @@ -239,9 +248,14 @@ export default function ApiTokensPage() { {token.token.substring(0, 8)}... + + + {token.role || "readonly"} + +
- {token.permissions.map((permission) => ( + {token.permissions?.map((permission) => ( {permission} @@ -328,6 +342,40 @@ export default function ApiTokensPage() { )} /> + ( + + Role + + + Determines the level of access for this token + + + + )} + /> + Permissions - Select the permissions for this token + Select specific permissions for this token
{systemRoles.map((role) => (