Merge branch 'audit'
This commit is contained in:
commit
0086639891
6 changed files with 104 additions and 1 deletions
18
apps/admin_audit/appinfo/app.php
Normal file
18
apps/admin_audit/appinfo/app.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
OC::$CLASSPATH['OC_Admin_Audit_Hooks_Handlers'] = 'apps/admin_audit/lib/hooks_handlers.php';
|
||||
|
||||
OCP\Util::connectHook('OCP\User', 'pre_login', 'OC_Admin_Audit_Hooks_Handlers', 'pre_login');
|
||||
OCP\Util::connectHook('OCP\User', 'post_login', 'OC_Admin_Audit_Hooks_Handlers', 'post_login');
|
||||
OCP\Util::connectHook('OCP\User', 'logout', 'OC_Admin_Audit_Hooks_Handlers', 'logout');
|
||||
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, 'OC_Admin_Audit_Hooks_Handlers', 'rename');
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, 'OC_Admin_Audit_Hooks_Handlers', 'create');
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, 'OC_Admin_Audit_Hooks_Handlers', 'copy');
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, 'OC_Admin_Audit_Hooks_Handlers', 'write');
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_read, 'OC_Admin_Audit_Hooks_Handlers', 'read');
|
||||
OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, 'OC_Admin_Audit_Hooks_Handlers', 'delete');
|
||||
|
||||
OCP\Util::connectHook('OC_Share', 'public', 'OC_Admin_Audit_Hooks_Handlers', 'share_public');
|
||||
OCP\Util::connectHook('OC_Share', 'public-download', 'OC_Admin_Audit_Hooks_Handlers', 'share_public_download');
|
||||
OCP\Util::connectHook('OC_Share', 'user', 'OC_Admin_Audit_Hooks_Handlers', 'share_user');
|
10
apps/admin_audit/appinfo/info.xml
Normal file
10
apps/admin_audit/appinfo/info.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<info>
|
||||
<id>admin_audit</id>
|
||||
<name>Log audit info</name>
|
||||
<version>0.1</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Bart Visscher</author>
|
||||
<require>2</require>
|
||||
<description>Audit user actions in Owncloud</description>
|
||||
</info>
|
72
apps/admin_audit/lib/hooks_handlers.php
Normal file
72
apps/admin_audit/lib/hooks_handlers.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
class OC_Admin_Audit_Hooks_Handlers {
|
||||
static public function pre_login($params) {
|
||||
$path = $params['uid'];
|
||||
self::log('Trying login '.$user);
|
||||
}
|
||||
static public function post_login($params) {
|
||||
$path = $params['uid'];
|
||||
self::log('Login '.$user);
|
||||
}
|
||||
static public function logout($params) {
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Logout '.$user);
|
||||
}
|
||||
|
||||
static public function rename($params) {
|
||||
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
|
||||
$newpath = $params[OC_Filesystem::signal_param_newpath];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user);
|
||||
}
|
||||
static public function create($params) {
|
||||
$path = $params[OC_Filesystem::signal_param_path];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Create "'.$path.'" by '.$user);
|
||||
}
|
||||
static public function copy($params) {
|
||||
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
|
||||
$newpath = $params[OC_Filesystem::signal_param_newpath];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user);
|
||||
}
|
||||
static public function write($params) {
|
||||
$path = $params[OC_Filesystem::signal_param_path];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Write "'.$path.'" by '.$user);
|
||||
}
|
||||
static public function read($params) {
|
||||
$path = $params[OC_Filesystem::signal_param_path];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Read "'.$path.'" by '.$user);
|
||||
}
|
||||
static public function delete($params) {
|
||||
$path = $params[OC_Filesystem::signal_param_path];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Delete "'.$path.'" by '.$user);
|
||||
}
|
||||
static public function share_public($params) {
|
||||
$path = $params['source'];
|
||||
$token = $params['token'];
|
||||
$user = OCP\User::getUser();
|
||||
self::log('Shared "'.$path.'" with public, token="'.$token.'" by '.$user);
|
||||
}
|
||||
static public function share_public_download($params) {
|
||||
$path = $params['source'];
|
||||
$token = $params['token'];
|
||||
$user = $_SERVER['REMOTE_ADDR'];
|
||||
self::log('Download of shared "'.$path.'" token="'.$token.'" by '.$user);
|
||||
}
|
||||
static public function share_user($params) {
|
||||
$path = $params['source'];
|
||||
$permissions = $params['permissions'];
|
||||
$with = $params['with'];
|
||||
$user = OCP\User::getUser();
|
||||
$rw = $permissions & OC_Share::WRITE ? 'w' : 'o';
|
||||
self::log('Shared "'.$path.'" (r'.$rw.') with user "'.$with.'" by '.$user);
|
||||
}
|
||||
static protected function log($msg) {
|
||||
OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO);
|
||||
}
|
||||
}
|
|
@ -77,6 +77,7 @@ if (isset($_GET['token']) && $source = OC_Share::getSource($_GET['token'])) {
|
|||
header("Content-Length: " . OC_Filesystem::filesize($source));
|
||||
//download the file
|
||||
@ob_clean();
|
||||
OCP\Util::emitHook('OC_Share', 'public-download', array('source'=>$source, 'token'=>$token);
|
||||
OC_Filesystem::readfile($source);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -47,6 +47,7 @@ class OC_Share {
|
|||
}
|
||||
if ($uid_shared_with == self::PUBLICLINK) {
|
||||
$token = sha1("$uid_shared_with-$source");
|
||||
OCP\Util::emitHook('OC_Share', 'public', array('source'=>$source, 'token'=>$token, 'permissions'=>$permissions));
|
||||
$query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions));
|
||||
$this->token = $token;
|
||||
} else {
|
||||
|
@ -118,6 +119,7 @@ class OC_Share {
|
|||
if (isset($gid)) {
|
||||
$uid = $uid."@".$gid;
|
||||
}
|
||||
OCP\Util::emitHook('OC_Share', 'user', array('source'=>$source, 'target'=>$target, 'with'=>$uid, 'permissions'=>$permissions));
|
||||
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
/**
|
||||
* Class for abstraction of filesystem functions
|
||||
* This class won't call any filesystem functions for itself but but will pass them to the correct OC_Filestorage object
|
||||
* this class should also handle all the file premission related stuff
|
||||
* this class should also handle all the file permission related stuff
|
||||
*
|
||||
* Hooks provided:
|
||||
* read(path)
|
||||
|
|
Loading…
Reference in a new issue