Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certificates - perms and model #1078

Merged
merged 2 commits into from
Oct 2, 2024
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
32 changes: 8 additions & 24 deletions post/user/certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@

if (isset($_POST['add_certificate'])) {

validateTechRole();
enforceUserPermission('module_support', 2);

$client_id = intval($_POST['client_id']);
$name = sanitizeInput($_POST['name']);
$description = sanitizeInput($_POST['description']);
$domain = sanitizeInput($_POST['domain']);
$issued_by = sanitizeInput($_POST['issued_by']);
$expire = sanitizeInput($_POST['expire']);
$public_key = sanitizeInput($_POST['public_key']);
$notes = sanitizeInput($_POST['notes']);
$domain_id = intval($_POST['domain_id']);
require_once 'post/user/certificate_model.php';

// Parse public key data for a manually provided public key
if (!empty($public_key) && (empty($expire) && empty($issued_by))) {
Expand Down Expand Up @@ -49,18 +41,10 @@

if (isset($_POST['edit_certificate'])) {

validateTechRole();
enforceUserPermission('module_support', 2);

require_once 'post/user/certificate_model.php';
$certificate_id = intval($_POST['certificate_id']);
$name = sanitizeInput($_POST['name']);
$description = sanitizeInput($_POST['description']);
$domain = sanitizeInput($_POST['domain']);
$issued_by = sanitizeInput($_POST['issued_by']);
$expire = sanitizeInput($_POST['expire']);
$public_key = sanitizeInput($_POST['public_key']);
$notes = sanitizeInput($_POST['notes']);
$domain_id = intval($_POST['domain_id']);
$client_id = intval($_POST['client_id']);

// Parse public key data for a manually provided public key
if (!empty($public_key) && (empty($expire) && empty($issued_by))) {
Expand Down Expand Up @@ -91,7 +75,7 @@

if (isset($_GET['archive_certificate'])) {

validateTechRole();
enforceUserPermission('module_support', 2);

$certificate_id = intval($_GET['archive_certificate']);

Expand All @@ -115,7 +99,7 @@

if (isset($_GET['delete_certificate'])) {

validateAdminRole();
enforceUserPermission('module_support', 3);

$certificate_id = intval($_GET['delete_certificate']);

Expand All @@ -138,7 +122,7 @@
}

if (isset($_POST['bulk_delete_certificates'])) {
validateAdminRole();
enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']);

$count = 0; // Default 0
Expand Down Expand Up @@ -169,7 +153,7 @@

if (isset($_POST['export_client_certificates_csv'])) {

validateTechRole();
enforceUserPermission('module_support');

$client_id = intval($_POST['client_id']);

Expand Down
10 changes: 10 additions & 0 deletions post/user/certificate_model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
$name = sanitizeInput($_POST['name']);
$description = sanitizeInput($_POST['description']);
$domain = sanitizeInput($_POST['domain']);
$issued_by = sanitizeInput($_POST['issued_by']);
$expire = sanitizeInput($_POST['expire']);
$public_key = sanitizeInput($_POST['public_key']);
$notes = sanitizeInput($_POST['notes']);
$domain_id = intval($_POST['domain_id']);
$client_id = intval($_POST['client_id']);
Loading