diff --git a/bitwarden_license/src/app/providers/clients/clients.component.ts b/bitwarden_license/src/app/providers/clients/clients.component.ts index 91e1edda..312fec54 100644 --- a/bitwarden_license/src/app/providers/clients/clients.component.ts +++ b/bitwarden_license/src/app/providers/clients/clients.component.ts @@ -20,10 +20,10 @@ import { ProviderUserType } from 'jslib-common/enums/providerUserType'; import { ValidationService } from 'jslib-angular/services/validation.service'; +import { Organization } from 'jslib-common/models/domain/organization'; import { ProviderOrganizationOrganizationDetailsResponse } from 'jslib-common/models/response/provider/providerOrganizationResponse'; -import { Organization } from 'jslib-common/models/domain/organization'; import { ModalComponent } from 'src/app/modal.component'; @@ -88,7 +88,7 @@ export class ClientsComponent implements OnInit { .map(o => o.id)); this.addableOrganizations = candidateOrgs.filter(o => allowedOrgsIds.includes(o.id)); - this.showAddExisting = this.addableOrganizations.length != 0; + this.showAddExisting = this.addableOrganizations.length !== 0; this.loading = false; } diff --git a/bitwarden_license/src/app/providers/setup/setup.component.ts b/bitwarden_license/src/app/providers/setup/setup.component.ts index 6a4ef1f0..7c5fe481 100644 --- a/bitwarden_license/src/app/providers/setup/setup.component.ts +++ b/bitwarden_license/src/app/providers/setup/setup.component.ts @@ -63,7 +63,7 @@ export class SetupComponent implements OnInit { this.providerId = qParams.providerId; this.token = qParams.token; - + // Check if provider exists, redirect if it does try { const provider = await this.apiService.getProvider(this.providerId); diff --git a/jslib b/jslib index 1f012796..add4b2f3 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 1f0127966e85aa29f9e50144de9b2a03b00de5d4 +Subproject commit add4b2f3e9d85a4a68d67a0da09be14cefe9a6b3 diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2922cf09..9d3207e4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -46,8 +46,19 @@ import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.serv import { ConstantsService } from 'jslib-common/services/constants.service'; +import { PolicyListService } from './services/policy-list.service'; import { RouterService } from './services/router.service'; +import { DisableSendPolicy } from './organizations/policies/disable-send.component'; +import { MasterPasswordPolicy } from './organizations/policies/master-password.component'; +import { PasswordGeneratorPolicy } from './organizations/policies/password-generator.component'; +import { PersonalOwnershipPolicy } from './organizations/policies/personal-ownership.component'; +import { RequireSsoPolicy } from './organizations/policies/require-sso.component'; +import { ResetPasswordPolicy } from './organizations/policies/reset-password.component'; +import { SendOptionsPolicy } from './organizations/policies/send-options.component'; +import { SingleOrgPolicy } from './organizations/policies/single-org.component'; +import { TwoFactorAuthenticationPolicy } from './organizations/policies/two-factor-authentication.component'; + const BroadcasterSubscriptionId = 'AppComponent'; const IdleTimeout = 60000 * 10; // 10 minutes @@ -56,6 +67,7 @@ const IdleTimeout = 60000 * 10; // 10 minutes templateUrl: 'app.component.html', }) export class AppComponent implements OnDestroy, OnInit { + toasterConfig: ToasterConfig = new ToasterConfig({ showCloseButton: true, mouseoverTimerStop: true, @@ -80,7 +92,7 @@ export class AppComponent implements OnDestroy, OnInit { private sanitizer: DomSanitizer, private searchService: SearchService, private notificationsService: NotificationsService, private routerService: RouterService, private stateService: StateService, private eventService: EventService, - private policyService: PolicyService) { } + private policyService: PolicyService, protected policyListService: PolicyListService) { } ngOnInit() { this.ngZone.runOutsideAngular(() => { @@ -170,6 +182,18 @@ export class AppComponent implements OnDestroy, OnInit { } }); + this.policyListService.addPolicies([ + new TwoFactorAuthenticationPolicy(), + new MasterPasswordPolicy(), + new PasswordGeneratorPolicy(), + new SingleOrgPolicy(), + new RequireSsoPolicy(), + new PersonalOwnershipPolicy(), + new DisableSendPolicy(), + new SendOptionsPolicy(), + new ResetPasswordPolicy(), + ]); + this.setFullWidth(); } diff --git a/src/app/organizations/manage/policies.component.html b/src/app/organizations/manage/policies.component.html index 77626cf3..a2dcc9a7 100644 --- a/src/app/organizations/manage/policies.component.html +++ b/src/app/organizations/manage/policies.component.html @@ -1,8 +1,3 @@ - -

{{'webPoliciesDeprecationWarning' | i18n}}

- -
@@ -13,10 +8,10 @@ - diff --git a/src/app/organizations/manage/policies.component.ts b/src/app/organizations/manage/policies.component.ts index e27ea292..7801d9e6 100644 --- a/src/app/organizations/manage/policies.component.ts +++ b/src/app/organizations/manage/policies.component.ts @@ -12,8 +12,8 @@ import { import { PolicyType } from 'jslib-common/enums/policyType'; -import { EnvironmentService } from 'jslib-common/abstractions'; import { ApiService } from 'jslib-common/abstractions/api.service'; +import { EnvironmentService } from 'jslib-common/abstractions/environment.service'; import { I18nService } from 'jslib-common/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; import { UserService } from 'jslib-common/abstractions/user.service'; @@ -22,8 +22,13 @@ import { PolicyResponse } from 'jslib-common/models/response/policyResponse'; import { ModalComponent } from '../../modal.component'; +import { Organization } from 'jslib-common/models/domain/organization'; + import { PolicyEditComponent } from './policy-edit.component'; +import { PolicyListService } from 'src/app/services/policy-list.service'; +import { BasePolicy } from '../policies/base-policy.component'; + @Component({ selector: 'app-org-policies', templateUrl: 'policies.component.html', @@ -33,11 +38,11 @@ export class PoliciesComponent implements OnInit { loading = true; organizationId: string; - policies: any[]; + policies: BasePolicy[]; + organization: Organization; // Remove when removing deprecation warning enterpriseTokenPromise: Promise; - userCanAccessBusinessPortal = false; private enterpriseUrl: string; @@ -48,81 +53,20 @@ export class PoliciesComponent implements OnInit { constructor(private apiService: ApiService, private route: ActivatedRoute, private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver, private platformUtilsService: PlatformUtilsService, private userService: UserService, - private router: Router, private environmentService: EnvironmentService) { } + private policyListService: PolicyListService, private router: Router, + private environmentService: EnvironmentService) { } async ngOnInit() { this.route.parent.parent.params.subscribe(async params => { this.organizationId = params.organizationId; - const organization = await this.userService.getOrganization(this.organizationId); - if (organization == null || !organization.usePolicies) { + this.organization = await this.userService.getOrganization(this.organizationId); + if (this.organization == null || !this.organization.usePolicies) { this.router.navigate(['/organizations', this.organizationId]); return; } - this.userCanAccessBusinessPortal = organization.canAccessBusinessPortal; - this.policies = [ - { - name: this.i18nService.t('twoStepLogin'), - description: this.i18nService.t('twoStepLoginPolicyDesc'), - type: PolicyType.TwoFactorAuthentication, - enabled: false, - display: true, - }, - { - name: this.i18nService.t('masterPass'), - description: this.i18nService.t('masterPassPolicyDesc'), - type: PolicyType.MasterPassword, - enabled: false, - display: true, - }, - { - name: this.i18nService.t('passwordGenerator'), - description: this.i18nService.t('passwordGeneratorPolicyDesc'), - type: PolicyType.PasswordGenerator, - enabled: false, - display: true, - }, - { - name: this.i18nService.t('singleOrg'), - description: this.i18nService.t('singleOrgDesc'), - type: PolicyType.SingleOrg, - enabled: false, - display: true, - }, - { - name: this.i18nService.t('requireSso'), - description: this.i18nService.t('requireSsoPolicyDesc'), - type: PolicyType.RequireSso, - enabled: false, - display: organization.useSso, - }, - { - name: this.i18nService.t('personalOwnership'), - description: this.i18nService.t('personalOwnershipPolicyDesc'), - type: PolicyType.PersonalOwnership, - enabled: false, - display: true, - }, - { - name: this.i18nService.t('disableSend'), - description: this.i18nService.t('disableSendPolicyDesc'), - type: PolicyType.DisableSend, - enabled: false, - display: true, - }, - { - name: this.i18nService.t('sendOptions'), - description: this.i18nService.t('sendOptionsPolicyDesc'), - type: PolicyType.SendOptions, - enabled: false, - display: true, - }, { - name: this.i18nService.t('resetPasswordPolicy'), - description: this.i18nService.t('resetPasswordPolicyDescription'), - type: PolicyType.ResetPassword, - enabled: false, - display: organization.useResetPassword, - }, - ]; + + this.policies = this.policyListService.getPolicies(); + await this.load(); // Handle policies component launch from Event message @@ -158,13 +102,11 @@ export class PoliciesComponent implements OnInit { this.orgPolicies.forEach(op => { this.policiesEnabledMap.set(op.type, op.enabled); }); - this.policies.forEach(p => { - p.enabled = this.policiesEnabledMap.has(p.type) && this.policiesEnabledMap.get(p.type); - }); + this.loading = false; } - edit(p: any) { + edit(policy: BasePolicy) { if (this.modal != null) { this.modal.close(); } @@ -174,9 +116,7 @@ export class PoliciesComponent implements OnInit { const childComponent = this.modal.show( PolicyEditComponent, this.editModalRef); - childComponent.name = p.name; - childComponent.description = p.description; - childComponent.type = p.type; + childComponent.policy = policy; childComponent.organizationId = this.organizationId; childComponent.policiesEnabledMap = this.policiesEnabledMap; childComponent.onSavedPolicy.subscribe(() => { diff --git a/src/app/organizations/manage/policy-edit.component.html b/src/app/organizations/manage/policy-edit.component.html index 1e038d79..6207b596 100644 --- a/src/app/organizations/manage/policy-edit.component.html +++ b/src/app/organizations/manage/policy-edit.component.html @@ -2,178 +2,21 @@
- {{p.name}} - {{'enabled' | i18n}} - {{p.description}} + + {{p.name | i18n}} + {{'enabled' | i18n}} + {{p.description | i18n}}