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
3 changes: 3 additions & 0 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ jobs:
git -C "$src" fetch --quiet --depth 1 https://github.com/parseablehq/quest.git "$QUEST_SOURCE_REF"
git -C "$src" checkout --quiet FETCH_HEAD
test "$(git -C "$src" rev-parse HEAD)" = "$QUEST_SOURCE_REF"
# This server returns an API key masked where upstream returns the
# key; see the patch for why. Drop it if Quest stops expecting the key.
git -C "$src" apply "$GITHUB_WORKSPACE/scripts/ci/quest-api-key-hash.patch"
docker build --tag "$QUEST_IMAGE" "$src"
- name: Run Quest
run: docker compose up --no-build --exit-code-from quest
Expand Down
6 changes: 6 additions & 0 deletions docker-compose-quest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# Find pin references: grep -rnE 'issue #151|f4a026e' .
# Remove the pin in quest-source here and QUEST_SOURCE_REF in
# .github/workflows/integration-test.yaml; the five extends callers can stay.
#
# Quest built straight from this commit fails TestSmokeAPIKeyLifecycle/GetAPIKey:
# it expects GET /api/prism/v1/apikeys/{id} to return the key, and this server
# returns it masked. CI applies scripts/ci/quest-api-key-hash.patch before
# building; for a local run, build an image from a patched checkout and pass it
# as QUEST_IMAGE.
services:
quest-source:
build:
Expand Down
5 changes: 3 additions & 2 deletions frontend/docs/api-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ Team requests share the cookie session and `credentials: 'include'`. The adminis
| `setDefaultRole(name)` | `PUT /api/v1/role/default` | JSON string body; empty success |
| `clearDefaultRole()` | `DELETE /api/v1/role/default` | Empty success |
| `listApiKeys(signal?)` | `GET /api/prism/v1/apikeys` | Array of `{keyId, apiKey, keyName, roles, createdBy, createdAt, modifiedAt, expiresAt}`; `apiKey` is masked as `****` plus the last four characters |
| `createApiKey(name, roles, ttlSeconds?)` | `POST /api/prism/v1/apikeys` | Body `{keyName, roles, ttlSeconds?}`; returns the same shape with the full generated key |
| `getApiKey(id, signal?)` | `GET /api/prism/v1/apikeys/{encoded id}` | Full key, retrieved only on an explicit copy action |
| `createApiKey(name, roles, ttlSeconds?)` | `POST /api/prism/v1/apikeys` | Body `{keyName, roles, ttlSeconds?}`; returns the same shape with the full generated key, the only time it is returned |
| `deleteApiKey(id)` | `DELETE /api/prism/v1/apikeys/{encoded id}` | Checked success; backend returns `{keyId, keyName, message}` |

The server keeps only a hash of each API key, so a key cannot be read back after the response that creates it. `GET /api/prism/v1/apikeys/{id}` returns the same masked `apiKey` as the list, and the client does not call it.

API key listing accepts `?privilege=reader|ingestor|admin|writer|editor|superadmin` (alias `priviledge`), matching direct or group-inherited role privileges by kind (an admin key does not match `reader`, and a super-admin key does not match `admin`). Each entry's `roles` lists direct roles only. Unknown or differently cased values, or a repeated parameter, return 400; unknown parameter names are ignored and leave the list unfiltered.

API key expiry is optional: `ttlSeconds` must be an integer from 1800 (30 minutes) through 7776000 (90 days), inclusive; invalid values return 400. Omitted or null TTL means no expiration. Responses include `expiresAt`, a UTC timestamp or null; the frontend also accepts an omitted field from older servers for legacy records. Finite lifetimes are elapsed durations from creation, independent of time zones or daylight saving changes. The creation form defaults to 90 days and offers presets, custom minutes/hours/days, and No expiration. TTL cannot be edited after creation. Expired keys remain listed and deletable; their names remain reserved until deletion.
Expand Down
2 changes: 1 addition & 1 deletion frontend/docs/prism-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Original authenticated shell geometry was relayed to the implementation owners i

