You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dg...@apache.org on 2020/06/26 15:26:46 UTC

[incubator-dlab] branch DLAB-1896 created (now f92bc60)

This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a change to branch DLAB-1896
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.


      at f92bc60  [DLAB-1896]: Added audit guard

This branch includes the following new commits:

     new 8bc89c5  [DLAB-1896]: Hide audit in navbar if value of 'auditEnabled' is false
     new f92bc60  [DLAB-1896]: Added audit guard

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 02/02: [DLAB-1896]: Added audit guard

Posted by dg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DLAB-1896
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit f92bc6054101a0c51c44765e278f511efe8c7f68
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Fri Jun 26 18:24:37 2020 +0300

    [DLAB-1896]: Added audit guard
---
 .../resources/webapp/src/app/app.routing.module.ts |  4 +--
 .../resources/webapp/src/app/core/core.module.ts   |  2 ++
 .../webapp/src/app/core/services/audit.guard.ts    | 31 +++++++++++++++++++++
 .../src/app/core/services/healthStatus.service.ts  |  4 +++
 .../webapp/src/app/core/services/index.ts          |  1 +
 .../audit/audit-grid/audit-grid.component.scss     |  4 +--
 .../bucket-browser/bucket-browser.component.ts     |  2 +-
 .../bucket-browser/bucket-data.service.ts          | 32 +++++++++++-----------
 8 files changed, 59 insertions(+), 21 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts b/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
index b8792e5..81663d4 100644
--- a/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
@@ -33,7 +33,7 @@ import { ProjectComponent } from './administration/project/project.component';
 import { RolesComponent } from './administration/roles/roles.component';
 import { SwaggerComponent } from './swagger/swagger.component';
 
