Skip to content
Snippets Groups Projects
Commit 5d61b85a authored by Björn Schießle's avatar Björn Schießle
Browse files

allow users to upload ssl root certificates for the webdav client

parent b2eac08a
No related branches found
No related tags found
No related merge requests found
<?php
OCP\JSON::checkAppEnabled('files_external');
$view = \OCP\Files::getStorage("files_external");
$from = $_FILES['rootcert_import']['tmp_name'];
$to = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").$_FILES['rootcert_import']['name'];
move_uploaded_file($from, $to);
header("Location: settings/personal.php");
exit;
?>
\ No newline at end of file
<?php
OCP\JSON::checkAppEnabled('files_external');
$view = \OCP\Files::getStorage("files_external");
$cert = $_POST['cert'];
$file = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").$cert;
unlink($file);
?>
\ No newline at end of file
OC.MountConfig={ OC.MountConfig={
saveStorage:function(tr) { saveStorage:function(tr) {
var mountPoint = $(tr).find('.mountPoint input').val(); var mountPoint = $(tr).find('.mountPoint input').val();
if (mountPoint == '') { if (mountPoint == '') {
...@@ -68,7 +68,6 @@ OC.MountConfig={ ...@@ -68,7 +68,6 @@ OC.MountConfig={
} }
$(document).ready(function() { $(document).ready(function() {
$('.chzn-select').chosen(); $('.chzn-select').chosen();
$('#selectBackend').live('change', function() { $('#selectBackend').live('change', function() {
...@@ -116,8 +115,11 @@ $(document).ready(function() { ...@@ -116,8 +115,11 @@ $(document).ready(function() {
$('td.remove>img').live('click', function() { $('td.remove>img').live('click', function() {
var tr = $(this).parent().parent(); var tr = $(this).parent().parent();
var mountPoint = $(tr).find('.mountPoint input').val(); var mountPoint = $(tr).find('.mountPoint input').val();
if (mountPoint == '') { if (!mountPoint) {
return false; var row=this.parentNode.parentNode;
$.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), { cert: row.id });
$(tr).remove();
return true;
} }
if ($('#externalStorage').data('admin') === true) { if ($('#externalStorage').data('admin') === true) {
var isPersonal = false; var isPersonal = false;
......
...@@ -237,6 +237,21 @@ class OC_Mount_Config { ...@@ -237,6 +237,21 @@ class OC_Mount_Config {
$content .= ");\n?>"; $content .= ");\n?>";
@file_put_contents($file, $content); @file_put_contents($file, $content);
} }
/**
* Returns all user uploaded ssl root certificates
* @return array
*/
public static function getCertificates() {
$view = \OCP\Files::getStorage('files_external');
$path=\OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("");
$result = array();
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if($file != '.' && $file != '..') $result[] = $file;
}
return $result;
}
} }
......
...@@ -28,6 +28,7 @@ unset($backends['OC_Filestorage_Local']); ...@@ -28,6 +28,7 @@ unset($backends['OC_Filestorage_Local']);
$tmpl = new OCP\Template('files_external', 'settings'); $tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', false, false); $tmpl->assign('isAdminPage', false, false);
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints()); $tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());
$tmpl->assign('certs', OC_Mount_Config::getCertificates());
$tmpl->assign('backends', $backends); $tmpl->assign('backends', $backends);
return $tmpl->fetchPage(); return $tmpl->fetchPage();
......
<form id="files_external"> <form id="files_external" method="post" enctype="multipart/form-data" action="/owncloud/?app=files_external&getfile=ajax%2FaddRootCertificate.php">
<fieldset class="personalblock"> <fieldset class="personalblock">
<legend><strong><?php echo $l->t('External Storage'); ?></strong></legend> <legend><strong><?php echo $l->t('External Storage'); ?></strong></legend>
<table id="externalStorage" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'> <table id="externalStorage" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
...@@ -79,6 +79,27 @@ ...@@ -79,6 +79,27 @@
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<br />
<table id="sslCertificate" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
<thead>
<tr>
<th><?php echo $l->t('SSL root certificates'); ?></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody width="100%">
<?php foreach ($_['certs'] as $rootCert): ?>
<tr id="<?php echo $rootCert ?>">
<td class="rootCert"><?php echo $rootCert ?></td>
<td <?php echo ($rootCert != '') ? 'class="remove"' : 'style="visibility:hidden;"'; ?>><img alt="<?php echo $l->t('Delete'); ?>" title="<?php echo $l->t('Delete'); ?>" class="svg action" src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="file" id="rootcert_import" name="rootcert_import" style="width:230px;">
<input type="submit" name="cert_import" value="<?php echo $l->t('Import Root Certificate'); ?>" />
<?php if ($_['isAdminPage']): ?> <?php if ($_['isAdminPage']): ?>
<br /> <br />
<input type="checkbox" name="allowUserMounting" id="allowUserMounting" value="1" <?php if ($_['allowUserMounting'] == 'yes') echo ' checked="checked"'; ?> /> <input type="checkbox" name="allowUserMounting" id="allowUserMounting" value="1" <?php if ($_['allowUserMounting'] == 'yes') echo ' checked="checked"'; ?> />
...@@ -86,4 +107,4 @@ ...@@ -86,4 +107,4 @@
<em><?php echo $l->t('Allow users to mount their own external storage'); ?></em> <em><?php echo $l->t('Allow users to mount their own external storage'); ?></em>
<?php endif; ?> <?php endif; ?>
</fieldset> </fieldset>
</form> </form>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment