-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to disable audit logs #6004
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,4 +136,27 @@ <h2 i18n class="inner-form-title">CUSTOMIZATIONS</h2> | |
</div> | ||
</div> | ||
|
||
<div class="row mt-4"> <!-- cache grid --> | ||
<div class="col-12 col-lg-4 col-xl-3"> | ||
<div class="anchor" id="customizations"></div> <!-- customizations anchor --> | ||
<h2 i18n class="inner-form-title">LOGS</h2> | ||
<div i18n class="inner-form-description"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description of this block is invalid |
||
Slight modifications to your PeerTube instance for when creating a plugin or theme is overkill. | ||
</div> | ||
</div> | ||
|
||
<div class="col-12 col-lg-8 col-xl-9"> | ||
<ng-container formGroupName="instance"> | ||
<ng-container formGroupName="logs"> | ||
<ng-container formGroupName="auditLogs"> | ||
<div class="form-group"> | ||
<my-peertube-checkbox inputName="auditLogsEnabled" formControlName="enabled" i18n-labelText | ||
labelText="Enable audit logs"></my-peertube-checkbox> | ||
</div> | ||
</ng-container> | ||
</ng-container> | ||
</ng-container> | ||
</div> | ||
</div> | ||
|
||
</ng-container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
</div> | ||
|
||
<ng-select | ||
*ngIf="!isAuditLog() || isAuditLogsEnabled" | ||
[(ngModel)]="startDate" | ||
(ngModelChange)="refresh()" | ||
[clearable]="false" | ||
|
@@ -30,14 +31,16 @@ | |
|
||
<my-select-tags *ngIf="!isAuditLog()" i18n-placeholder placeholder="Filter logs by tags" [(ngModel)]="tagsOneOf" (ngModelChange)="refresh()"></my-select-tags> | ||
|
||
<my-button i18n-label label="Refresh" icon="refresh" (click)="refresh()"></my-button> | ||
<my-button *ngIf="!isAuditLog() || isAuditLogsEnabled" i18n-label label="Refresh" icon="refresh" (click)="refresh()"></my-button> | ||
</div> | ||
|
||
<div class="logs"> | ||
<div *ngIf="loading" i18n>Loading...</div> | ||
|
||
<div #logsElement> | ||
<div *ngIf="!loading && logs.length === 0" i18n>No log.</div> | ||
<div *ngIf="isAuditLog && !isAuditLogsEnabled" i18n>Audit logs disabled.</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Also transform |
||
|
||
<div *ngIf="!loading && logs.length === 0 && isAuditLogsEnabled" i18n>No log.</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If audit logs is disabled but you're on the normal logs, you'll never see this message I suggest to simplify lines 41/43 using an Angular else for example (not easy to use, but will be simpler in the future with the new Angular markup language: https://blog.angular.io/meet-angulars-new-control-flow-a02c6eee7843). |
||
|
||
<div *ngFor="let log of logs" class="log-row" [ngClass]="{ error: log.level === 'error', warn: log.level === 'warn' }"> | ||
<span class="log-level">{{ log.level }}</span> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -763,6 +763,9 @@ instance: | |
securitytxt: | | ||
Contact: https://github.com/Chocobozzz/PeerTube/blob/develop/SECURITY.md | ||
Expires: 2025-12-31T11:00:00.000Z' | ||
logs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already have a log section: https://github.com/Chocobozzz/PeerTube/blob/develop/config/default.yaml#L230 Please also add this block to |
||
audit_logs: | ||
enabled: true | ||
|
||
services: | ||
# Cards configuration to format video in Twitter | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,41 @@ describe('Test logs', function () { | |
expect(logsString.includes('video 10')).to.be.true | ||
expect(logsString.includes('video 11')).to.be.false | ||
}) | ||
|
||
it('Should refuse to create logs if disabled', async function () { | ||
this.timeout(100000) | ||
|
||
await server.config.updateCustomSubConfig({ | ||
newConfig: { | ||
instance: { | ||
logs: { | ||
auditLogs:{ | ||
enabled: false | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
|
||
await server.videos.upload({ attributes: { name: 'video 12' } }) | ||
await waitJobs([ server ]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just upload one video to test audit logs. Test 403 if disabled, but also the audit log was not filled when it was disabled (so re-enable the feature and check the audit log doesn't contain your upload) |
||
|
||
const now1 = new Date() | ||
|
||
await server.videos.upload({ attributes: { name: 'video 13' } }) | ||
await waitJobs([ server ]) | ||
|
||
const now2 = new Date() | ||
|
||
await server.videos.upload({ attributes: { name: 'video 14' } }) | ||
await waitJobs([ server ]) | ||
|
||
await logsCommand.getAuditLogs({ | ||
startDate: now1, | ||
endDate: now2, | ||
expectedStatus: HttpStatusCode.FORBIDDEN_403 | ||
}) | ||
}) | ||
}) | ||
|
||
describe('When creating log from the client', function () { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove HTML comments