-import { AuthorizationGuard, CheckParamsGuard, CloudProviderGuard, AdminGuard } from './core/services';
+import { AuthorizationGuard, CheckParamsGuard, CloudProviderGuard, AdminGuard, AuditGuard } from './core/services';
 import {AuditComponent} from './reports/audit/audit.component';
 
 const routes: Routes = [{
@@ -84,7 +84,7 @@ const routes: Routes = [{
     {
       path: 'audit',
       component: AuditComponent,
-      canActivate: [AuthorizationGuard, AdminGuard],
+      canActivate: [AuthorizationGuard, AuditGuard],
     },
   ]
 }, {
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts b/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts
index f815c70..84fc615 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts
@@ -48,6 +48,7 @@ import { NoCacheInterceptor } from './interceptors/nocache.interceptor';
 import { ErrorInterceptor } from './interceptors/error.interceptor';
 
 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import {AuditGuard} from './services';
 
 @NgModule({
   imports: [CommonModule],
@@ -65,6 +66,7 @@ export class CoreModule {
         ApplicationSecurityService,
         AuthorizationGuard,
         AdminGuard,
+        AuditGuard,
         CloudProviderGuard,
         CheckParamsGuard,
         AppRoutingService,
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/audit.guard.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/audit.guard.ts
new file mode 100644
index 0000000..ef61d05
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/audit.guard.ts
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
+import { HealthStatusService } from './healthStatus.service';
+
+@Injectable()
+export class AuditGuard implements CanActivate {
+  constructor(private _healthStatus: HealthStatusService) { }
+
+  canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
+    return this._healthStatus.isPassageway('audit');
+  }
+}
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts
index 12086bc..02004f3 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts
@@ -119,6 +119,10 @@ export class HealthStatusService {
               this.appRoutingService.redirectToHomePage();
               return false;
             }
+            if (parameter === 'audit' && !data.auditEnabled) {
+              this.appRoutingService.redirectToHomePage();
+              return false;
+            }
             if (parameter === 'administration' && !data.admin && !data.projectAdmin) {
               this.appRoutingService.redirectToNoAccessPage();
               return false;
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/index.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/index.ts
index 0068a29..2005741 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/index.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/index.ts
@@ -26,6 +26,7 @@ export * from './userResource.service';
 export * from './authorization.guard';
 export * from './admin.guard';
 export * from './cloudProvider.guard';
+export * from './audit.guard';
 export * from './checkParams.guard';
 export * from './librariesInstallation.service';
 export * from './manageUngit.service';
diff --git a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
index 125a404..f1c1df0 100644
--- a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
+++ b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
@@ -32,7 +32,7 @@
 
     tr {
       .th_user {
-        width: 19%;
+        width: 15%;
       }
 
       .th_action {
@@ -48,7 +48,7 @@
       }
 
       .th_resource{
-        width: 11%;
+        width: 14%;
       }
 
       .th_resource-type{
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts
index 2485a40..d3c4c73 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.ts
@@ -62,7 +62,7 @@ export class BucketBrowserComponent implements OnInit {
   public isFilterVisible: boolean;
   public buckets;
   public isFileUploading: boolean;
-  public uploadingQueueLength: number = 5;
+  public uploadingQueueLength: number = 4;
   public maxFileSize: number = 4294967296;
 
   @ViewChild(FolderTreeComponent, {static: true}) folderTreeComponent;
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-data.service.ts b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-data.service.ts
index 9eed7a9..d0ce7b9 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-data.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-data.service.ts
@@ -23,7 +23,7 @@ import {BucketBrowserService, TodoItemNode} from '../../core/services/bucket-bro
 
 
 const array = [{'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'folder11/', 'size': '18 bytes', 'lastModifiedDate': '21-4-2020 11:36:36'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'folder11/dsafaraorueajkegrgavhsfnvgahsfgsdjfhagsdjfg497frgfhsdajfsgdafjsxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzdvcfdvbgffgsdfgdsafaraorueajkegrgavhsfnvgahsfgsdjfhagsdjfg497frgfhsdajfsgdafjsxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzdvcfdvbgffgsdfgdsfgsdfgggggg', ' [...]
-{'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '3.jpg', 'size': '5 bytes', 'lastModifiedDate': '14-4-2020 09:36:16'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '2.jpg', 'size': '52 bytes', 'lastModifiedDate': '17-4-2020 12:13:26'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '1test', 'size': '112 bytes', 'lastModifiedDate': '14-4-2020 04:55:02'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'test.pem', 'size': '1 KB', 'lastModifiedDate': '14-4-2020 04:57 [...]
+{'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '<script>alert("hello")' + ' </script>', 'size': '5 bytes', 'lastModifiedDate': '14-4-2020 09:36:16'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '2.jpg', 'size': '52 bytes', 'lastModifiedDate': '17-4-2020 12:13:26'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '1test', 'size': '112 bytes', 'lastModifiedDate': '14-4-2020 04:55:02'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'test.pem', 'size': '1 KB', 'las [...]
 {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': '5.jpg', 'size': '52 bytes', 'lastModifiedDate': '17-4-2020 12:13:26'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'test', 'size': '12 bytes', 'lastModifiedDate': '14-4-2020 04:55:02'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'test.pem', 'size': '1 KB', 'lastModifiedDate': '14-4-2020 04:57:54'}, {'bucket': 'ofuks-1304-prj1-local-bucket', 'object': 'test1', 'size': '52 bytes', 'lastModifiedDate': '17-4-2020 11:22: [...]
 
 @Injectable()
@@ -39,21 +39,21 @@ export class BucketDataService {
 
   public refreshBucketdata(bucket, endpoint) {
     let backetData = [];
-    this.bucketBrowserService.getBucketData(bucket, endpoint).subscribe(v => {
-      const copiedData = JSON.parse(JSON.stringify(v));
-
-      this.serverData = v;
-      if (this.emptyFolder) {
-        copiedData.unshift(this.emptyFolder);
-      }
-      backetData = this.convertToFolderTree(copiedData);
-      const data = this.buildFileTree({[bucket]: backetData}, 0);
-      this._bucketData.next(data);
-    });
-    // this.serverData = array;
-    // backetData = this.convertToFolderTree(array);
-    // const data = this.buildFileTree({[bucket]: backetData}, 0);
-    // this._bucketData.next(data);
+    // this.bucketBrowserService.getBucketData(bucket, endpoint).subscribe(v => {
+    //   const copiedData = JSON.parse(JSON.stringify(v));
+    //
+    //   this.serverData = v;
+    //   if (this.emptyFolder) {
+    //     copiedData.unshift(this.emptyFolder);
+    //   }
+    //   backetData = this.convertToFolderTree(copiedData);
+    //   const data = this.buildFileTree({[bucket]: backetData}, 0);
+    //   this._bucketData.next(data);
+    // });
+    this.serverData = array;
+    backetData = this.convertToFolderTree(array);
+    const data = this.buildFileTree({[bucket]: backetData}, 0);
+    this._bucketData.next(data);
   }
 
   public buildFileTree(obj: {[key: string]: any}, level: number): TodoItemNode[] {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 01/02: [DLAB-1896]: Hide audit in navbar if value of 'auditEnabled' is false

Posted by dg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DLAB-1896
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 8bc89c57a1c532d757b19d834d608e19858c4817
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Fri Jun 26 15:55:30 2020 +0300

    [DLAB-1896]: Hide audit in navbar if value of 'auditEnabled' is false
---
 .../webapp/src/app/administration/management/management.model.ts      | 1 +
 .../src/app/resources/bucket-browser/bucket-browser.component.html    | 2 --
 .../src/main/resources/webapp/src/app/shared/navbar/index.ts          | 2 +-
 .../main/resources/webapp/src/app/shared/navbar/navbar.component.html | 4 ++--
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
index 6b0f600..4387884 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
@@ -71,6 +71,7 @@ export class BackupOptionsModel {
 
 export interface GeneralEnvironmentStatus {
   admin: boolean;
+  auditEnabled: boolean;
   projectAdmin: boolean;
   billingEnabled: boolean;
   billingQuoteUsed: number;
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.html
index 9dfa1fb..449445f 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/bucket-browser/bucket-browser.component.html
@@ -190,7 +190,6 @@
               </div>
               <div class="size">{{file.object?.size | convertFileSize}}</div>
               <div class="date" *ngIf="!file.isDownloading">{{convertDate(file.object?.lastModifiedDate) | date: 'dd/MM/yyyy hh:mm:ss aa'  }}</div>
-<!--              <div class="date" *ngIf="!file.isDownloading">{{file.object?.lastModifiedDate }}</div>-->
               <div class="progress-wrapper" *ngIf="file.isDownloading">
                 <div class="progres">
                   <span class="progress-bar-text">{{file.progress || 0}}% Downloading...</span>
@@ -215,7 +214,6 @@
         <span class="close" matTooltip="Upload is still in progress, please wait." matTooltipPosition="above" [ngClass]="{'not-allow': isFileUploading}" [matTooltipDisabled]="!isFileUploading">
            <button type="button" class="close" (click)="closeUploadWindow()" [disabled]="isFileUploading" [ngClass]="{'not-allow': isFileUploading}" >&times;</button>
         </span>
-
       </header>
       <ul class="upload-files">
         <li class="file upload-table-header" *ngIf="addedFiles.length">
diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts
index 7a6f2d4..65cf645 100644
--- a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts
@@ -25,7 +25,7 @@ import { ProgressDialogModule, BubbleModule } from '../index';
 
 import { NavbarComponent } from './navbar.component';
 import { NotificationDialogModule } from '../modal-dialog/notification-dialog';
-import {EdgeActionDialogModule} from "../modal-dialog/edge-action-dialog";
+import {EdgeActionDialogModule} from '../modal-dialog/edge-action-dialog';
 
 export * from './navbar.component';
 
diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
index 8f6a8ca..f24a29f 100644
--- a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
@@ -95,14 +95,14 @@
               <ng-template #env><i class="material-icons">settings</i></ng-template>
             </a>
           </a>
-          <a class="nav-item has-children" *ngIf="healthStatus?.billingEnabled || true">
+          <a class="nav-item has-children" *ngIf="healthStatus?.billingEnabled || healthStatus?.auditEnabled">
             <span *ngIf="isExpanded">Reports</span>
             <a *ngIf="healthStatus?.billingEnabled" class="sub-nav-item" [routerLink]="['/billing_report']"
               [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}" [style.margin-left.px]="isExpanded ? '30' : '0'">
               <span *ngIf="isExpanded; else billing">Billing</span>
               <ng-template #billing><i class="material-icons">account_balance_wallet</i></ng-template>
             </a>
-            <a  class="sub-nav-item" [routerLink]="['/audit']" [style.margin-left.px]="isExpanded ? '30' : '0'"
+            <a *ngIf="healthStatus?.auditEnabled" class="sub-nav-item" [routerLink]="['/audit']" [style.margin-left.px]="isExpanded ? '30' : '0'"
                [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
               <span *ngIf="isExpanded; else audit">Audit</span>
               <ng-template #audit><i class="material-icons">library_books</i></ng-template>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org