Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

docs: update AUTH_SECRET documentation and enhance API key management UI

Andrej Acevski44dc65126265
diff --git a/ENVIRONMENT_SETUP.md b/ENVIRONMENT_SETUP.md
index 6fceb852b..01913a706 100644
--- a/ENVIRONMENT_SETUP.md
+++ b/ENVIRONMENT_SETUP.md
@@ -25,7 +25,7 @@ For development, you'll need at minimum:
- `KANEO_CLIENT_URL` - The URL of the web application (e.g., `http://localhost:5173`)
- `KANEO_API_URL` - The URL of the API (e.g., `http://localhost:1337`)
-- `AUTH_SECRET` - Secret key for JWT token generation
+- `AUTH_SECRET` - Secret key for JWT token generation (**must be at least 32 characters long**; use a long, random value in production)
- `DATABASE_URL` - PostgreSQL connection string
- `POSTGRES_DB` - PostgreSQL database name
- `POSTGRES_USER` - PostgreSQL username
diff --git a/apps/docs/content/docs/core/installation/environment-variables.mdx b/apps/docs/content/docs/core/installation/environment-variables.mdx
index 4d87b9b60..6ce929015 100644
--- a/apps/docs/content/docs/core/installation/environment-variables.mdx
+++ b/apps/docs/content/docs/core/installation/environment-variables.mdx
@@ -47,7 +47,7 @@ This section will cover all the variables related to the authentication.
Name | Description |
--- | --- |
-| `AUTH_SECRET` | The secret key for the JWT token.
+| `AUTH_SECRET` | The secret key for the JWT token. **Must be at least 32 characters long** – use a long, random value in production.
## Optional variables
diff --git a/apps/web/src/components/settings/api-key-created-modal.tsx b/apps/web/src/components/settings/api-key-created-modal.tsx
index 2c3e2934c..49d28d40c 100644
--- a/apps/web/src/components/settings/api-key-created-modal.tsx
+++ b/apps/web/src/components/settings/api-key-created-modal.tsx
@@ -1,7 +1,7 @@
-import { AlertTriangle, Check, Copy } from "lucide-react";
+import { Check, Copy } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
-import { Alert, AlertDescription } from "../ui/alert";
+import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
import { Button } from "../ui/button";
import {
Dialog,
@@ -46,13 +46,6 @@ export function ApiKeyCreatedModal({
</DialogHeader>
<div className="space-y-4 px-6 py-4">
- <Alert variant="destructive">
- <AlertTriangle className="h-4 w-4" />
- <AlertDescription>
- Copy this key now. You won't be able to see it again.
- </AlertDescription>
- </Alert>
-
<div className="space-y-2">
<div className="flex items-center justify-between">
<p className="text-xs font-medium">Your API Key</p>
@@ -81,6 +74,13 @@ export function ApiKeyCreatedModal({
</code>
</div>
</div>
+
+ <Alert>
+ <AlertTitle>Success! Your API key has been created</AlertTitle>
+ <AlertDescription>
+ Copy this key now. You won't be able to see it again.
+ </AlertDescription>
+ </Alert>
</div>
<DialogFooter className="gap-2 sm:gap-2">
diff --git a/apps/web/src/components/settings/api-key-table.tsx b/apps/web/src/components/settings/api-key-table.tsx
index acbbca56f..acdcd6617 100644
--- a/apps/web/src/components/settings/api-key-table.tsx
+++ b/apps/web/src/components/settings/api-key-table.tsx
@@ -1,4 +1,4 @@
-import { Copy, Trash2 } from "lucide-react";
+import { Trash2 } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
import useDeleteApiKey from "@/hooks/mutations/api-key/use-delete-api-key";
@@ -22,11 +22,6 @@ export function ApiKeyTable({ apiKeys, isLoading }: ApiKeyTableProps) {
const { mutateAsync: deleteApiKey } = useDeleteApiKey();
const [deletingId, setDeletingId] = useState<string | null>(null);
- const handleCopy = (text: string) => {
- navigator.clipboard.writeText(text);
- toast.success("Copied to clipboard");
- };
-
const handleDelete = async (id: string, name: string | null) => {
const keyName = name || "this API key";
if (!confirm(`Are you sure you want to delete "${keyName}"?`)) {
@@ -74,6 +69,7 @@ export function ApiKeyTable({ apiKeys, isLoading }: ApiKeyTableProps) {
<TableHead>Name</TableHead>
<TableHead>Key</TableHead>
<TableHead>Created</TableHead>
+ <TableHead>Expires</TableHead>
<TableHead className="w-[100px]">Actions</TableHead>
</TableRow>
</TableHeader>
@@ -86,23 +82,18 @@ export function ApiKeyTable({ apiKeys, isLoading }: ApiKeyTableProps) {
<TableCell>
<div className="flex items-center gap-2">
<code className="text-xs bg-background px-2 py-1 rounded border border-border">
- {apiKey.prefix}_{apiKey.start}...
+ {apiKey.start}...
</code>
- <Button
- variant="ghost"
- size="icon"
- className="h-6 w-6"
- onClick={() =>
- handleCopy(`${apiKey.prefix}_${apiKey.start}...`)
- }
- >
- <Copy className="h-3 w-3" />
- </Button>
</div>
</TableCell>
<TableCell className="text-muted-foreground">
{new Date(apiKey.createdAt).toLocaleDateString()}
</TableCell>
+ <TableCell className="text-muted-foreground">
+ {apiKey.expiresAt
+ ? new Date(apiKey.expiresAt).toLocaleDateString()
+ : "Never"}
+ </TableCell>
<TableCell>
<Button
variant="ghost"
diff --git a/apps/web/src/components/settings/create-api-key-dialog.tsx b/apps/web/src/components/settings/create-api-key-dialog.tsx
index cd06d1972..da699d808 100644
--- a/apps/web/src/components/settings/create-api-key-dialog.tsx
+++ b/apps/web/src/components/settings/create-api-key-dialog.tsx
@@ -24,12 +24,43 @@ import {
FormMessage,
} from "../ui/form";
import { Input } from "../ui/input";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "../ui/select";
+
+const EXPIRATION_OPTIONS = [
+ {
+ label: "1 day",
+ value: "86400",
+ },
+ {
+ label: "7 days",
+ value: "604800",
+ },
+ {
+ label: "30 days",
+ value: "2592000",
+ },
+ {
+ label: "90 days",
+ value: "7776000",
+ },
+ {
+ label: "Never",
+ value: "never",
+ },
+];
const createApiKeySchema = z.object({
name: z
.string()
.min(1, "Name is required")
.min(3, "Name must be at least 3 characters"),
+ expiresIn: z.string().min(1, "Expiration is required"),
});
type FormValues = z.infer<typeof createApiKeySchema>;
@@ -52,14 +83,19 @@ export function CreateApiKeyDialog({
resolver: standardSchemaResolver(createApiKeySchema),
defaultValues: {
name: "",
+ expiresIn: "2592000",
},
});
const onSubmit = async (data: FormValues) => {
+ const expiresInValue =
+ data.expiresIn === "never" ? null : Number.parseInt(data.expiresIn, 10);
+
setIsSubmitting(true);
try {
const result = await createApiKey({
name: data.name,
+ expiresIn: Number.isNaN(expiresInValue) ? null : expiresInValue,
});
form.reset();
@@ -118,6 +154,39 @@ export function CreateApiKeyDialog({
)}
/>
+ <FormField
+ control={form.control}
+ name="expiresIn"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel className="text-xs">Expiration</FormLabel>
+ <FormControl>
+ <Select
+ onValueChange={field.onChange}
+ value={field.value}
+ disabled={isSubmitting}
+ >
+ <SelectTrigger className="h-8 text-xs">
+ <SelectValue placeholder="Select expiration" />
+ </SelectTrigger>
+ <SelectContent>
+ {EXPIRATION_OPTIONS.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </FormControl>
+ <FormDescription className="text-xs">
+ Choose how long this API key should remain valid. Never will
+ create a key without an automatic expiry.
+ </FormDescription>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
<DialogFooter className="gap-2 sm:gap-2">
<Button
type="button"
diff --git a/apps/web/src/types/api-key.ts b/apps/web/src/types/api-key.ts
index a26b53e34..96f9cbfaa 100644
--- a/apps/web/src/types/api-key.ts
+++ b/apps/web/src/types/api-key.ts
@@ -23,7 +23,7 @@ export type ApiKey = {
export type CreateApiKeyRequest = {
name?: string;
- expiresIn?: number;
+ expiresIn?: number | null;
prefix?: string;
metadata?: Record<string, unknown>;
};