## Final implemented scope and remaining visual differences

Team administration is implemented at `/team` with Prism-compatible `roles`, `user`, `groups` and `apikeys` query tabs. Admin navigation replaces the classic-only Users and Roles links. Native users, one-time passwords, role creation and full-array privilege edits, typed deletion, OIDC defaults, group mappings and safe role inspection, and API-key creation/copy/deletion use this checkout's backend contracts. Each tab has search and 25-row pagination; users support name/email/method sorting. The community OIDC explanations and status sentences are preserved, including provider-only removal protection, legacy provenance, manual overlaps and sign-in/session refresh wording.
Team administration is implemented at `/team` with Prism-compatible `roles`, `user`, `groups` and `apikeys` query tabs. Admin navigation replaces the classic-only Users and Roles links. Native users, one-time passwords, role creation and full-array privilege edits, typed deletion, OIDC defaults, group mappings and safe role inspection, and API-key creation (the key is shown once, with a copy action)/deletion use this checkout's backend contracts. Each tab has search and 25-row pagination; users support name/email/method sorting. The community OIDC explanations and status sentences are preserved, including provider-only removal protection, legacy provenance, manual overlaps and sign-in/session refresh wording.

Alerts is native under Observe, after Metrics; the Classic UI sidebar group is removed. `/alerts`, `/alerts/new`, `/alerts/:id`, `/alerts/:id/edit` and `/alerts/targets` cover list/search/tags/sort/pagination, PromQL and SQL thresholds, non-notifying previews, runtime instances/delivery failures, hold duration, optional targets, evaluate/enable/mute/duplicate/delete and target management. Fork behavior survives: explicit `promqlAlerts` capability, independent per-series state, transition-based notifications, three delivery attempts, state-only rules and dashboard handoff URL fields. Frequency uses the server's minute units rather than classic's inconsistent day options.

