Skip to content

Commit

Permalink
Enable audit by configuration nextcloud#163
Browse files Browse the repository at this point in the history
- audit of following actions:
- user X created circle Z;
- user X removed circle Z;
- user X change name of circle Z for circle W;
- user X was added to circle U by user Z;
- user X shared file/folder with circle Y;
- user X, that created circle, unshared file/folder with circle Y
- member X accepted invitation to circle Y by user Z;
- member X left circle Y;
- user X change role of member Y in circle Z for W.
- user X was invited to circle U by user Z

- configuration by circles_enable_audit in config.php

Signed-off-by: Flávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
  • Loading branch information
Flávio Gomes da Silva Lisboa committed Apr 20, 2018
1 parent d0e4e2f commit 0ebf0e7
Show file tree
Hide file tree
Showing 20 changed files with 436 additions and 32 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ Anyone can find the circle and request an invitation; but only members will see
- A **Secret Circle** is an hidden group that can only be seen by its members or by people knowing the exact name of the circle.
Non-members won't be able to find your secret circle using the search bar.

## Settings

Circles settings is available in Nextcloud interface in **Settings / Additional Settings**.

### Async Testing

This option allows to initiate an async test in Circles.

### Allow linking of groups

This option allows that groups be linked to circles.

### Allow federated circles

This option allows that circles from different Nextclouds can be linked together.

### Enable audit

This options allows that actions of circles, members and sharing can be audit with records into log. Following actions are audited:

* User X created circle Z;
* User X removed circle Z;
* User X change name of circle Z for circle W;
* User X was added to circle U by user Z;
* User X shared file/folder with circle Y;
* User X, that created circle, unshared file/folder with circle Y
* Member X accepted invitation to circle Y by user Z;
* Member X left circle Y;
* User X change role of member Y in circle Z for W.
* User X was invited to circle U by user Z

***
# API (PHP & Javascript)
Expand Down
2 changes: 1 addition & 1 deletion appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
$app->registerNavigation();
$app->registerFilesNavigation();
$app->registerFilesPlugin();

$app->registerHooks();

