Add delete, new and revoke in list_users page

This commit is contained in:
Li Chen 2013-11-30 21:31:18 +01:00
parent dbcc23a535
commit 32bb0163c1
3 changed files with 56 additions and 0 deletions

View file

@ -55,11 +55,56 @@ if (!empty($p[2]))
$dir = "$misc_dir/pki";
remove_directory($dir);
}
elseif ($p[2] == "revoke")
{
$name = $_GET['name'];
if (isset($name))
{
putenv("OPENSSL_CONF=$misc_dir/openssl.cnf");
putenv("TOP_DIR=$misc_dir/pki");
$output = shell_exec("$misc_dir/CA.sh -revoke $name");
//TODO Check revocation failed
Team::set_revoked(TRUE, $name);
}
}
// Is new team
elseif ($p[2] == "newclient")
{
$name = $_GET['name'];
//TODO handle error
//TODO check revoked attribute
if (isset($name))
{
new_client($name, $misc_dir);
Team::set_revoked(FALSE, $name);
}
}
elseif ($p[2] == "get")
{
$name = $_GET['name'];
if (isset($name))
{
$path = "$misc_dir/pki/pkcs/$name.p12";
if (file_exists($path) && is_readable($path))
{
header("Content-Type: application/force-download");
header("Content-Length: ".strval(filesize($path)));
header("Content-Disposition: attachment; filename=\"$name.p12\"");
readfile($path);
}
}
exit;
}
if ($p[2] == "deleteca" || $p[2] == "newca")
{
header("Location: /".SALT_ADMIN."/");
exit;
}
elseif ($p[2] == "revoke" || $p[2] == "newclient")
{
header("Location: /".SALT_ADMIN."/teams");
exit;
}
}