2022-04-29 18:12:35 +03:00
|
|
|
<!--
|
|
|
|
|
|
|
|
|
|
Copyright © 2016-2022 The Thingsboard Authors
|
|
|
|
|
|
|
|
|
|
Licensed 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.
|
|
|
|
|
|
|
|
|
|
-->
|
2022-04-28 23:03:37 +03:00
|
|
|
<div>
|
|
|
|
|
<mat-card class="settings-card">
|
|
|
|
|
<mat-card-title>
|
|
|
|
|
<div fxLayout="row">
|
|
|
|
|
<span class="mat-headline" translate>admin.2fa.2fa</span>
|
|
|
|
|
<span fxFlex></span>
|
|
|
|
|
<!-- <div tb-help="twoFactorAuthSettings"></div>-->
|
|
|
|
|
</div>
|
|
|
|
|
</mat-card-title>
|
|
|
|
|
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
|
|
|
|
|
</mat-progress-bar>
|
|
|
|
|
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
|
2022-05-16 17:21:04 +03:00
|
|
|
<mat-card-content>
|
2022-04-29 18:12:35 +03:00
|
|
|
<form [formGroup]="twoFaFormGroup" (ngSubmit)="save()">
|
|
|
|
|
<fieldset [disabled]="isLoading$ | async">
|
2022-05-27 16:02:32 +03:00
|
|
|
<div>
|
2022-05-19 15:04:15 +03:00
|
|
|
<fieldset class="fields-group" formArrayName="providers">
|
|
|
|
|
<legend class="group-title" translate>admin.2fa.available-providers</legend>
|
|
|
|
|
<ng-container *ngFor="let provider of providersForm.controls; let i = index; let $last = last; trackBy: trackByElement">
|
|
|
|
|
<mat-expansion-panel class="provider" [formGroupName]="i">
|
|
|
|
|
<mat-expansion-panel-header>
|
|
|
|
|
<mat-panel-title fxLayoutAlign="start center">
|
|
|
|
|
<mat-slide-toggle
|
2022-05-20 17:19:21 +03:00
|
|
|
(click)="toggleExtensionPanel($event, i, provider.get('enable').value)"
|
2022-05-19 15:04:15 +03:00
|
|
|
formControlName="enable">
|
|
|
|
|
</mat-slide-toggle>
|
2022-05-25 12:32:42 +03:00
|
|
|
{{ twoFactorAuthProvidersData.get(provider.value.providerType).name | translate }}
|
2022-05-19 15:04:15 +03:00
|
|
|
</mat-panel-title>
|
|
|
|
|
</mat-expansion-panel-header>
|
|
|
|
|
|
|
|
|
|
<ng-template matExpansionPanelContent>
|
|
|
|
|
<ng-container [ngSwitch]="provider.get('providerType').value">
|
|
|
|
|
<ng-container *ngSwitchCase="twoFactorAuthProviderType.TOTP">
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.issuer-name</mat-label>
|
|
|
|
|
<input matInput formControlName="issuerName" required>
|
2022-05-31 17:22:08 +03:00
|
|
|
<mat-error *ngIf="provider.get('issuerName').hasError('required') ||
|
|
|
|
|
provider.get('issuerName').hasError('pattern')">
|
2022-05-19 15:04:15 +03:00
|
|
|
{{ "admin.2fa.issuer-name-required" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</ng-container>
|
|
|
|
|
<div *ngSwitchCase="twoFactorAuthProviderType.SMS"
|
|
|
|
|
fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.verification-message-template</mat-label>
|
|
|
|
|
<input matInput formControlName="smsVerificationMessageTemplate" required>
|
|
|
|
|
<mat-error *ngIf="provider.get('smsVerificationMessageTemplate').hasError('required')">
|
|
|
|
|
{{ "admin.2fa.verification-message-template-required" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="provider.get('smsVerificationMessageTemplate').hasError('pattern')">
|
|
|
|
|
{{ "admin.2fa.verification-message-template-pattern" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.verification-code-lifetime</mat-label>
|
|
|
|
|
<input matInput formControlName="verificationCodeLifetime" type="number" step="1" min="1" required>
|
|
|
|
|
<mat-error *ngIf="provider.get('verificationCodeLifetime').hasError('required')">
|
|
|
|
|
{{ "admin.2fa.verification-code-lifetime-required" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="provider.get('verificationCodeLifetime').hasError('min') ||
|
|
|
|
|
provider.get('verificationCodeLifetime').hasError('pattern')">
|
|
|
|
|
{{ "admin.2fa.verification-code-lifetime-pattern" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
<div *ngSwitchCase="twoFactorAuthProviderType.EMAIL">
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.verification-code-lifetime</mat-label>
|
|
|
|
|
<input matInput formControlName="verificationCodeLifetime" type="number" step="1" min="1" required>
|
|
|
|
|
<mat-error *ngIf="provider.get('verificationCodeLifetime').hasError('required')">
|
|
|
|
|
{{ "admin.2fa.verification-code-lifetime-required" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="provider.get('verificationCodeLifetime').hasError('min') ||
|
|
|
|
|
provider.get('verificationCodeLifetime').hasError('pattern')">
|
|
|
|
|
{{ "admin.2fa.verification-code-lifetime-pattern" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
2022-05-25 12:32:42 +03:00
|
|
|
<div *ngSwitchCase="twoFactorAuthProviderType.BACKUP_CODE">
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.number-of-codes</mat-label>
|
|
|
|
|
<input matInput formControlName="codesQuantity" type="number" step="1" min="1" required>
|
|
|
|
|
<mat-error *ngIf="provider.get('codesQuantity').hasError('required')">
|
|
|
|
|
{{ "admin.2fa.number-of-codes-required" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="provider.get('codesQuantity').hasError('min') ||
|
|
|
|
|
provider.get('codesQuantity').hasError('pattern')">
|
|
|
|
|
{{ "admin.2fa.number-of-codes-pattern" | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
2022-05-19 15:04:15 +03:00
|
|
|
</ng-container>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</mat-expansion-panel>
|
|
|
|
|
<mat-divider *ngIf="!$last"></mat-divider>
|
|
|
|
|
</ng-container>
|
|
|
|
|
</fieldset>
|
2022-05-16 17:21:04 +03:00
|
|
|
<fieldset class="fields-group">
|
2022-05-18 10:27:59 +03:00
|
|
|
<legend class="group-title" translate>admin.2fa.verification-limitations</legend>
|
2022-05-18 17:49:25 +03:00
|
|
|
<div class="input-row" fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
|
2022-05-16 17:21:04 +03:00
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.total-allowed-time-for-verification</mat-label>
|
2022-05-31 17:22:08 +03:00
|
|
|
<input matInput required formControlName="totalAllowedTimeForVerification" type="number" step="1" min="60">
|
2022-05-16 17:21:04 +03:00
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('totalAllowedTimeForVerification').hasError('required')">
|
|
|
|
|
{{ 'admin.2fa.total-allowed-time-for-verification-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('totalAllowedTimeForVerification').hasError('pattern')
|
|
|
|
|
|| twoFaFormGroup.get('totalAllowedTimeForVerification').hasError('min')">
|
|
|
|
|
{{ 'admin.2fa.total-allowed-time-for-verification-pattern' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
2022-05-20 17:19:21 +03:00
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.retry-verification-code-period</mat-label>
|
|
|
|
|
<input matInput required formControlName="minVerificationCodeSendPeriod" type="number" step="1" min="5">
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('minVerificationCodeSendPeriod').hasError('required')">
|
|
|
|
|
{{ 'admin.2fa.retry-verification-code-period-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('minVerificationCodeSendPeriod').hasError('pattern')
|
|
|
|
|
|| twoFaFormGroup.get('minVerificationCodeSendPeriod').hasError('min')">
|
|
|
|
|
{{ 'admin.2fa.retry-verification-code-period-pattern' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
2022-05-16 17:21:04 +03:00
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.max-verification-failures-before-user-lockout</mat-label>
|
2022-05-26 13:59:53 +03:00
|
|
|
<input matInput formControlName="maxVerificationFailuresBeforeUserLockout" type="number" step="1" min="0" max="65535">
|
2022-05-16 17:21:04 +03:00
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('maxVerificationFailuresBeforeUserLockout').hasError('pattern')
|
|
|
|
|
|| twoFaFormGroup.get('maxVerificationFailuresBeforeUserLockout').hasError('min')
|
|
|
|
|
|| twoFaFormGroup.get('maxVerificationFailuresBeforeUserLockout').hasError('max')">
|
|
|
|
|
{{ 'admin.2fa.max-verification-failures-before-user-lockout-pattern' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
2022-05-20 17:19:21 +03:00
|
|
|
|
2022-05-18 17:49:25 +03:00
|
|
|
<mat-expansion-panel class="provider">
|
|
|
|
|
<mat-expansion-panel-header>
|
|
|
|
|
<mat-panel-title fxLayoutAlign="start center">
|
2022-05-25 12:32:42 +03:00
|
|
|
<mat-slide-toggle (click)="toggleExtensionPanel($event, providersForm.length, twoFaFormGroup.get('verificationCodeCheckRateLimitEnable').value)"
|
2022-05-18 17:49:25 +03:00
|
|
|
formControlName="verificationCodeCheckRateLimitEnable">
|
|
|
|
|
</mat-slide-toggle>
|
|
|
|
|
{{ 'admin.2fa.verification-code-check-rate-limit' | translate }}
|
|
|
|
|
</mat-panel-title>
|
|
|
|
|
</mat-expansion-panel-header>
|
|
|
|
|
<ng-template matExpansionPanelContent>
|
|
|
|
|
<div fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.number-of-checking-attempts</mat-label>
|
|
|
|
|
<input matInput formControlName="verificationCodeCheckRateLimitNumber" required type="number" step="1" min="1">
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('verificationCodeCheckRateLimitNumber').hasError('required')">
|
|
|
|
|
{{ 'admin.2fa.number-of-checking-attempts-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('verificationCodeCheckRateLimitNumber').hasError('pattern')
|
2022-05-16 17:21:04 +03:00
|
|
|
|| twoFaFormGroup.get('verificationCodeCheckRateLimitNumber').hasError('min')">
|
2022-05-18 17:49:25 +03:00
|
|
|
{{ 'admin.2fa.number-of-checking-attempts-pattern' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>admin.2fa.within-time</mat-label>
|
|
|
|
|
<input matInput formControlName="verificationCodeCheckRateLimitTime" required type="number" step="1" min="1">
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('verificationCodeCheckRateLimitTime').hasError('required')">
|
|
|
|
|
{{ 'admin.2fa.within-time-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="twoFaFormGroup.get('verificationCodeCheckRateLimitTime').hasError('pattern')
|
2022-05-16 17:21:04 +03:00
|
|
|
|| twoFaFormGroup.get('verificationCodeCheckRateLimitTime').hasError('min')">
|
2022-05-18 17:49:25 +03:00
|
|
|
{{ 'admin.2fa.within-time-pattern' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</mat-expansion-panel>
|
2022-05-16 17:21:04 +03:00
|
|
|
</fieldset>
|
2022-05-27 16:02:32 +03:00
|
|
|
</div>
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="end center" fxLayoutGap="8px">
|
|
|
|
|
<button mat-button mat-raised-button color="primary"
|
|
|
|
|
[disabled]="(isLoading$ | async) || twoFaFormGroup.invalid || !twoFaFormGroup.dirty"
|
|
|
|
|
type="submit">
|
|
|
|
|
{{'action.save' | translate}}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2022-04-29 18:12:35 +03:00
|
|
|
</fieldset>
|
2022-04-28 23:03:37 +03:00
|
|
|
</form>
|
|
|
|
|
</mat-card-content>
|
|
|
|
|
</mat-card>
|
|
|
|
|
</div>
|