You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by jx...@apache.org on 2018/10/18 00:53:46 UTC

[1/2] helix git commit: enforce login for all users

Repository: helix
Updated Branches:
  refs/heads/master 41ff38670 -> ca364aecf


enforce login for all users


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/17c5f9ca
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/17c5f9ca
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/17c5f9ca

Branch: refs/heads/master
Commit: 17c5f9cac1656d522f06e29f9baa1f499ecc96e0
Parents: 41ff386
Author: Vivo Xu <vx...@linkedin.com>
Authored: Mon Aug 27 14:04:21 2018 -0700
Committer: Vivo Xu <vx...@linkedin.com>
Committed: Wed Oct 17 14:20:18 2018 -0700

----------------------------------------------------------------------
 helix-front/client/app/app.component.ts |  3 +--
 helix-front/server/controllers/user.ts  | 18 +++++++-----------
 2 files changed, 8 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/17c5f9ca/helix-front/client/app/app.component.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/app.component.ts b/helix-front/client/app/app.component.ts
index 13d7426..06f7f5e 100644
--- a/helix-front/client/app/app.component.ts
+++ b/helix-front/client/app/app.component.ts
@@ -11,7 +11,6 @@ import { MatDialog } from '@angular/material';
 
 import { Angulartics2Piwik } from 'angulartics2';
 
-import { environment } from '../environments/environment';
 import { UserService } from './core/user.service';
 import { InputDialogComponent } from './shared/dialog/input-dialog/input-dialog.component';
 import { HelperService } from './shared/helper.service';
