95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Collect Site Name, DN, list of E-Mail addresses, Serial Number
|
|
*
|
|
* Call Hydra to create new record, collect Client ID and Secret
|
|
*
|
|
* Send Client ID and Secret back to caller and display
|
|
*
|
|
*/
|
|
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', '1');
|
|
|
|
echo file_get_contents("html/header.html");
|
|
|
|
$ini_arr = parse_ini_file( "cacert.ini", true );
|
|
$internalHydraEndpointURL = $ini_arr[ 'URLs' ][ 'InternalHydraEndpointURL' ];
|
|
$dbUser = $ini_arr[ 'DB' ][ 'User' ];
|
|
$dbPass = $ini_arr[ 'DB' ][ 'Password' ];
|
|
|
|
?>
|
|
|
|
<div class="scrollDiv" >
|
|
|
|
<?php
|
|
|
|
if (isset($_POST['radiobtn'])) {
|
|
|
|
$idx = $_POST['radiobtn'];
|
|
$clientID = $_POST['client_id'][$idx];
|
|
|
|
}
|
|
|
|
|
|
$hydraCommand = "/srv/hydra/bin/hydra delete oauth2-client $clientID --endpoint $internalHydraEndpointURL ";
|
|
$retcode = exec($hydraCommand, $hydraArray);
|
|
|
|
|
|
$outArray = [];
|
|
|
|
foreach ($hydraArray as $hydra) {
|
|
|
|
$keyIDX = strpos($hydra, "\t");
|
|
|
|
if ($keyIDX === false) {
|
|
$outArray[$hydra] = "";
|
|
} else {
|
|
$valIDX = strrpos($hydra, "\t", -1);
|
|
|
|
$key = substr($hydra, 0, $keyIDX);
|
|
|
|
$val = substr($hydra, $valIDX + 1);
|
|
$outArray[$key] = $val;
|
|
}
|
|
}
|
|
|
|
if ($outArray['ID'] == $clientID) {
|
|
|
|
$db = new PDO("pgsql:host=localhost;port=5432;dbname=oidc_db;user=$dbUser;password=$dbPass");
|
|
|
|
$stmt = $db->prepare("update clients set deleted_at = now() where client_id = :client_id");
|
|
$retcode = $stmt->execute([$clientID]);
|
|
|
|
$stmt = $db->query("select site_name, created_at, client_id from clients where client_id = '$clientID' ");
|
|
$result = $stmt->fetchAll();
|
|
|
|
?>
|
|
<div style="background-color: lightblue; color: black; padding: 1em">
|
|
<p>
|
|
<?php
|
|
$siteInfo = $result['0'];
|
|
?>
|
|
Site <?php echo $siteInfo['site_name'] ?>
|
|
with Client ID <?php echo $siteInfo['client_id'] ?>
|
|
deleted successfully
|
|
</p>
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
|
|
|
|
echo "<div class='pageFooter' >";
|
|
|
|
echo file_get_contents("html/footer.html");
|
|
|
|
echo "<br>";
|
|
echo '<p>Copyright © CAcert, Inc ';
|
|
echo date("Y");
|
|
echo "</p>";
|
|
|
|
echo "</div>";
|
|
echo "</div>";
|
|
|