Skip to content

Commit

Permalink
Merge pull request #1078 from itflow-org/cert-perms-model
Browse files Browse the repository at this point in the history
Certificates - perms and model
  • Loading branch information
johnnyq authored Oct 2, 2024
2 parents c352f6e + 4a62518 commit 10fab10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
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']);

0 comments on commit 10fab10

Please sign in to comment.