@@ -67,7 +66,7 @@ export class AppComponent implements OnInit {
     this.dialog
       .open(InputDialogComponent, {
         data: {
-          title: 'Login',
+          title: 'Sign In',
           message: 'Please enter your LDAP username and password to continue:',
           values: {
             username: {

http://git-wip-us.apache.org/repos/asf/helix/blob/17c5f9ca/helix-front/server/controllers/user.ts
----------------------------------------------------------------------
diff --git a/helix-front/server/controllers/user.ts b/helix-front/server/controllers/user.ts
index 21e1b0f..980d97c 100644
--- a/helix-front/server/controllers/user.ts
+++ b/helix-front/server/controllers/user.ts
@@ -14,24 +14,20 @@ export class UserCtrl {
     router.route('/user/can').get(this.can);
   }
 
-  // please rewrite this function to support your own authorization logic
   protected authorize(req: Request, res: Response) {
-    if (req.query.name) {
-      // since it's bypass mode, skip admin check
-      req.session.username = req.query.name;
 
-      if (req.query.url) {
-        res.redirect(req.query.url);
-      } else {
-        res.redirect('/');
-      }
+    // you can rewrite this function to support your own authorization logic
+    // by default, doing nothing but redirection
+
+    if (req.query.url) {
+      res.redirect(req.query.url);
     } else {
-      res.status(401).send('Unauthorized');
+      res.redirect('/');
     }
   }
 
   protected current(req: Request, res: Response) {
-    res.json(req.session.username || 'Guest');
+    res.json(req.session.username || 'Sign In');
   }
 
   protected can(req: Request, res: Response) {


[2/2] helix git commit: Add maintenance mode support

Posted by jx...@apache.org.
Add maintenance mode support


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/ca364aec
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/ca364aec
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/ca364aec

Branch: refs/heads/master
Commit: ca364aecf4815d6dbd24e15499343469f24ceee8
Parents: 17c5f9c
Author: Vivo Xu <vx...@linkedin.com>
Authored: Thu Sep 6 15:34:02 2018 -0700
Committer: Vivo Xu <vx...@linkedin.com>
Committed: Wed Oct 17 14:20:22 2018 -0700

----------------------------------------------------------------------
 .../cluster-detail.component.html               |  9 +++++
 .../cluster-detail/cluster-detail.component.ts  | 35 ++++++++++++++++++++
 .../client/app/cluster/shared/cluster.model.ts  |  2 ++
 .../app/cluster/shared/cluster.service.ts       | 12 +++++++
 4 files changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/ca364aec/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
----------------------------------------------------------------------
diff --git a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
index e0fe3ac..3176ef7 100644
--- a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
+++ b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
@@ -3,6 +3,7 @@
     <mat-toolbar-row>
       <hi-detail-header [cluster]="clusterName"></hi-detail-header>
       <hi-disabled-label *ngIf="!cluster?.enabled" text="DISABLED"></hi-disabled-label>
+      <hi-disabled-label *ngIf="cluster?.inMaintenance" text="In Maintenance Mode"></hi-disabled-label>
     </mat-toolbar-row>
     <mat-toolbar-row class="information">
       <mat-spinner *ngIf="isLoading" diameter="30"></mat-spinner>
@@ -18,6 +19,14 @@
           <mat-icon>settings_input_antenna</mat-icon>
           <span>Activate this Cluster</span>
         </button>
+        <button mat-menu-item *ngIf="!cluster?.inMaintenance" (click)="enableMaintenanceMode()">
+          <mat-icon>music_off</mat-icon>
+          <span>Enable maintenance mode</span>
+        </button>
+        <button mat-menu-item *ngIf="cluster?.inMaintenance" (click)="disableMaintenanceMode()">
+          <mat-icon>music_note</mat-icon>
+          <span>Disable maintenance mode</span>
+        </button>
         <button mat-menu-item *ngIf="cluster?.enabled" (click)="disableCluster()">
           <mat-icon>not_interested</mat-icon>
           <span>Disable this Cluster</span>

http://git-wip-us.apache.org/repos/asf/helix/blob/ca364aec/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
index 0fbc0c1..323af7b 100644
--- a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
+++ b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
@@ -156,6 +156,41 @@ export class ClusterDetailComponent implements OnInit {
       });
   }
 
+  enableMaintenanceMode() {
+    this.dialog
+      .open(InputDialogComponent, {
+        data: {
+          title: 'Enable maintenance mode',
+          message: 'What reason do you want to use to put the cluster in maintenance mode?',
+          values: {
+            reason: {
+              label: 'reason'
+            }
+          }
+        }
+      })
+      .afterClosed()
+      .subscribe(result => {
+        if (result && result.reason.value) {
+          this.clusterService
+            .enableMaintenanceMode(this.clusterName, result.reason.value)
+            .subscribe(
+              () => this.loadCluster(),
+              error => this.helperService.showError(error)
+            );
+        }
+      });
+  }
+
+  disableMaintenanceMode() {
+    this.clusterService
+      .disableMaintenanceMode(this.clusterName)
+      .subscribe(
+        () => this.loadCluster(),
+        error => this.helperService.showError(error)
+      );
+  }
+
   deleteCluster() {
     this.helperService
       .showConfirmation('Are you sure you want to delete this cluster?')

http://git-wip-us.apache.org/repos/asf/helix/blob/ca364aec/helix-front/client/app/cluster/shared/cluster.model.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/cluster/shared/cluster.model.ts b/helix-front/client/app/cluster/shared/cluster.model.ts
index 1519c6e..0ac9402 100644
--- a/helix-front/client/app/cluster/shared/cluster.model.ts
+++ b/helix-front/client/app/cluster/shared/cluster.model.ts
@@ -6,6 +6,7 @@ export class Cluster {
   readonly controller: string;
   readonly enabled: boolean;
   readonly instances: Instance[];
+  readonly inMaintenance: boolean;
 
   // TODO vxu: Resources are useless here. Remove it please.
   readonly resources: string[];
@@ -20,6 +21,7 @@ export class Cluster {
     this.controller = obj.controller;
     this.enabled = !obj.paused;
     this.resources = obj.resources;
+    this.inMaintenance = obj.maintenance;
 
     let ins: Instance[] = [];
     for (let instance of obj.instances) {

http://git-wip-us.apache.org/repos/asf/helix/blob/ca364aec/helix-front/client/app/cluster/shared/cluster.service.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/cluster/shared/cluster.service.ts b/helix-front/client/app/cluster/shared/cluster.service.ts
index 43b1c8f..05e047f 100644
--- a/helix-front/client/app/cluster/shared/cluster.service.ts
+++ b/helix-front/client/app/cluster/shared/cluster.service.ts
@@ -49,4 +49,16 @@ export class ClusterService extends HelixService {
     return this
       .post(`/clusters/${ name }?command=activate&superCluster=${ superCluster }`, null);
   }
+
+  public enableMaintenanceMode(name: string, reason: string) {
+    return this
+      .post(`/clusters/${ name }?command=enableMaintenanceMode`, JSON.stringify({
+        reason: reason
+      }));
+  }
+
+  public disableMaintenanceMode(name: string) {
+    return this
+      .post(`/clusters/${ name }?command=disableMaintenanceMode`, null);
+  }
 }