Initial commit: CABM-IT (ItGlue-style MSP documentation platform)

Laravel 13 + Livewire/Volt app for managing client organizations,
documents, passwords, flexible assets, virtual machines, contacts,
domains, todos, shortcuts, and role-based user administration.
This commit is contained in:
jeremy bayse
2026-08-16 13:28:12 +02:00
commit 8f22dca9c8
209 changed files with 23324 additions and 0 deletions
@@ -0,0 +1,168 @@
<?php
use App\Models\Organization;
use App\Models\Password;
use Livewire\Component;
new class extends Component
{
public Organization $organization;
public ?Password $password = null;
public string $name = '';
public string $username = '';
public string $password_ciphertext = '';
public string $url = '';
public string $notes = '';
public bool $is_favorite = false;
public function mount(Organization $organization, ?Password $password = null): void
{
$this->organization = $organization;
if ($password?->exists) {
$this->password = $password;
$this->name = $password->name;
$this->username = $password->username ?? '';
// password_ciphertext intentionally left blank: never pre-fill a decrypted secret into the form.
$this->url = $password->url ?? '';
$this->notes = $password->notes ?? '';
$this->is_favorite = $password->is_favorite;
$password->logAction('viewed');
}
}
public function save(): void
{
$validated = $this->validate([
'name' => 'required|string|max:255',
'username' => 'nullable|string|max:255',
'password_ciphertext' => $this->password?->exists ? 'nullable|string' : 'required|string',
'url' => 'nullable|url|max:255',
'notes' => 'nullable|string',
'is_favorite' => 'boolean',
]);
if (blank($validated['password_ciphertext'])) {
unset($validated['password_ciphertext']);
} else {
$validated['password_updated_at'] = now();
}
if ($this->password?->exists) {
$isRotation = isset($validated['password_ciphertext']);
$this->password->update($validated);
$this->password->logAction($isRotation ? 'rotated' : 'updated');
session()->flash('status', "Mot de passe « {$this->password->name} » mis à jour.");
} else {
$validated['created_by'] = auth()->id();
$validated['password_updated_at'] = now();
$created = $this->organization->passwords()->create($validated);
$created->logAction('created');
session()->flash('status', "Mot de passe « {$this->name} » créé.");
}
$this->redirectRoute('organizations.passwords.index', $this->organization, navigate: true);
}
};
?>
<div class="max-w-2xl">
<p class="text-sm text-slate-500">{{ $organization->name }}</p>
<h1 class="mb-6 text-2xl font-semibold text-slate-900">
{{ $password?->exists ? 'Modifier le mot de passe' : 'Nouveau mot de passe' }}
</h1>
<form wire:submit="save" class="space-y-4 rounded border border-slate-200 bg-white p-6">
<div>
<label class="block text-sm font-medium text-slate-700">Nom</label>
<input type="text" wire:model="name"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@error('name') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700">Nom d'utilisateur</label>
<input type="text" wire:model="username"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
</div>
<div>
<label class="block text-sm font-medium text-slate-700">
Mot de passe
@if ($password?->exists) <span class="text-xs font-normal text-slate-400">(laisser vide pour conserver l'actuel)</span> @endif
</label>
<input type="password" wire:model="password_ciphertext" autocomplete="new-password"
class="mt-1 w-full rounded border-slate-300 font-mono text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@error('password_ciphertext') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
</div>
<div>
<label class="block text-sm font-medium text-slate-700">URL</label>
<input type="text" wire:model="url" placeholder="https://..."
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
@error('url') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Notes</label>
<textarea wire:model="notes" rows="3"
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500"></textarea>
</div>
<label class="flex items-center gap-2 text-sm text-slate-700">
<input type="checkbox" wire:model="is_favorite" class="rounded border-slate-300">
Favori
</label>
<div class="flex items-center gap-3 pt-2">
<button type="submit"
class="rounded bg-slate-900 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">
Enregistrer
</button>
<a href="{{ route('organizations.passwords.index', $organization) }}" class="text-sm text-slate-500 hover:text-slate-900">Annuler</a>
</div>
</form>
@if ($password?->exists)
<div class="mt-8">
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-slate-500">Journal d'audit</h2>
<div class="overflow-hidden rounded border border-slate-200 bg-white">
<table class="min-w-full divide-y divide-slate-200 text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500">
<tr>
<th class="px-4 py-2">Action</th>
<th class="px-4 py-2">Utilisateur</th>
<th class="px-4 py-2">IP</th>
<th class="px-4 py-2">Quand</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@forelse ($password->auditLogs()->with('user')->latest()->limit(20)->get() as $log)
<tr>
<td class="px-4 py-2 capitalize text-slate-900">{{ $log->action }}</td>
<td class="px-4 py-2 text-slate-600">{{ $log->user?->name ?? 'système' }}</td>
<td class="px-4 py-2 text-slate-600">{{ $log->ip_address ?? '—' }}</td>
<td class="px-4 py-2 text-slate-500">{{ $log->created_at->diffForHumans() }}</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-4 py-4 text-center text-slate-400">Aucune activité pour le moment.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="mt-8">
<livewire:related-items.panel :organization="$organization" :item="$password" :key="'related-'.$password->id" />
</div>
@endif
</div>
@@ -0,0 +1,144 @@
<?php
use App\Models\Organization;
use App\Models\Password;
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;
new class extends Component
{
use WithPagination;
public Organization $organization;
#[Url]
public string $search = '';
public array $revealed = [];
public function reveal(int $passwordId): void
{
$password = $this->organization->passwords()->findOrFail($passwordId);
$password->logAction('revealed');
$this->revealed[$passwordId] = $password->password_ciphertext;
}
public function hide(int $passwordId): void
{
unset($this->revealed[$passwordId]);
}
public function copy(int $passwordId): void
{
$password = $this->organization->passwords()->findOrFail($passwordId);
$password->logAction('copied');
$this->dispatch('password-copy', value: $password->password_ciphertext);
}
public function delete(int $passwordId): void
{
$password = $this->organization->passwords()->findOrFail($passwordId);
$password->logAction('deleted');
$password->delete();
unset($this->revealed[$passwordId]);
session()->flash('status', "Mot de passe « {$password->name} » supprimé.");
}
public function with(): array
{
return [
'passwords' => $this->organization->passwords()
->when($this->search, fn ($query) => $query->where(function ($q) {
$q->where('name', 'like', "%{$this->search}%")
->orWhere('username', 'like', "%{$this->search}%")
->orWhere('url', 'like', "%{$this->search}%");
}))
->orderBy('name')
->paginate(15),
];
}
};
?>
<div x-data x-on:password-copy.window="navigator.clipboard.writeText($event.detail.value)">
<div class="mb-6 flex items-center justify-between">
<div>
<p class="text-sm text-slate-500">{{ $organization->name }}</p>
<h1 class="text-2xl font-semibold text-slate-900">Mots de passe</h1>
</div>
<a href="{{ route('organizations.passwords.create', $organization) }}"
class="rounded bg-slate-900 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">
+ Nouveau mot de passe
</a>
</div>
<input type="text" wire:model.live.debounce.300ms="search" placeholder="Filtrer par nom, nom d'utilisateur, url..."
class="mb-4 w-full max-w-sm rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
<div class="overflow-x-auto rounded border border-slate-200 bg-white">
<table class="min-w-full divide-y divide-slate-200 text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500">
<tr>
<th class="px-4 py-3">Nom</th>
<th class="px-4 py-3">Nom d'utilisateur</th>
<th class="px-4 py-3">Mot de passe</th>
<th class="px-4 py-3">URL</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@forelse ($passwords as $password)
<tr wire:key="pw-{{ $password->id }}">
<td class="px-4 py-3">
<a href="{{ route('organizations.passwords.edit', [$organization, $password]) }}"
class="font-medium text-slate-900 hover:underline">
{{ $password->name }}
</a>
</td>
<td class="px-4 py-3 text-slate-600">{{ $password->username ?? '—' }}</td>
<td class="px-4 py-3">
<div class="flex items-center gap-2 font-mono">
@if (isset($revealed[$password->id]))
<span class="text-slate-900">{{ $revealed[$password->id] }}</span>
<button type="button" wire:click="hide({{ $password->id }})"
class="text-xs text-slate-400 hover:text-slate-700">masquer</button>
@else
<span class="tracking-widest text-slate-400">••••••••</span>
<button type="button" wire:click="reveal({{ $password->id }})"
class="text-xs text-slate-500 hover:text-slate-900">afficher</button>
@endif
<button type="button" wire:click="copy({{ $password->id }})"
class="text-xs text-slate-500 hover:text-slate-900">copier</button>
</div>
</td>
<td class="px-4 py-3 text-slate-600">{{ $password->url ?? '—' }}</td>
<td class="px-4 py-3 text-right whitespace-nowrap">
<a href="{{ route('organizations.passwords.edit', [$organization, $password]) }}" class="text-slate-500 hover:text-slate-900">Modifier</a>
<button type="button"
wire:click="delete({{ $password->id }})"
wire:confirm="Supprimer ce mot de passe ? Cette action est irréversible."
class="ml-3 text-red-500 hover:text-red-700">
Supprimer
</button>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-4 py-6 text-center text-slate-400">Aucun mot de passe pour le moment.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-4">
{{ $passwords->links() }}
</div>
</div>