Expand Down
7 changes: 2 additions & 5 deletions frontend/e2e/api-key-expiration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,13 @@ test('expiration updates at the deadline, disables copying and preserves deletio
]);
const soon = row(page, 'soon');
await expect(soon.getByText('Expired', { exact: true })).toHaveCount(0);
await expect(soon.getByRole('button', { name: 'Copy API key for soon' })).toBeEnabled();
await page.clock.fastForward(30_000);
await expect(soon.getByText('Expired', { exact: true })).toBeVisible();
await expect(soon.getByRole('button', { name: 'Copy API key for soon' })).toBeDisabled();
for (const name of ['legacy', 'forever']) {
await expect(row(page, name)).toContainText('No expiration');
await expect(
row(page, name).getByRole('button', { name: `Copy API key for ${name}` }),
).toBeEnabled();
}
// The key is shown once, when it is created: no row offers to copy it
await expect(page.getByRole('button', { name: /^Copy API key/ })).toHaveCount(0);
await soon.getByRole('button', { name: 'Delete API key soon' }).click();
const dialog = page.getByRole('dialog', { name: 'Delete API key', exact: true });
await dialog.getByLabel('Confirmation name').fill('soon');
Expand Down
11 changes: 6 additions & 5 deletions frontend/e2e/team.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ test('OIDC groups map exact role names and have a search empty state', async ({
await expect(page.getByRole('button', { name: /Add (group|role)/ })).toHaveCount(0);
});

test('API keys are created once, copied through GET, masked in the table and deleted by name', async ({
test('API keys are shown once at creation, masked in the table and deleted by name', async ({
page,
context,
}) => {
Expand All @@ -401,7 +401,9 @@ test('API keys are created once, copied through GET, masked in the table and del
const key = await sheet.getByLabel('API key', { exact: true }).inputValue();
expect(key).toBeTruthy();
await expect(
sheet.getByText('Store this key securely. Admins can copy it again from the API keys list.'),
sheet.getByText(
'This is the only time you can see this key. Store it securely; if it is lost, delete it and create another.',
),
).toBeVisible();
await sheet.getByRole('button', { name: 'Copy API key', exact: true }).click();
await expect(sheet.getByRole('status')).toHaveText('API key copied to clipboard');
Expand All @@ -413,9 +415,8 @@ test('API keys are created once, copied through GET, masked in the table and del
const row = namedRow(page, 'automation-key');
await expect(row).toContainText(`****${key.slice(-4)}`);
await expect(page.getByText(key, { exact: true })).toHaveCount(0);
await row.getByRole('button', { name: 'Copy API key for automation-key' }).click();
await expect(row.getByRole('status')).toHaveText('API key copied to clipboard');
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(key);
// The key cannot be read back: the list has no copy action
await expect(row.getByRole('button', { name: /^Copy API key/ })).toHaveCount(0);
await row.getByRole('button', { name: 'Delete API key automation-key' }).click();
const remove = page.getByRole('dialog', { name: 'Delete API key', exact: true });
await expect(remove.locator('[data-dialog-confirm]')).toBeDisabled();
Expand Down
93 changes: 0 additions & 93 deletions frontend/src/features/team/ApiKeysTab.test.ts

This file was deleted.

65 changes: 1 addition & 64 deletions frontend/src/features/team/ApiKeysTab.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { Copy } from 'lucide-react';
import { useCallback, useEffect, useState } from 'react';
import {
Badge,
Button,
Card,
EmptyState,
Pagination,
TypedConfirmDialog,
InlineError,
} from '../../components/ui';
import { QueryState } from '../../components/explorer/QueryState';
import { useApp } from '../../app/AppProvider';
Expand All @@ -18,63 +16,6 @@ import { useCollection } from '../../hooks/useCollection';
import { useMutation } from '../../hooks/useMutation';
import { isApiKeyExpired } from './apiKeyExpiration';

export async function copyApiKey(key: Promise<ApiKey>, active: { current: boolean }) {
try {
if (typeof ClipboardItem !== 'undefined') {
await navigator.clipboard.write([
new ClipboardItem({
'text/plain': key.then((result) => new Blob([result.apiKey], { type: 'text/plain' })),
}),
]);
} else {
const result = await key;
if (!active.current) return;
await navigator.clipboard.writeText(result.apiKey);
}
} catch {
// Preserve fetch errors before translating a clipboard failure.
await key;
throw new Error(
'Unable to copy API key. Check your browser clipboard permissions and try again.',
);
}
}

function CopyKey({ apiKey, expired }: { apiKey: ApiKey; expired: boolean }) {
const { client } = useApp();
const [status, setStatus] = useState('');
const mutation = useMutation();
const active = useRef(true);
useEffect(() => {
active.current = true;
return () => {
active.current = false;
};
}, []);
function copy() {
setStatus('');
void mutation.run(async () => {
await copyApiKey(client.getApiKey(apiKey.keyId), active);
if (active.current) setStatus('API key copied to clipboard');
});
}
return (
<div className="team-copy">
<Button
variant="ghost"
size="sm"
aria-label={`Copy API key for ${apiKey.keyName}`}
onClick={copy}
disabled={mutation.pending || expired}
>
<Copy size={14} aria-hidden="true" /> Copy API key
</Button>
<InlineError error={mutation.error} />
<span role="status">{status}</span>
</div>
);
}

function DeleteKey({
apiKey,
onClose,
Expand Down Expand Up @@ -203,10 +144,6 @@ export function ApiKeysTab({
</td>
<td>
<div className="team-actions">
<CopyKey
apiKey={key}
expired={isApiKeyExpired(key.expiresAt, Math.max(now, Date.now()))}
/>
<Button
variant="ghost"
size="sm"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/team/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function SecretResult({ value, kind }: { value: string; kind: 'password'
<p className="notice">
{kind === 'password'
? 'This is the only time you can see this password.'
: 'Store this key securely. Admins can copy it again from the API keys list.'}
: 'This is the only time you can see this key. Store it securely; if it is lost, delete it and create another.'}
</p>
<p role="status">{status}</p>
</div>
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/features/team/team.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@
color: var(--color-muted);
overflow-wrap: anywhere;
}
.team-copy {
display: flex;
flex-direction: column;
}
.team-copy [role='status'] {
font-size: 11px;
}
.team-empty {
padding: 20px;
color: var(--color-muted);
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,6 @@ export function createClient({
if (!apiKey(data)) return malformed(keys);
return data;
},
async getApiKey(id, signal) {
const endpoint = `${keys}/${encodeURIComponent(id)}`;
const data = await readJson(endpoint, { signal }, onUnauthorized);
if (!apiKey(data)) return malformed(endpoint);
return data;
},
deleteApiKey: (id) => mutate(`${keys}/${encodeURIComponent(id)}`, { method: 'DELETE' }),
createDataset: (name, options) => {
const headers: Record<string, string> = { 'X-P-Telemetry-Type': options.telemetryType };
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/lib/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,6 @@ export function createDemoClient(): ParseableClient {
keys.push(key);
return clone(key);
},
async getApiKey(id, signal) {
await ready(signal);
return clone(findKey(id));
},
async deleteApiKey(id) {
await ready();
const key = findKey(id);
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/lib/demoTeam.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ describe('per-client Team demo', () => {
const client = createDemoClient();
const key = await client.createApiKey('test-key', ['editors']);
expect(key.keyId).toMatch(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);
expect((await client.getApiKey(key.keyId)).apiKey).toBe(key.apiKey);
expect((await client.listApiKeys()).find((item) => item.keyId === key.keyId)?.apiKey).toBe(
`****${key.apiKey.slice(-4)}`,
);
Expand All @@ -198,7 +197,7 @@ describe('per-client Team demo', () => {
'Roles do not exist',
);
await client.deleteApiKey(key.keyId);
await expect(client.getApiKey(key.keyId)).rejects.toMatchObject({ status: 404 });
await expect(client.deleteApiKey(key.keyId)).rejects.toMatchObject({ status: 404 });
expect(await client.listApiKeys()).toHaveLength(2);
});
it.each([1800, 7776000])(
Expand All @@ -208,7 +207,6 @@ describe('per-client Team demo', () => {
const users = await client.listUsers();
const key = await client.createApiKey('finite-key', ['analysts'], ttlSeconds);
expect(Date.parse(key.expiresAt!) - Date.parse(key.createdAt)).toBe(ttlSeconds * 1000);
expect((await client.getApiKey(key.keyId)).expiresAt).toBe(key.expiresAt);
expect((await client.listApiKeys()).find((item) => item.keyId === key.keyId)?.expiresAt).toBe(
key.expiresAt,
);
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/lib/teamClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ const cases: Case[] = [
body: { keyName: 'ingestion', roles: ['analysts'], ttlSeconds: 7776000 },
reply: { ...key, expiresAt: '2027-01-06T12:00:00Z' },
},
{
name: 'get API key',
run: (c, s) => c.getApiKey('key/id', s),
url: '/api/prism/v1/apikeys/key%2Fid',
reply: { ...key, apiKey: 'full-test-key' },
},
{
name: 'delete API key',
run: (c) => c.deleteApiKey('key/id'),
Expand Down Expand Up @@ -347,7 +341,6 @@ describe('Team HTTP contracts', () => {
{ run: (c) => c.defaultRole(), reply: { role: 'analysts' } },
{ run: (c) => c.listApiKeys(), reply: [{ ...key, roles: 'analysts' }] },
{ run: (c) => c.createApiKey('key', []), reply: { ...key, createdAt: 'invalid' } },
{ run: (c) => c.getApiKey('key'), reply: { keyId: 'key' } },
...[42, 'invalid', '', '2026-10-08', '2026-10-08T12:00:00+02:00'].map((expiresAt) => ({
run: (c: ParseableClient) => c.listApiKeys(),
reply: [{ ...key, expiresAt }],
Expand Down
Loading
Loading