-
- {{ 'ORG.POLICY.DATA.DESCRIPTION' | translate }}
-
-
{{'ORG.POLICY.DATA.MINLENGTH' | translate}}
@@ -54,7 +54,7 @@
-
\ No newline at end of file
diff --git a/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.scss b/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.scss
index 3e48cbe4cd..a80b1ae8f7 100644
--- a/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.scss
+++ b/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.scss
@@ -1,3 +1,8 @@
+.default {
+ color: #5282c1;
+ margin-top: 0;
+}
+
.content {
padding-top: 1rem;
display: flex;
@@ -7,10 +12,9 @@
.row {
display: flex;
align-items: center;
- padding: .5rem 0;
+ padding: .3rem 0;
.left-desc {
- color: var(--grey);
font-size: .9rem;
}
@@ -21,6 +25,7 @@
.length-wrapper {
display: flex;
align-items: center;
+ margin-right: -.6rem;
}
}
}
diff --git a/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.ts b/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.ts
index 4cc5c6c47d..d559f97745 100644
--- a/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.ts
+++ b/console/src/app/modules/policies/password-complexity-policy/password-complexity-policy.component.ts
@@ -1,17 +1,14 @@
-import { Component, OnDestroy } from '@angular/core';
-import { ActivatedRoute, Router } from '@angular/router';
+import { Component, Injector, OnDestroy, Type } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { switchMap } from 'rxjs/operators';
-import {
- OrgIamPolicy,
- PasswordAgePolicy,
- PasswordComplexityPolicy,
- PasswordLockoutPolicy,
-} from 'src/app/proto/generated/management_pb';
+import { DefaultPasswordComplexityPolicy } from 'src/app/proto/generated/admin_pb';
+import { PasswordComplexityPolicyView } from 'src/app/proto/generated/management_pb';
+import { AdminService } from 'src/app/services/admin.service';
import { ManagementService } from 'src/app/services/mgmt.service';
import { ToastService } from 'src/app/services/toast.service';
-import { PolicyComponentAction } from '../policy-component-action.enum';
+import { PolicyComponentServiceType } from '../policy-component-types.enum';
@Component({
selector: 'app-password-policy',
@@ -19,37 +16,37 @@ import { PolicyComponentAction } from '../policy-component-action.enum';
styleUrls: ['./password-complexity-policy.component.scss'],
})
export class PasswordComplexityPolicyComponent implements OnDestroy {
- public title: string = '';
- public desc: string = '';
+ public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
+ public service!: ManagementService | AdminService;
- componentAction: PolicyComponentAction = PolicyComponentAction.CREATE;
-
- public PolicyComponentAction: any = PolicyComponentAction;
-
- public complexityData!: PasswordComplexityPolicy.AsObject;
+ public complexityData!: PasswordComplexityPolicyView.AsObject | DefaultPasswordComplexityPolicy.AsObject;
private sub: Subscription = new Subscription();
-
+ public PolicyComponentServiceType: any = PolicyComponentServiceType;
constructor(
private route: ActivatedRoute,
- private mgmtService: ManagementService,
- private router: Router,
private toast: ToastService,
+ private injector: Injector,
) {
this.sub = this.route.data.pipe(switchMap(data => {
- this.componentAction = data.action;
- return this.route.params;
- })).subscribe(params => {
- this.title = 'ORG.POLICY.PWD_COMPLEXITY.TITLECREATE';
- this.desc = 'ORG.POLICY.PWD_COMPLEXITY.DESCRIPTIONCREATE';
+ this.serviceType = data.serviceType;
- if (this.componentAction === PolicyComponentAction.MODIFY) {
- this.getData(params).then(data => {
- if (data) {
- this.complexityData = data.toObject() as PasswordComplexityPolicy.AsObject;
- }
- });
+ switch (this.serviceType) {
+ case PolicyComponentServiceType.MGMT:
+ this.service = this.injector.get(ManagementService as Type
);
+ break;
+ case PolicyComponentServiceType.ADMIN:
+ this.service = this.injector.get(AdminService as Type);
+ break;
}
+
+ return this.route.params;
+ })).subscribe(() => {
+ this.getData().then(data => {
+ if (data) {
+ this.complexityData = data.toObject();
+ }
+ });
});
}
@@ -57,19 +54,27 @@ export class PasswordComplexityPolicyComponent implements OnDestroy {
this.sub.unsubscribe();
}
- private async getData(params: any):
- Promise {
- this.title = 'ORG.POLICY.PWD_COMPLEXITY.TITLE';
- this.desc = 'ORG.POLICY.PWD_COMPLEXITY.DESCRIPTION';
- return this.mgmtService.GetPasswordComplexityPolicy();
+ private async getData():
+ Promise {
+ switch (this.serviceType) {
+ case PolicyComponentServiceType.MGMT:
+ return (this.service as ManagementService).GetPasswordComplexityPolicy();
+ case PolicyComponentServiceType.ADMIN:
+ return (this.service as AdminService).GetDefaultPasswordComplexityPolicy();
+ }
}
- public deletePolicy(): void {
- this.mgmtService.DeletePasswordComplexityPolicy(this.complexityData.id).then(() => {
- this.toast.showInfo('Successfully deleted');
- }).catch(error => {
- this.toast.showError(error);
- });
+ public removePolicy(): void {
+ if (this.service instanceof ManagementService) {
+ this.service.removePasswordComplexityPolicy().then(() => {
+ this.toast.showInfo('ORG.POLICY.TOAST.RESETSUCCESS', true);
+ setTimeout(() => {
+ this.getData();
+ }, 1000);
+ }).catch(error => {
+ this.toast.showError(error);
+ });
+ }
}
public incrementLength(): void {
@@ -85,35 +90,56 @@ export class PasswordComplexityPolicyComponent implements OnDestroy {
}
public savePolicy(): void {
- if (this.componentAction === PolicyComponentAction.CREATE) {
+ switch (this.serviceType) {
+ case PolicyComponentServiceType.MGMT:
+ if ((this.complexityData as PasswordComplexityPolicyView.AsObject).pb_default) {
+ (this.service as ManagementService).CreatePasswordComplexityPolicy(
- this.mgmtService.CreatePasswordComplexityPolicy(
- this.complexityData.description,
- this.complexityData.hasLowercase,
- this.complexityData.hasUppercase,
- this.complexityData.hasNumber,
- this.complexityData.hasSymbol,
- this.complexityData.minLength,
- ).then(() => {
- this.router.navigate(['org']);
- }).catch(error => {
- this.toast.showError(error);
- });
+ this.complexityData.hasLowercase,
+ this.complexityData.hasUppercase,
+ this.complexityData.hasNumber,
+ this.complexityData.hasSymbol,
+ this.complexityData.minLength,
+ ).then(() => {
+ this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
+ }).catch(error => {
+ this.toast.showError(error);
+ });
+ } else {
+ (this.service as ManagementService).UpdatePasswordComplexityPolicy(
+ this.complexityData.hasLowercase,
+ this.complexityData.hasUppercase,
+ this.complexityData.hasNumber,
+ this.complexityData.hasSymbol,
+ this.complexityData.minLength,
+ ).then(() => {
+ this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
+ }).catch(error => {
+ this.toast.showError(error);
+ });
+ }
+ break;
+ case PolicyComponentServiceType.ADMIN:
+ (this.service as AdminService).UpdateDefaultPasswordComplexityPolicy(
+ this.complexityData.hasLowercase,
+ this.complexityData.hasUppercase,
+ this.complexityData.hasNumber,
+ this.complexityData.hasSymbol,
+ this.complexityData.minLength,
+ ).then(() => {
+ this.toast.showInfo('ORG.POLICY.TOAST.SET', true);
+ }).catch(error => {
+ this.toast.showError(error);
+ });
+ break;
+ }
+ }
- } else if (this.componentAction === PolicyComponentAction.MODIFY) {
-
- this.mgmtService.UpdatePasswordComplexityPolicy(
- this.complexityData.description,
- this.complexityData.hasLowercase,
- this.complexityData.hasUppercase,
- this.complexityData.hasNumber,
- this.complexityData.hasSymbol,
- this.complexityData.minLength,
- ).then(() => {
- this.router.navigate(['org']);
- }).catch(error => {
- this.toast.showError(error);
- });
+ public get isDefault(): boolean {
+ if (this.complexityData && this.serviceType === PolicyComponentServiceType.MGMT) {
+ return (this.complexityData as PasswordComplexityPolicyView.AsObject).pb_default;
+ } else {
+ return false;
}
}
}
diff --git a/console/src/app/modules/policies/password-iam-policy/password-iam-policy-routing.module.ts b/console/src/app/modules/policies/password-iam-policy/password-iam-policy-routing.module.ts
deleted file mode 100644
index c0c86d4d2d..0000000000
--- a/console/src/app/modules/policies/password-iam-policy/password-iam-policy-routing.module.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
-
-import { PolicyComponentAction } from '../policy-component-action.enum';
-import { PasswordIamPolicyComponent } from './password-iam-policy.component';
-
-const routes: Routes = [
- {
- path: '',
- component: PasswordIamPolicyComponent,
- data: {
- animation: 'DetailPage',
- action: PolicyComponentAction.MODIFY,
- },
- },
- {
- path: 'create',
- component: PasswordIamPolicyComponent,
- data: {
- animation: 'DetailPage',
- action: PolicyComponentAction.CREATE,
- },
- },
-];
-
-@NgModule({
- imports: [RouterModule.forChild(routes)],
- exports: [RouterModule],
-})
-export class PasswordIamPolicyRoutingModule { }
diff --git a/console/src/app/modules/policies/password-iam-policy/password-iam-policy.component.html b/console/src/app/modules/policies/password-iam-policy/password-iam-policy.component.html
deleted file mode 100644
index 5ef10571fc..0000000000
--- a/console/src/app/modules/policies/password-iam-policy/password-iam-policy.component.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
- {{ 'ORG.POLICY.DATA.DESCRIPTION' | translate }}
-
-
-
- {{'ORG.POLICY.DATA.USERLOGINMUSTBEDOMAIN' | translate}}
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/console/src/app/modules/policies/password-iam-policy/password-iam-policy.component.ts b/console/src/app/modules/policies/password-iam-policy/password-iam-policy.component.ts
deleted file mode 100644
index cf8eb91648..0000000000
--- a/console/src/app/modules/policies/password-iam-policy/password-iam-policy.component.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import { Component, OnDestroy } from '@angular/core';
-import { ActivatedRoute, Router } from '@angular/router';
-import { Subscription } from 'rxjs';
-import { switchMap } from 'rxjs/operators';
-import {
- OrgIamPolicy,
- PasswordAgePolicy,
- PasswordComplexityPolicy,
- PasswordLockoutPolicy,
-} from 'src/app/proto/generated/management_pb';
-import { AdminService } from 'src/app/services/admin.service';
-import { ManagementService } from 'src/app/services/mgmt.service';
-import { StorageService } from 'src/app/services/storage.service';
-import { ToastService } from 'src/app/services/toast.service';
-
-import { PolicyComponentAction } from '../policy-component-action.enum';
-
-@Component({
- selector: 'app-password-iam-policy',
- templateUrl: './password-iam-policy.component.html',
- styleUrls: ['./password-iam-policy.component.scss'],
-})
-export class PasswordIamPolicyComponent implements OnDestroy {
- public title: string = '';
- public desc: string = '';
-
- componentAction: PolicyComponentAction = PolicyComponentAction.CREATE;
-
- public PolicyComponentAction: any = PolicyComponentAction;
-
- public iamData!: OrgIamPolicy.AsObject;
-
- private sub: Subscription = new Subscription();
-
- constructor(
- private route: ActivatedRoute,
- private mgmtService: ManagementService,
- private adminService: AdminService,
- private router: Router,
- private toast: ToastService,
- private sessionStorage: StorageService,
- ) {
- this.sub = this.route.data.pipe(switchMap(data => {
- this.componentAction = data.action;
- console.log(data.action);
- return this.route.params;
- })).subscribe(params => {
- this.title = 'ORG.POLICY.IAM_POLICY.TITLECREATE';
- this.desc = 'ORG.POLICY.IAM_POLICY.DESCRIPTIONCREATE';
-
- if (this.componentAction === PolicyComponentAction.MODIFY) {
- this.getData(params).then(data => {
- if (data) {
- this.iamData = data.toObject() as OrgIamPolicy.AsObject;
- }
- });
- }
- });
- }
-
- public ngOnDestroy(): void {
- this.sub.unsubscribe();
- }
-
- private async getData(params: any):
- Promise {
-
- this.title = 'ORG.POLICY.IAM_POLICY.TITLECREATE';
- this.desc = 'ORG.POLICY.IAM_POLICY.DESCRIPTIONCREATE';
- return this.mgmtService.GetMyOrgIamPolicy();
- }
-
- public savePolicy(): void {
- if (this.componentAction === PolicyComponentAction.CREATE) {
- const orgId = this.sessionStorage.getItem('organization');
- if (orgId) {
- this.adminService.CreateOrgIamPolicy(
- orgId,
- this.iamData.description,
- this.iamData.userLoginMustBeDomain,
- ).then(() => {
- this.router.navigate(['org']);
- }).catch(error => {
- this.toast.showError(error);
- });
- }
- } else if (this.componentAction === PolicyComponentAction.MODIFY) {
- const orgId = this.sessionStorage.getItem('organization');
- if (orgId) {
- this.adminService.UpdateOrgIamPolicy(
- orgId,
- this.iamData.description,
- this.iamData.userLoginMustBeDomain,
- ).then(() => {
- this.router.navigate(['org']);
- }).catch(error => {
- this.toast.showError(error);
- });
- }
- }
- }
-}
diff --git a/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy-routing.module.ts b/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy-routing.module.ts
index 61e1cfdec2..1572a12262 100644
--- a/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy-routing.module.ts
+++ b/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy-routing.module.ts
@@ -1,7 +1,6 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
-import { PolicyComponentAction } from '../policy-component-action.enum';
import { PasswordLockoutPolicyComponent } from './password-lockout-policy.component';
const routes: Routes = [
@@ -10,15 +9,6 @@ const routes: Routes = [
component: PasswordLockoutPolicyComponent,
data: {
animation: 'DetailPage',
- action: PolicyComponentAction.MODIFY,
- },
- },
- {
- path: 'create',
- component: PasswordLockoutPolicyComponent,
- data: {
- animation: 'DetailPage',
- action: PolicyComponentAction.CREATE,
},
},
];
diff --git a/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy.component.html b/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy.component.html
index af366cf470..9633d01002 100644
--- a/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy.component.html
+++ b/console/src/app/modules/policies/password-lockout-policy/password-lockout-policy.component.html
@@ -1,17 +1,16 @@
-
-
-