mirror of
https://github.com/tips-of-mine/gestion-certificats2.git
synced 2025-07-01 22:48:42 +02:00
![google-labs-jules[bot]](/assets/img/avatar_default.png)
Ce commit introduit la possibilité pour vous de télécharger les fichiers de certificats (racine, intermédiaire, final) et la clé privée du certificat racine (administrateurs uniquement) directement depuis la page du tableau de bord. Changements inclus : - Ajout d'une méthode `download()` dans `CertificateController` pour gérer la logique de téléchargement sécurisé des fichiers. - Ajout d'une nouvelle route `GET /certificates/download`. - Correction et standardisation des liens de téléchargement dans la vue du dashboard pour assurer la transmission correcte des paramètres (type de certificat, nom de fichier, périmètre). - La méthode de téléchargement inclut la journalisation des tentatives et des erreurs, ainsi que la gestion des permissions pour la clé privée racine.
97 lines
6.3 KiB
PHP
97 lines
6.3 KiB
PHP
<?php
|
|
// Variables attendues du contrôleur: $translations, $currentLang, $darkModeClass, $username, $userRole
|
|
require_once APP_ROOT_DIR . '/src/Views/shared/header.php';
|
|
?>
|
|
|
|
<div class="container">
|
|
<h1><?= str_replace('{username}', htmlspecialchars($username), htmlspecialchars($translations['welcome'])) ?></h1>
|
|
|
|
<nav>
|
|
<ul>
|
|
<li><a href="/certificates"><?= htmlspecialchars($translations['certificates']) ?></a></li>
|
|
<li><a href="/perimeters"><?= htmlspecialchars($translations['functional_perimeters']) ?></a></li>
|
|
<?php if ($userRole === 'admin'): ?>
|
|
<li><a href="/users"><?= htmlspecialchars($translations['users']) ?></a></li>
|
|
<?php endif; ?>
|
|
<li><a href="/logout" class="button logout-button"><?= htmlspecialchars($translations['logout']) ?></a></li>
|
|
</ul>
|
|
</nav>
|
|
|
|
<section class="quick-actions">
|
|
<h2><?= htmlspecialchars($translations['quick_actions']) ?></h2>
|
|
<ul>
|
|
<li><a href="/certificates/create" class="button create-button"><?= htmlspecialchars($translations['create_new_certificate']) ?></a></li>
|
|
<li><a href="/perimeters/create" class="button create-button"><?= htmlspecialchars($translations['create_new_perimeter']) ?></a></li>
|
|
<?php if ($userRole === 'admin'): ?>
|
|
<li><a href="/users/create" class="button create-button"><?= htmlspecialchars($translations['new_user']) ?></a></li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</section>
|
|
|
|
<section class="certificates-overview">
|
|
<h2><?= htmlspecialchars($translations['certificates_overview_title'] ?? 'Certificates Overview') ?></h2>
|
|
|
|
<!-- Root Certificate -->
|
|
<h3><?= htmlspecialchars($translations['root_certificate_title'] ?? 'Root Certificate') ?></h3>
|
|
<?php if (isset($structuredCertificates['root']) && $structuredCertificates['root']): ?>
|
|
<div>
|
|
<p><strong><?= htmlspecialchars($translations['name'] ?? 'Name:') ?></strong> <?= htmlspecialchars($structuredCertificates['root']['name']) ?></p>
|
|
<p>
|
|
<a href="/certificates/download?type=root&file=ca.cert.pem" class="button">
|
|
<?= htmlspecialchars($translations['download_certificate_pem'] ?? 'Download Certificate (.pem)') ?>
|
|
</a>
|
|
</p>
|
|
<p>
|
|
<a href="/certificates/download?type=root&file=ca.key.pem" class="button">
|
|
<?= htmlspecialchars($translations['download_key_pem'] ?? 'Download Private Key (.key)') ?>
|
|
</a>
|
|
</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<p><?= htmlspecialchars($translations['root_certificate_not_configured'] ?? 'Root certificate is not configured.') ?></p>
|
|
<?php endif; ?>
|
|
|
|
<!-- Intermediate Certificates -->
|
|
<h3><?= htmlspecialchars($translations['intermediate_certificates_title'] ?? 'Intermediate Certificates') ?></h3>
|
|
<?php if (isset($structuredCertificates['intermediates']) && !empty($structuredCertificates['intermediates'])): ?>
|
|
<?php foreach ($structuredCertificates['intermediates'] as $intermediate): ?>
|
|
<div class="intermediate-certificate">
|
|
<h4><?= htmlspecialchars($intermediate['name']) ?> (<?= htmlspecialchars($translations['perimeter'] ?? 'Perimeter:') ?> <?= htmlspecialchars($intermediate['perimeter_name']) ?>)</h4>
|
|
<p>
|
|
<a href="/certificates/download?type=intermediate&perimeter=<?= urlencode($intermediate['perimeter_name']) ?>&file=intermediate.cert.pem" class="button">
|
|
<?= htmlspecialchars($translations['download_certificate_pem'] ?? 'Download Certificate (.pem)') ?>
|
|
</a>
|
|
</p>
|
|
|
|
<h5><?= htmlspecialchars($translations['associated_final_certificates_title'] ?? 'Associated Final Certificates') ?></h5>
|
|
<?php if (isset($intermediate['final_certificates']) && !empty($intermediate['final_certificates'])): ?>
|
|
<ul>
|
|
<?php foreach ($intermediate['final_certificates'] as $finalCert): ?>
|
|
<li>
|
|
<?= htmlspecialchars($finalCert['name']) ?>
|
|
(<?= htmlspecialchars($translations['type'] ?? 'Type:') ?> <?= htmlspecialchars($finalCert['type']) ?>,
|
|
<?= htmlspecialchars($translations['expires'] ?? 'Expires:') ?> <?= htmlspecialchars($finalCert['expiration_date']) ?>,
|
|
<?= htmlspecialchars($translations['revoked'] ?? 'Revoked:') ?> <?= $finalCert['is_revoked'] ? htmlspecialchars($translations['yes'] ?? 'Yes') : htmlspecialchars($translations['no'] ?? 'No') ?>)
|
|
<p>
|
|
<a href="/certificates/download?type=simple&perimeter=<?= urlencode($intermediate['perimeter_name']) ?>&file=<?= urlencode($finalCert['name']) ?>" class="button download-button-small">
|
|
<?= htmlspecialchars($translations['download_certificate_pem'] ?? 'Download Certificate (.pem)') ?>
|
|
</a>
|
|
</p>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php else: ?>
|
|
<p><?= htmlspecialchars($translations['no_associated_final_certificates'] ?? 'No final certificates associated with this intermediate.') ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<p><?= htmlspecialchars($translations['no_intermediate_certificates_found'] ?? 'No intermediate certificates found.') ?></p>
|
|
<?php endif; ?>
|
|
</section>
|
|
</div>
|
|
|
|
<?php
|
|
require_once APP_ROOT_DIR . '/src/Views/shared/footer.php';
|
|
?>
|