11 changes: 10 additions & 1 deletion js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ $(document).ready(function () {
elements.test_async_result = $('#test_async_result');
elements.allow_linked_groups = $('#allow_linked_groups');
elements.allow_federated_circles = $('#allow_federated_circles');
elements.enable_audit = $('#enable_audit');

elements.test_async_wait.hide().on('click', function () {
self.refreshResult();
Expand Down Expand Up @@ -74,6 +75,10 @@ $(document).ready(function () {
elements.allow_federated_circles.on('change', function () {
saveChange();
});

elements.enable_audit.on('change', function () {
saveChange();
});

saveChange = function () {
$.ajax({
Expand All @@ -83,11 +88,14 @@ $(document).ready(function () {
allow_linked_groups: (elements.allow_linked_groups.is(
':checked')) ? '1' : '0',
allow_federated_circles: (elements.allow_federated_circles.is(
':checked')) ? '1' : '0'
':checked')) ? '1' : '0',
enable_audit: (elements.enable_audit.is(
':checked')) ? '1' : '0'
}
}).done(function (res) {
elements.allow_linked_groups.prop('checked', (res.allowLinkedGroups === '1'));
elements.allow_federated_circles.prop('checked', (res.allowFederatedCircles === '1'));
elements.enable_audit.prop('checked', (res.enableAudit === '1'));
});
};

Expand Down Expand Up @@ -170,6 +178,7 @@ $(document).ready(function () {
}).done(function (res) {
elements.allow_linked_groups.prop('checked', (res.allowLinkedGroups === '1'));
elements.allow_federated_circles.prop('checked', (res.allowFederatedCircles === '1'));
elements.enable_audit.prop('checked', (res.enableAudit === '1'));
});

var timerTestAsync = setInterval(function () {
Expand Down
3 changes: 2 additions & 1 deletion js/circles.app.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ var actions = {
circle_desc: elements.settingsDesc.val(),
allow_links: (elements.settingsLink.is(":checked")),
allow_links_auto: (elements.settingsLinkAuto.is(":checked")),
allow_links_files: (elements.settingsLinkFiles.is(":checked"))
allow_links_files: (elements.settingsLinkFiles.is(":checked")),
enable_audit: (elements.settingsEnableAudit.is(":checked"))
};

api.settingsCircle(curr.circle, data, settings.saveSettingsResult);
Expand Down
2 changes: 2 additions & 0 deletions js/circles.app.elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var elements = {
settingsEntryLink: null,
settingsEntryLinkAuto: null,
settingsEntryLinkFiles: null,
settingsEnableAudit: null,
settingsSave: null,

addMember: null,
Expand Down Expand Up @@ -131,6 +132,7 @@ var elements = {
elements.settingsEntryLink = $('#settings-entry-link');
elements.settingsEntryLinkAuto = $('#settings-entry-link-auto');
elements.settingsEntryLinkFiles = $('#settings-entry-link-files');
elements.settingsEnableAudit = $('#settings-enable-audit');
elements.settingsSave = $('#settings-submit');

elements.addMember = $('#addmember');
Expand Down
2 changes: 2 additions & 0 deletions js/circles.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var curr = {
allowed_linked_groups: 0,
allowed_federated_circles: 0,
allowed_circles: 0,
enabled_audit: 0,

defineCircle: function (data) {
curr.circle = data.circle_id;
Expand Down Expand Up @@ -192,6 +193,7 @@ $(document).ready(function () {
curr.allowed_circles = result.allowed_circles;
curr.allowed_linked_groups = result.allowed_linked_groups;
curr.allowed_federated_circles = result.allowed_federated_circles;
curr.enabled_audit = result.enabled_audit;

var circleId = window.location.hash.substr(1);
if (circleId) {
Expand Down
10 changes: 6 additions & 4 deletions js/circles.app.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ var settings = {
(curr.circleSettings['allow_links_auto'] === 'true'));
elements.settingsLinkFiles.prop('checked',
(curr.circleSettings['allow_links_files'] === 'true'));
elements.settingsEnableAudit.prop('checked',
(curr.circleSettings['enable_audit'] === 'true'));

elements.settingsLink.on('change', function () {
settings.interactUISettings();
Expand All @@ -79,6 +81,9 @@ var settings = {
(elements.settingsLink.is(":checked")));
settings.enableSetting(elements.settingsEntryLinkFiles, elements.settingsLinkFiles,
(elements.settingsLink.is(":checked")));
settings.enableSetting(elements.settingsEntryEnableAudit, elements.settingsEnableAudit,
(elements.settingsEnableAudit.is(":checked")));

},

enableSetting: function (entry, input, enable) {
Expand All @@ -100,7 +105,4 @@ var settings = {
nav.displayMembersInteraction(result.details);
OCA.notification.onSuccess(t('circles', "Settings saved."));
}
};



};
4 changes: 3 additions & 1 deletion l10n/pt_BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ OC.L10N.register(
"Allow linking of groups:" : "Permitir links dos grupos:",
"Groups can be linked to circles." : "Grupos podem ser linkados a círculos.",
"Allow federated circles:" : "Permitir círculos federados:",
"Circles from different Nextclouds can be linked together." : "Círculos de diferentes Nextclouds podem ser linkados juntos."
"Circles from different Nextclouds can be linked together." : "Círculos de diferentes Nextclouds podem ser linkados juntos.",
"Enable audit:" : "Habilitar auditoria:",
"Actions of circles, members and sharing can be audited." : "Ações de círculos, membros e compartilhamentos podem ser auditadas."
},
"nplurals=2; plural=(n > 1);");
4 changes: 3 additions & 1 deletion l10n/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@
"Allow linking of groups:" : "Permitir links dos grupos:",
"Groups can be linked to circles." : "Grupos podem ser linkados a círculos.",
"Allow federated circles:" : "Permitir círculos federados:",
"Circles from different Nextclouds can be linked together." : "Círculos de diferentes Nextclouds podem ser linkados juntos."
"Circles from different Nextclouds can be linked together." : "Círculos de diferentes Nextclouds podem ser linkados juntos.",
"Enable audit:" : "Habilitar auditoria:",
"Actions of circles, members and sharing can be audited." : "Ações de círculos, membros e compartilhamentos podem ser auditadas."
},"pluralForm" :"nplurals=2; plural=(n > 1);"
}
4 changes: 3 additions & 1 deletion lib/Api/v1/Circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@ public static function shareToCircle(
$frame = new SharingFrame((string)$source, (string)$type);
$frame->setPayload($payload);

return $c->query(SharingFrameService::class)
$result = $c->query(SharingFrameService::class)
->createFrame($circleUniqueId, $frame, (string)$broadcaster);

return $result;
}


Expand Down
30 changes: 30 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,36 @@ public function registerHooks() {
Util::connectHook(
'OC_User', 'post_deleteGroup', '\OCA\Circles\Hooks\UserHooks', 'onGroupDeleted'
);
Util::connectHook(
'OCA\Circles', 'post_createCircle', '\OCA\Circles\Hooks\UserHooks', 'onCircleCreated'
);
Util::connectHook(
'OCA\Circles', 'post_destroyCircle', '\OCA\Circles\Hooks\UserHooks', 'onCircleDestroyed'
);
Util::connectHook(
'OCA\Circles', 'post_updateCircle', '\OCA\Circles\Hooks\UserHooks', 'onCircleUpdated'
);
Util::connectHook(
'OCA\Circles', 'post_addMember', '\OCA\Circles\Hooks\UserHooks', 'onMemberAdded'
);
Util::connectHook(
'OCA\Circles', 'post_removeMember', '\OCA\Circles\Hooks\UserHooks', 'onMemberRemoved'
);
Util::connectHook(
'OCP\Share', 'post_share', '\OCA\Circles\Hooks\UserHooks', 'onItemShared'
);
Util::connectHook(
'OCP\Share', 'post_unshare', '\OCA\Circles\Hooks\UserHooks', 'onItemUnshared'
);
Util::connectHook(
'OCA\Circles', 'post_joinMember', '\OCA\Circles\Hooks\UserHooks', 'onMemberJoined'
);
Util::connectHook(
'OCA\Circles', 'post_leftMember', '\OCA\Circles\Hooks\UserHooks', 'onMemberLeft'
);
Util::connectHook(
'OCA\Circles', 'post_changeLevelMember', '\OCA\Circles\Hooks\UserHooks', 'onMemberLevelChanged'
);
}


Expand Down
8 changes: 7 additions & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,26 @@ public function getSettings() {
),
'allowFederatedCircles' => $this->configService->getAppValue(
ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES
),
'enableAudit' => $this->configService->getAppValue(
ConfigService::CIRCLES_ENABLE_AUDIT
)
];

return $params;
}


public function setSettings($allow_linked_groups, $allow_federated_circles) {
public function setSettings($allow_linked_groups, $allow_federated_circles, $enable_audit) {
$this->configService->setAppValue(
ConfigService::CIRCLES_ALLOW_LINKED_GROUPS, $allow_linked_groups
);
$this->configService->setAppValue(
ConfigService::CIRCLES_ALLOW_FEDERATED_CIRCLES, $allow_federated_circles
);
$this->configService->setAppValue(
ConfigService::CIRCLES_ENABLE_AUDIT, $enable_audit
);

return $this->getSettings();
}
Expand Down
Loading

0 comments on commit 0ebf0e7

Please sign in to comment.