allow user to choose encryption mode
This commit is contained in:
parent
c4d1ad1b7d
commit
6b058cd359
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
OCP\JSON::checkAppEnabled('files_encryption');
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
|
||||
$query = \OC_DB::prepare( "SELECT mode FROM *PREFIX*encryption WHERE uid = ?" );
|
||||
$result = $query->execute(array(\OCP\User::getUser()));
|
||||
|
||||
if ($row = $result->fetchRow()){
|
||||
$query = OC_DB::prepare( 'UPDATE *PREFIX*encryption SET mode = ? WHERE uid = ?' );
|
||||
} else {
|
||||
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*encryption ( mode, uid ) VALUES( ?, ? )' );
|
||||
}
|
||||
$query->execute(array($mode, \OCP\User::getUser()));
|
|
@ -28,4 +28,5 @@ and OCP\User::isLoggedIn()
|
|||
|
||||
}
|
||||
|
||||
OCP\App::registerAdmin('files_encryption', 'settings');
|
||||
OCP\App::registerAdmin('files_encryption', 'settings');
|
||||
OCP\App::registerPersonal('files_encryption','settings-personal');
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<database>
|
||||
<name>*dbname*</name>
|
||||
<create>true</create>
|
||||
<overwrite>false</overwrite>
|
||||
<charset>utf8</charset>
|
||||
<table>
|
||||
<name>*dbprefix*encryption</name>
|
||||
<declaration>
|
||||
<field>
|
||||
<name>uid</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>64</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>mode</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>64</length>
|
||||
</field>
|
||||
</declaration>
|
||||
</table>
|
||||
</database>
|
|
@ -1 +1 @@
|
|||
0.2
|
||||
0.2.1
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright (c) 2012, Bjoern Schiessle <schiessle@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
console.log("loaded!");
|
||||
$('input[name=encryption_mode]').change(function(){
|
||||
console.log("HERE!!!!!!!!!!!");
|
||||
var client=$('input[value="client"]:checked').val()
|
||||
,server=$('input[value="server"]:checked').val()
|
||||
,user=$('input[value="user"]:checked').val()
|
||||
,none=$('input[value="none"]:checked').val()
|
||||
if (client)
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'changemode.php'), { mode: 'client' });
|
||||
else if (server)
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'changemode.php'), { mode: 'server' });
|
||||
else
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'changemode.php'), { mode: 'none' });
|
||||
})
|
||||
})
|
|
@ -17,19 +17,18 @@ $(document).ready(function(){
|
|||
OC.AppConfig.setValue('files_encryption','type_blacklist',blackList);
|
||||
}
|
||||
|
||||
$('#enable_encryption').change(function(){
|
||||
var checked=$('#enable_encryption').is(':checked');
|
||||
OC.AppConfig.setValue('files_encryption','enable_encryption',(checked)?'true':'false');
|
||||
})
|
||||
$('input[name=encryption_mode]').change(function(){
|
||||
var client=$('input[value="client"]:checked').val()
|
||||
,server=$('input[value="server"]:checked').val()
|
||||
,user=$('input[value="user"]:checked').val()
|
||||
,none=$('input[value="none"]:checked').val()
|
||||
if (client)
|
||||
OC.AppConfig.setValue('files_encryption','mode','client');
|
||||
if (server)
|
||||
else if (server)
|
||||
OC.AppConfig.setValue('files_encryption','mode','server');
|
||||
if (none)
|
||||
else if (user)
|
||||
OC.AppConfig.setValue('files_encryption','mode','user');
|
||||
else
|
||||
OC.AppConfig.setValue('files_encryption','mode','none');
|
||||
})
|
||||
})
|
|
@ -37,14 +37,17 @@ class Crypt {
|
|||
*/
|
||||
public static function mode( $user = null ) {
|
||||
|
||||
$mode = \OC_Appconfig::getValue( 'files_encryption', 'mode', 'unknown' );
|
||||
|
||||
if ( $mode == 'unknown' ) {
|
||||
|
||||
error_log('no encryption mode configured');
|
||||
|
||||
return false;
|
||||
|
||||
$mode = \OC_Appconfig::getValue( 'files_encryption', 'mode', 'none' );
|
||||
|
||||
if ( $mode == 'user') {
|
||||
$mode = 'none';
|
||||
if ( $user ) {
|
||||
$query = \OC_DB::prepare( "SELECT mode FROM *PREFIX*encryption WHERE uid = ?" );
|
||||
$result = $query->execute(array($user));
|
||||
if ($row = $result->fetchRow()){
|
||||
$mode = $row['mode'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mode;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
$sysEncMode = \OC_Appconfig::getValue('files_encryption', 'mode', 'none');
|
||||
|
||||
if ($sysEncMode == 'user') {
|
||||
|
||||
$tmpl = new OCP\Template( 'files_encryption', 'settings-personal');
|
||||
|
||||
$query = \OC_DB::prepare( "SELECT mode FROM *PREFIX*encryption WHERE uid = ?" );
|
||||
$result = $query->execute(array(\OCP\User::getUser()));
|
||||
|
||||
if ($row = $result->fetchRow()){
|
||||
$mode = $row['mode'];
|
||||
} else {
|
||||
$mode = 'none';
|
||||
}
|
||||
|
||||
OCP\Util::addscript('files_encryption','settings-personal');
|
||||
$tmpl->assign('encryption_mode', $mode);
|
||||
return $tmpl->fetchPage();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
?>
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
$tmpl = new OCP\Template( 'files_encryption', 'settings');
|
||||
$blackList=explode(',',OCP\Config::getAppValue('files_encryption','type_blacklist','jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg'));
|
||||
$enabled=(OCP\Config::getAppValue('files_encryption','enable_encryption','true')=='true');
|
||||
$tmpl->assign('blacklist',$blackList);
|
||||
$tmpl->assign('encryption_mode',\OC_Appconfig::getValue('files_encryption', 'mode', 'none'));
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
<form id="encryption">
|
||||
<fieldset class="personalblock">
|
||||
|
||||
<strong>Choose encryption mode:</strong>
|
||||
|
||||
<p>
|
||||
<input type="radio" name="encryption_mode" value="client" style="width:20px;" <?php if ($_['encryption_mode'] == 'client') echo "checked='checked'"?>/> Client side encryption (most secure but makes it impossible to access your data from the web interface)<br />
|
||||
<input type="radio" name="encryption_mode" value="server" style="width:20px;" <?php if ($_['encryption_mode'] == 'server') echo "checked='checked'"?> /> Server side encryption (allows you to access your files from the web interface and the desktop client)<br />
|
||||
<input type="radio" name="encryption_mode" value="none" style="width:20px;" <?php if ($_['encryption_mode'] == 'none') echo "checked='checked'"?>/> None (no encryption at all)<br/>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<form id="calendar">
|
||||
<form id="encryption">
|
||||
<fieldset class="personalblock">
|
||||
|
||||
<strong>Choose encryption mode:</strong>
|
||||
|
@ -6,6 +6,7 @@
|
|||
<p>
|
||||
<input type="radio" name="encryption_mode" value="client" style="width:20px;" <?php if ($_['encryption_mode'] == 'client') echo "checked='checked'"?>/> Client side encryption (most secure but makes it impossible to access your data from the web interface)<br />
|
||||
<input type="radio" name="encryption_mode" value="server" style="width:20px;" <?php if ($_['encryption_mode'] == 'server') echo "checked='checked'"?> /> Server side encryption (allows you to access your files from the web interface and the desktop client)<br />
|
||||
<input type="radio" name="encryption_mode" value="user" style="width:20px;" <?php if ($_['encryption_mode'] == 'user') echo "checked='checked'"?>/> User specific (let the user decide)<br/>
|
||||
<input type="radio" name="encryption_mode" value="none" style="width:20px;" <?php if ($_['encryption_mode'] == 'none') echo "checked='checked'"?>/> None (no encryption at all)<br/>
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -39,4 +39,4 @@
|
|||
</field>
|
||||
</declaration>
|
||||
</table>
|
||||
</database>
|
||||
</database>
|
Loading…
Reference in New Issue