mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
feat: show the token owner in tooltips on the run page and audit logs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c5ed41fbb7
commit
84ce2b51af
@@ -1 +1 @@
|
||||
0ecfe50159aea7ca6ec0b91e4195910430baad50
|
||||
106411cb2b5d7cd2ff2c37fd96dbfceb5e9fec07
|
||||
|
||||
@@ -35424,6 +35424,9 @@ components:
|
||||
token_label:
|
||||
type: string
|
||||
description: Label of the token whose prefix is in span, while that token still exists
|
||||
token_owner:
|
||||
type: string
|
||||
description: Workspace username of that token's owner, while the token and the user still exist
|
||||
client_ip:
|
||||
type: string
|
||||
description: Address of the client that made the request. Forwarding headers are believed only from the proxies listed in the TRUSTED_PROXIES environment variable, or, when it is unset, from loopback and the private ranges, where a reverse proxy usually sits. Any host that reaches the server directly from a private address can then name any address here; peer_ip and forwarded_for tell such an entry apart. Absent on entries no request stands behind.
|
||||
|
||||
@@ -29,6 +29,8 @@ pub struct AuditLog {
|
||||
#[sqlx(default)]
|
||||
pub token_label: Option<String>,
|
||||
#[sqlx(default)]
|
||||
pub token_owner: Option<String>,
|
||||
#[sqlx(default)]
|
||||
pub client_ip: Option<String>,
|
||||
#[sqlx(default)]
|
||||
pub user_agent: Option<String>,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import { type AuditLog } from '$lib/gen'
|
||||
import { displayDate } from '$lib/utils'
|
||||
import { ExternalLink, X } from 'lucide-svelte'
|
||||
import { ExternalLink, ListFilterPlus, X } from 'lucide-svelte'
|
||||
import Tooltip from '$lib/components/meltComponents/Tooltip.svelte'
|
||||
import { Highlight } from 'svelte-highlight'
|
||||
import { json } from 'svelte-highlight/languages'
|
||||
import HighlightTheme from '$lib/components/HighlightTheme.svelte'
|
||||
@@ -63,21 +64,26 @@
|
||||
<span class="text-xs break-all">{log.span.slice(JOB_SPAN_PREFIX.length)}</span>
|
||||
{:else}
|
||||
{@const tokenText = `${log.span}****${log.token_label ? ` (${log.token_label})` : ''}`}
|
||||
{#if onFilterToken}
|
||||
<div class="flex">
|
||||
<div class="flex items-center gap-1">
|
||||
{#if log.token_owner}
|
||||
<Tooltip small>
|
||||
{#snippet text()}Owned by {log.token_owner}{/snippet}
|
||||
<span class="text-xs break-all">{tokenText}</span>
|
||||
</Tooltip>
|
||||
{:else}
|
||||
<span class="text-xs break-all">{tokenText}</span>
|
||||
{/if}
|
||||
{#if onFilterToken}
|
||||
<Button
|
||||
wrapperClasses="-ml-2"
|
||||
variant="subtle"
|
||||
unifiedSize="xs"
|
||||
unifiedSize="sm"
|
||||
iconOnly
|
||||
startIcon={{ icon: ListFilterPlus }}
|
||||
title="Show every entry made with this token"
|
||||
onClick={() => onFilterToken(log.span!)}
|
||||
>
|
||||
{tokenText}
|
||||
</Button>
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-xs break-all">{tokenText}</span>
|
||||
{/if}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import VirtualList from '@tutorlatin/svelte-tiny-virtual-list'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import BatchLoadProgress from '../BatchLoadProgress.svelte'
|
||||
import Tooltip from '../meltComponents/Tooltip.svelte'
|
||||
|
||||
interface Props {
|
||||
logs?: AuditLog[]
|
||||
@@ -244,12 +245,16 @@
|
||||
{#if tokenOf(logOrDate.log)}
|
||||
{@const token = tokenOf(logOrDate.log)!}
|
||||
<div class="flex flex-row gap-2 items-center min-w-0 pr-2">
|
||||
<span
|
||||
class="truncate"
|
||||
title={`${token}****${logOrDate.log.token_label ? ` (${logOrDate.log.token_label})` : ''}`}
|
||||
>
|
||||
<Tooltip small class="truncate min-w-0">
|
||||
{#snippet text()}
|
||||
{token}****{logOrDate.log.token_label
|
||||
? ` (${logOrDate.log.token_label})`
|
||||
: ''}{logOrDate.log.token_owner
|
||||
? `, owned by ${logOrDate.log.token_owner}`
|
||||
: ''}
|
||||
{/snippet}
|
||||
{token}****
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
|
||||
@@ -57,7 +57,6 @@ export interface FieldConfig {
|
||||
label: string
|
||||
getValue: (job: Job) => string | null
|
||||
getHref?: (job: Job, workspaceId: string) => string | null
|
||||
getTitle?: (job: Job) => string | null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +245,6 @@ export const fieldConfigs: Record<JobField, FieldConfig> = {
|
||||
const label = job.token_label === 'session' ? 'Session' : job.token_label
|
||||
return `${job.token_prefix}****${label ? ` (${label})` : ''}`
|
||||
},
|
||||
getTitle: (job) => (job.token_owner ? `Owned by ${job.token_owner}` : null),
|
||||
getHref: (job, workspaceId) =>
|
||||
job.token_prefix
|
||||
? `${AUDIT_LOGS_PATH}?token=${encodeURIComponent(job.token_prefix)}&workspace=${encodeURIComponent(job.workspace_id || workspaceId)}`
|
||||
|
||||
@@ -290,6 +290,19 @@
|
||||
</Tooltip>
|
||||
{/if}
|
||||
</span>
|
||||
{:else if config.field === 'token' && href && job.token_owner}
|
||||
<Tooltip small>
|
||||
{#snippet text()}Owned by {job.token_owner}{/snippet}
|
||||
<a
|
||||
{href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="flex items-center gap-1 min-w-0 text-primary"
|
||||
>
|
||||
<span class="truncate flex-shrink min-w-0">{displayValue}</span>
|
||||
<ExternalLink size={12} class="flex-shrink-0" />
|
||||
</a>
|
||||
</Tooltip>
|
||||
{:else if config.field === 'memory_peak'}
|
||||
{@const memoryParts = fullValue.split('|')}
|
||||
{@const displayMem = memoryParts[0] || fullValue}
|
||||
@@ -384,7 +397,7 @@
|
||||
? 'Flow version'
|
||||
: 'Script hash'
|
||||
}: ${fullValue}`
|
||||
: (config.getTitle?.(job) ?? fullValue)}
|
||||
: fullValue}
|
||||
>
|
||||
<span class="truncate flex-shrink min-w-0">{displayValue}</span>
|
||||
<ExternalLink size={12} class="flex-shrink-0" />
|
||||
|
||||
Reference in New Issue
Block a user