Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/add-documentation-to-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
mongodb-version: [ 7.0.21 ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-after-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
mongodb-version: [ 7.0.21 ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
mongodb-version: [7.0.21]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-schedule-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
mongodb-version: [ 7.0.21 ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-schedule-vm0033.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
mongodb-version: [ 7.0.21 ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flow-pull-request-formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: guardian-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand All @@ -46,7 +46,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
node-version: [ 20.19.5 ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
mongodb-version: [7.0.21]
steps:
- name: Harden Runner
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit

Expand Down
7 changes: 4 additions & 3 deletions api-gateway/src/api/service/worker-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ApiExtraModels, ApiInternalServerErrorResponse, ApiOkResponse, ApiOpera
import { Auth, AuthUser } from '#auth';
import { Examples, InternalServerErrorDTO, pageHeader, WorkersTasksDTO } from '#middlewares';
import { IAuthUser } from '@guardian/common';
import { Permissions } from '@guardian/interfaces';
import { Guardians, parseInteger } from '#helpers';

@Controller('worker-tasks')
Expand All @@ -12,7 +13,7 @@ export class WorkerTasksController {
* Get all notifications
*/
@Get('/')
@Auth()
@Auth(Permissions.WORKER_TASKS_READ)
@ApiOperation({
summary: 'Get all worker tasks',
description: 'Returns all worker tasks.',
Expand Down Expand Up @@ -62,7 +63,7 @@ export class WorkerTasksController {
res.header('X-Total-Count', count).send(tasks);
}

@Auth()
@Auth(Permissions.WORKER_TASKS_EXECUTE)
@ApiOperation({
summary: 'Restart task',
description: 'Restart task'
Expand All @@ -85,7 +86,7 @@ export class WorkerTasksController {
await guardians.restartTask(body.taskId, user.id.toString());
}

@Auth()
@Auth(Permissions.WORKER_TASKS_DELETE)
@ApiOperation({
summary: 'Delete task',
description: 'Delete task'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,20 @@ const routes: Routes = [
{ path: 'register', component: RegisterComponent },
{ path: 'task/:id', component: AsyncProgressComponent },
{ path: 'notifications', component: NotificationsComponent },
{ path: 'worker-tasks', component: WorkerTasksComponent },

{
path: 'worker-tasks',
component: WorkerTasksComponent,
canActivate: [PermissionsGuard],
data: {
roles: [
UserRole.STANDARD_REGISTRY,
UserRole.USER
],
permissions: [
Permissions.WORKER_TASKS_READ
]
}
},
{
path: 'user-profile',
component: UserProfileComponent,
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/app/utils/permissions-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export const entityNames = new Map<PermissionEntities, string>([
[PermissionEntities.ROLE, 'Role'],
[PermissionEntities.STATISTIC, 'Statistic'],
[PermissionEntities.LABEL, 'Label'],
[PermissionEntities.FORMULA, 'Formula']
[PermissionEntities.FORMULA, 'Formula'],
[PermissionEntities.WORKER_TASK, 'Worker Task']
])

export const actionIndexes = new Map<PermissionActions, number>([
Expand Down Expand Up @@ -171,7 +172,8 @@ export const categoryNames = new Map<PermissionCategories, string>([
[PermissionCategories.PERMISSIONS, 'Permissions'],
[PermissionCategories.STATISTICS, 'Policy Statistics'],
[PermissionCategories.FORMULAS, 'Formulas'],
[PermissionCategories.ACCESS, 'Access']
[PermissionCategories.ACCESS, 'Access'],
[PermissionCategories.WORKER_TASKS, 'Worker Tasks'],
])

export const actionName = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
</div>
</div>
<div
*ngIf="user.WORKER_TASKS_READ"
[class.current]="activeLink.startsWith('/worker-tasks')"
[routerLink]="'/worker-tasks'"
class="item cursor-pointer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ <h1>Worker Tasks</h1>
<td class="col-ACTION">
<div class="operations-container">
<button
*ngIf="user.WORKER_TASKS_EXECUTE"
(click)="restartTask(task)"
[disabled]="!(task.isError && task.isRetryableTask)"
class="p-button-raised p-button-rounded p-button-text"
icon="pi pi-undo"
pButton type="button"></button>
<button
*ngIf="user.WORKER_TASKS_DELETE"
(click)="deleteTask(task)"
[disabled]="!task.isError"
class="p-button-raised p-button-rounded p-button-text"
Expand Down
22 changes: 15 additions & 7 deletions frontend/src/app/views/worker-tasks/worker-tasks.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { HttpResponse } from '@angular/common/http';
import { WorkerTasksService } from '../../services/worker-tasks.service';
import { forkJoin } from 'rxjs';
import { ProfileService } from 'src/app/services/profile.service';
import { UserPermissions } from '@guardian/interfaces';

/**
* Notifications
Expand All @@ -12,6 +15,7 @@ import { WorkerTasksService } from '../../services/worker-tasks.service';
})
export class WorkerTasksComponent implements OnInit {
public loading: boolean = true;
public user: UserPermissions = new UserPermissions();
public workerTasks: any[] = [];
public workerTasksCount: any;
public workerTasksColumns: string[] = ['type', 'operations'];
Expand All @@ -37,6 +41,7 @@ export class WorkerTasksComponent implements OnInit {

constructor(
private tasksService: WorkerTasksService,
private profileService: ProfileService,
) {
this.pageIndex = 0;
this.pageSize = 10;
Expand All @@ -48,13 +53,16 @@ export class WorkerTasksComponent implements OnInit {

private loadWorkerTasks() {
this.loading = true;
const request = this.tasksService.all(
this.pageIndex,
this.pageSize,
this.currentStatus
);
request.subscribe(
(notificationsResponse: HttpResponse<any[]>) => {
forkJoin([
this.profileService.getProfile(),
this.tasksService.all(
this.pageIndex,
this.pageSize,
this.currentStatus
)
]).subscribe(
([profile, notificationsResponse]) => {
this.user = new UserPermissions(profile)
this.workerTasks = notificationsResponse.body || [];
this.workerTasksCount =
notificationsResponse.headers.get('X-Total-Count') ||
Expand Down
Loading
Loading