updates for active directory now with docs
tests / ci (push) Canceled after 0s

This commit is contained in:
Mark Gregory
2026-11-11 17:35:18 +00:00
parent 0ca05c06e3
commit c0d6b821cb
@@ -1,96 +1,141 @@
<x-layouts::app title="Directory sync"> <x-layouts::app title="Directory sync">
<div class="mx-auto flex w-full max-w-5xl flex-col gap-8"> <div class="mx-auto flex w-full max-w-6xl min-w-0 flex-col gap-6">
<header class="space-y-2"> <header class="flex flex-wrap items-start justify-between gap-4">
<flux:heading size="xl">Directory sync</flux:heading> <div>
<flux:text> <h1 class="text-2xl font-semibold tracking-tight text-indigo-950 sm:text-3xl dark:text-indigo-100">Directory sync</h1>
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">Active Directory accounts and sync activity</p>
</div>
@if (! $scheduled) @if (! $scheduled)
Schedule disabled <flux:badge color="zinc" size="sm">Schedule disabled</flux:badge>
@elseif ($stale) @elseif ($stale)
Stale · No successful sync in the last 30 minutes <flux:badge color="amber" size="sm">Stale</flux:badge>
@else @else
Scheduled every 10 minutes <flux:badge color="green" size="sm">Scheduled every 10 minutes</flux:badge>
@endif @endif
</flux:text>
</header> </header>
@if (session('sync_error')) @if (session('sync_error'))
<p role="alert" class="rounded-lg border p-3">{{ session('sync_error') }}</p> <p role="alert" class="rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200">{{ session('sync_error') }}</p>
@endif @endif
@if (session('sync_status')) @if (session('sync_status'))
<p role="status" class="rounded-lg border p-3">{{ session('sync_status') }}</p> <p role="status" class="rounded-lg border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800 dark:border-green-900 dark:bg-green-950 dark:text-green-200">{{ session('sync_status') }}</p>
@endif @endif
<section class="space-y-3 rounded-xl border border-zinc-200 p-5 dark:border-zinc-700"> <section class="overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900" aria-labelledby="sync-summary">
<flux:heading size="lg">Latest successful sync</flux:heading> <div class="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 bg-indigo-50 px-5 py-4 sm:px-6 dark:bg-indigo-950">
<flux:text>{{ $success?->finished_at ?? 'No successful sync recorded yet' }}</flux:text> <h2 id="sync-summary" class="text-base font-semibold">Latest successful sync</h2>
<p class="text-sm tabular-nums text-zinc-500 dark:text-zinc-400">
{{ $success?->finished_at ?? 'No successful sync recorded yet' }}
</p>
</div>
@if ($success) @if ($success)
<dl class="grid grid-cols-2 gap-4 sm:grid-cols-5"> <dl class="grid grid-cols-2 gap-px border-t border-zinc-200 bg-zinc-200 sm:grid-cols-5 dark:border-zinc-700 dark:bg-zinc-700">
@foreach (['created' => 'Created', 'updated' => 'Updated', 'unchanged' => 'Unchanged', 'deactivated' => 'Disabled', 'reactivated' => 'Re-enabled'] as $key => $label) @foreach ([
<div> 'created' => ['Created', 'border-t-emerald-500 text-emerald-700 dark:text-emerald-300'],
<dt class="text-sm text-zinc-500 dark:text-zinc-400">{{ $label }}</dt> 'updated' => ['Updated', 'border-t-sky-500 text-sky-700 dark:text-sky-300'],
<dd class="text-2xl font-semibold">{{ $counts[$key] }}</dd> 'unchanged' => ['Unchanged', 'border-t-zinc-400 text-zinc-700 dark:text-zinc-300'],
'deactivated' => ['Disabled', 'border-t-amber-500 text-amber-800 dark:text-amber-300'],
'reactivated' => ['Re-enabled', 'border-t-violet-500 text-violet-700 dark:text-violet-300'],
] as $key => [$label, $accent])
<div class="border-t-2 bg-zinc-50 px-5 py-4 sm:px-6 dark:bg-zinc-900 {{ $accent }}">
<dt class="text-sm font-medium">{{ $label }}</dt>
<dd class="mt-1 text-2xl font-semibold tabular-nums">{{ $counts[$key] }}</dd>
</div> </div>
@endforeach @endforeach
</dl> </dl>
@endif @endif
@if ($failure || ($scheduled && $stale))
<div class="space-y-2 border-t border-zinc-200 px-5 py-3 text-sm sm:px-6 dark:border-zinc-700">
@if ($scheduled && $stale)
<p class="text-amber-700 dark:text-amber-300">No successful sync in the last 30 minutes.</p>
@endif
@if ($failure) @if ($failure)
<div class="border-t border-zinc-200 pt-3 dark:border-zinc-700"> <p><strong class="text-red-700 dark:text-red-300">Latest failure</strong> <span class="text-zinc-600 dark:text-zinc-400">· {{ $failure->finished_at }} · {{ $failure->failure }}</span></p>
<flux:heading>Latest failure</flux:heading> @endif
<flux:text>{{ $failure->finished_at }} · {{ $failure->failure }}</flux:text>
</div> </div>
@endif @endif
</section> </section>
<section class="space-y-3 rounded-xl border border-zinc-200 p-5 dark:border-zinc-700"> <section class="overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900" aria-labelledby="missing-users">
<flux:heading size="lg">Review missing users</flux:heading> <div class="flex flex-wrap items-center justify-between gap-4 px-5 py-4 sm:px-6">
<flux:text>Check which active Laravel accounts are missing from the directory. The preview expires after 10 minutes.</flux:text> <div class="space-y-1">
<h2 id="missing-users" class="text-base font-semibold">Review missing users</h2>
<p class="text-sm text-zinc-500 dark:text-zinc-400">Check which active directory accounts are missing. Previews expire after 10 minutes.</p>
</div>
<form method="POST" action="{{ route('admin.directory-sync.preview') }}"> <form method="POST" action="{{ route('admin.directory-sync.preview') }}">
@csrf @csrf
<flux:button type="submit">Preview missing users</flux:button> <flux:button type="submit" size="sm">Preview missing users</flux:button>
</form> </form>
</div>
@if ($review) @if ($review)
<div class="space-y-4 border-t border-zinc-200 bg-zinc-50 px-5 py-4 sm:px-6 dark:border-zinc-700 dark:bg-zinc-800">
@if ($review['users']) @if ($review['users'])
<ul class="space-y-1"> <ul class="divide-y divide-zinc-200 dark:divide-zinc-700">
@foreach ($review['users'] as $user) @foreach ($review['users'] as $user)
<li>{{ $user['name'] }} · {{ $user['email'] }}</li> <li class="flex flex-wrap items-baseline gap-x-3 py-2 text-sm">
<span class="font-medium">{{ $user['name'] }}</span>
<span class="break-all text-zinc-500 dark:text-zinc-400">{{ $user['email'] }}</span>
</li>
@endforeach @endforeach
</ul> </ul>
<form method="POST" action="{{ route('admin.directory-sync.apply') }}"> <form method="POST" action="{{ route('admin.directory-sync.apply') }}">
@csrf @csrf
<input type="hidden" name="review_token" value="{{ $review['token'] }}"> <input type="hidden" name="review_token" value="{{ $review['token'] }}">
<flux:button type="submit" variant="danger">Deactivate reviewed users</flux:button> <flux:button type="submit" variant="danger" size="sm">Deactivate reviewed users</flux:button>
</form> </form>
@else @else
<flux:text>No missing users found.</flux:text> <p class="text-sm text-zinc-600 dark:text-zinc-400">No missing users found.</p>
@endif @endif
</div>
@endif @endif
</section> </section>
<section class="space-y-3 rounded-xl border border-zinc-200 p-5 dark:border-zinc-700"> <section class="overflow-hidden rounded-xl border border-zinc-200 bg-white dark:border-zinc-700 dark:bg-zinc-900" aria-labelledby="disabled-users">
<flux:heading size="lg">Disabled directory users</flux:heading> <div class="flex items-center justify-between gap-3 px-5 py-4 sm:px-6">
<h2 id="disabled-users" class="text-base font-semibold">Disabled directory users</h2>
<flux:badge :color="$disabledUsers->total() ? 'amber' : 'zinc'" size="sm">{{ $disabledUsers->total() }}</flux:badge>
</div>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="w-full text-left text-sm"> <table class="w-full text-left text-sm" aria-labelledby="disabled-users">
<thead> <thead class="border-y border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300">
<tr><th scope="col" class="py-2 pe-4">User</th><th scope="col" class="py-2 pe-4">Reason</th><th scope="col" class="py-2">Disabled at</th></tr> <tr>
<th scope="col" class="px-5 py-3 font-medium sm:px-6">User</th>
<th scope="col" class="px-5 py-3 font-medium sm:px-6">Reason</th>
<th scope="col" class="whitespace-nowrap px-5 py-3 font-medium sm:px-6">Disabled at</th>
</tr>
</thead> </thead>
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700"> <tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
@forelse ($disabledUsers as $user) @forelse ($disabledUsers as $user)
<tr> <tr>
<td class="py-2 pe-4">{{ $user->name }}<br><span class="text-zinc-500 dark:text-zinc-400">{{ $user->email }}</span></td> <td class="px-5 py-3 sm:px-6">
<td class="py-2 pe-4">{{ match ($user->ad_disabled_reason) { <div class="font-medium">{{ $user->name }}</div>
'directory_disabled' => 'Disabled in Active Directory', <div class="break-all text-zinc-500 dark:text-zinc-400">{{ $user->email }}</div>
'missing_from_snapshot' => 'Missing from the directory', </td>
default => 'Reason unavailable', <td class="px-5 py-3 text-zinc-600 sm:px-6 dark:text-zinc-300">
} }}</td> @switch($user->ad_disabled_reason)
<td class="py-2">{{ $user->ad_disabled_at }}</td> @case('directory_disabled')
<flux:badge color="amber" size="sm">Disabled in Active Directory</flux:badge>
@break
@case('missing_from_snapshot')
<flux:badge color="violet" size="sm">Missing from the directory</flux:badge>
@break
@default
<flux:badge color="zinc" size="sm">Reason unavailable</flux:badge>
@endswitch
</td>
<td class="whitespace-nowrap px-5 py-3 tabular-nums text-zinc-600 sm:px-6 dark:text-zinc-300">{{ $user->ad_disabled_at }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="3" class="py-2">No disabled directory users.</td></tr> <tr><td colspan="3" class="px-5 py-6 text-center text-zinc-500 dark:text-zinc-400">No disabled directory users.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
</div> </div>
@if ($disabledUsers->hasPages())
<div class="border-t border-zinc-200 px-5 py-4 sm:px-6 dark:border-zinc-700">
{{ $disabledUsers->links() }} {{ $disabledUsers->links() }}
</div>
@endif
</section> </section>
</div> </div>
</x-layouts::app> </x-layouts::app>