@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
2,754 lines • 394 kB
JavaScript
import * as i0 from '@angular/core';
import { Input, Component, Injectable, EventEmitter, NgModule, Output, inject, ChangeDetectorRef, ElementRef, Renderer2, TemplateRef, ContentChild, ViewChild } from '@angular/core';
import * as i2 from '@c8y/ngx-components';
import { FormGroupComponent, C8yTranslatePipe, Permissions, C8yTranslateDirective, RequiredInputPlaceholderDirective, MinValidationDirective, MaxValidationDirective, MessagesComponent, MessageDirective, TitleComponent, BreadcrumbComponent, BreadcrumbItemComponent, ActionBarItemComponent, IconDirective, HelpComponent, CoreModule, hookRoute, DefaultValidationDirective, memoize, SelectLegacyComponent, MoNamePipe, EmptyStateComponent, Status, NavigatorNode, hookTab, hookNavigator, hookPatternMessages } from '@c8y/ngx-components';
import * as i1$1 from '@c8y/client';
import { TenantLoginOptionType, TfaStrategy, GrantType, UserManagementSource } from '@c8y/client';
import * as i1 from '@angular/forms';
import { NgForm, ControlContainer, FormsModule } from '@angular/forms';
import * as i1$2 from '@angular/common';
import { NgIf, NgFor, NgSwitch, NgSwitchCase, NgClass, AsyncPipe, KeyValuePipe } from '@angular/common';
import { PopoverDirective, PopoverModule } from 'ngx-bootstrap/popover';
import { map, catchError, tap, switchMap, shareReplay, publishReplay, refCount, take, mapTo, mergeAll, toArray } from 'rxjs/operators';
import { forkJoin, from, of, BehaviorSubject, defer, throwError, Subject, EMPTY, merge } from 'rxjs';
import { isString, omit, defaults, omitBy, isEmpty, cloneDeep, isFinite, pickBy, identity, map as map$1, pick, findKey, has, get, reduce, pull, defaultsDeep, at, head, reject, isUndefined } from 'lodash-es';
import { gettext } from '@c8y/ngx-components/gettext';
import * as i2$1 from '@ngx-translate/core';
import { TooltipDirective, TooltipModule } from 'ngx-bootstrap/tooltip';
import * as i1$4 from 'ngx-bootstrap/collapse';
import { CollapseDirective, CollapseModule } from 'ngx-bootstrap/collapse';
import { HttpStatusCode } from '@angular/common/http';
import { __decorate, __metadata } from 'tslib';
import * as i4 from 'ngx-bootstrap/pagination';
import { PaginationModule } from 'ngx-bootstrap/pagination';
import * as i1$3 from 'ngx-bootstrap/modal';
import { AssetSelectorComponent, AssetSelectorModule } from '@c8y/ngx-components/assets-navigator';
import { BsDatepickerInputDirective, BsDatepickerDirective, BsDatepickerModule } from 'ngx-bootstrap/datepicker';
import * as i1$5 from '@angular/router';
class UserAgent {
constructor(value) {
this._id = this.uniqueId();
this.value = value;
}
get id() {
return this._id;
}
uniqueId() {
const dateString = Date.now().toString(36);
const randomString = Math.random().toString(36).substr(2);
return dateString + randomString;
}
}
function isOauthInternal(tenantLoginOption) {
return tenantLoginOption.type === TenantLoginOptionType.OAUTH2_INTERNAL;
}
function isBasic(tenantLoginOption) {
return tenantLoginOption.type === TenantLoginOptionType.BASIC;
}
class BasicAuthSettingsComponent {
constructor(controlContainer) {
this.controlContainer = controlContainer;
this.preferredLoginOptionType = TenantLoginOptionType.BASIC;
this.tenantLoginOptionTypeEnum = TenantLoginOptionType;
}
ngOnChanges(changes) {
if (changes.authConfiguration && changes.authConfiguration.currentValue) {
this.preferredLoginOptionType =
changes.authConfiguration.currentValue.preferredLoginOptionType;
}
}
ngDoCheck() {
if (this.preferredLoginOptionType !== this.authConfiguration.preferredLoginOptionType) {
this.preferredLoginOptionType = this.authConfiguration.preferredLoginOptionType;
if (this.preferredLoginOptionType === TenantLoginOptionType.BASIC) {
this.forbiddenWebBrowsers = false;
}
}
}
get forbiddenWebBrowsers() {
return this.authenticationRestrictions.forbiddenClients.includes('WEB_BROWSERS');
}
set forbiddenWebBrowsers(value) {
this.authenticationRestrictions.forbiddenClients = value ? ['WEB_BROWSERS'] : [];
}
forbiddenUserAgentsRemove(id) {
this.authenticationRestrictions.forbiddenUserAgents = this.remove(this.authenticationRestrictions.forbiddenUserAgents, id);
this.controlContainer.control.markAsDirty();
}
trustedUserAgentsRemove(id) {
this.authenticationRestrictions.trustedUserAgents = this.remove(this.authenticationRestrictions.trustedUserAgents, id);
this.controlContainer.control.markAsDirty();
}
get authenticationRestrictions() {
return this.authConfiguration.loginOptions.find(isBasic).authenticationRestrictions;
}
add(collection) {
collection.push(new UserAgent(''));
}
remove(collection, id) {
const newArray = collection.filter(obj => obj.id !== id);
if (!newArray.length) {
newArray.push(new UserAgent(''));
}
return newArray;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicAuthSettingsComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: BasicAuthSettingsComponent, isStandalone: true, selector: "c8y-basic-auth-settings", inputs: { authConfiguration: "authConfiguration" }, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"card-block separator-top\"\n *ngIf=\"authConfiguration.preferredLoginOptionType !== 'BASIC'\"\n>\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ 'Basic Auth restrictions' | translate }}\n </div>\n </div>\n\n <div class=\"col-sm-9\">\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"c8y-switch\" title=\"{{ 'Forbidden for web browsers' | translate }}\">\n <input type=\"checkbox\" name=\"forbiddenWebBrowsers\" [(ngModel)]=\"forbiddenWebBrowsers\" />\n <span></span>\n <span>{{ 'Forbidden for web browsers' | translate }}</span>\n </label>\n <div\n class=\"alert alert-warning\"\n *ngIf=\"\n preferredLoginOptionType === tenantLoginOptionTypeEnum.BASIC && forbiddenWebBrowsers\n \"\n >\n {{\n 'You are about to forbid browsers from using Basic authentication. This will prevent users from using web applications on your tenant because you are going to set Basic authentication as the preferred login mode.'\n | translate\n }}\n </div>\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <label title=\"{{ 'Forbidden user agents' | translate }}\">\n {{ 'Forbidden user agents' | translate }}\n </label>\n <div\n class=\"input-group m-t-8\"\n *ngFor=\"\n let forbiddenUserAgent of authenticationRestrictions.forbiddenUserAgents;\n last as isLast;\n first as isFirst\n \"\n >\n <input\n type=\"text\"\n [name]=\"'forbiddenUserAgent' + forbiddenUserAgent.id\"\n [(ngModel)]=\"forbiddenUserAgent.value\"\n class=\"form-control\"\n data-cy=\"c8y-basic-auth--forbidden-agent\"\n placeholder=\"{{ 'e.g.' | translate }} forbidden-agent\"\n />\n <div class=\"input-group-btn col-sm-2\">\n <button\n *ngIf=\"!(isFirst && isLast && forbiddenUserAgent.value === '')\"\n title=\"{{ 'Remove' | translate }}\"\n [name]=\"'forbiddenUserAgentRemove' + forbiddenUserAgent.id\"\n type=\"button\"\n class=\"btn btn-dot text-primary\"\n (click)=\"forbiddenUserAgentsRemove(forbiddenUserAgent.id)\"\n >\n <i class=\"dlt-c8y-icon-minus-circle text-danger\"></i>\n </button>\n <button\n title=\"{{ 'Add' | translate }}\"\n type=\"button\"\n class=\"btn btn-dot text-primary\"\n (click)=\"add(authenticationRestrictions.forbiddenUserAgents)\"\n *ngIf=\"isLast\"\n >\n <i class=\"dlt-c8y-icon-plus-circle\"></i>\n </button>\n </div>\n </div>\n </div>\n <div class=\"col-sm-6\">\n <label title=\"{{ 'Trusted user agents' | translate }}\">\n {{ 'Trusted user agents' | translate }}\n </label>\n <div\n class=\"input-group m-t-8\"\n *ngFor=\"\n let trustedUserAgent of authenticationRestrictions.trustedUserAgents;\n last as isLast;\n first as isFirst\n \"\n >\n <input\n type=\"text\"\n [name]=\"'trustedUserAgent' + trustedUserAgent.id\"\n class=\"form-control\"\n placeholder=\"{{ 'e.g.' | translate }} trusted-agent\"\n data-cy=\"c8y-basic-auth--trusted-agent\"\n [(ngModel)]=\"trustedUserAgent.value\"\n />\n <div class=\"input-group-btn col-sm-2\">\n <button\n *ngIf=\"!(isFirst && isLast && trustedUserAgent.value === '')\"\n title=\"{{ 'Remove' | translate }}\"\n [name]=\"'trustedUserAgentRemove' + trustedUserAgent.id\"\n type=\"button\"\n class=\"btn btn-dot btn-dot--danger text-primary\"\n (click)=\"trustedUserAgentsRemove(trustedUserAgent.id)\"\n >\n <i class=\"dlt-c8y-icon-minus-circle\"></i>\n </button>\n <button\n title=\"{{ 'Add' | translate }}\"\n type=\"button\"\n (click)=\"add(authenticationRestrictions.trustedUserAgents)\"\n class=\"btn btn-dot text-primary\"\n *ngIf=\"isLast\"\n >\n <i class=\"dlt-c8y-icon-plus-circle\"></i>\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicAuthSettingsComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-basic-auth-settings', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [NgIf, FormGroupComponent, FormsModule, NgFor, C8yTranslatePipe], template: "<div\n class=\"card-block separator-top\"\n *ngIf=\"authConfiguration.preferredLoginOptionType !== 'BASIC'\"\n>\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ 'Basic Auth restrictions' | translate }}\n </div>\n </div>\n\n <div class=\"col-sm-9\">\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"c8y-switch\" title=\"{{ 'Forbidden for web browsers' | translate }}\">\n <input type=\"checkbox\" name=\"forbiddenWebBrowsers\" [(ngModel)]=\"forbiddenWebBrowsers\" />\n <span></span>\n <span>{{ 'Forbidden for web browsers' | translate }}</span>\n </label>\n <div\n class=\"alert alert-warning\"\n *ngIf=\"\n preferredLoginOptionType === tenantLoginOptionTypeEnum.BASIC && forbiddenWebBrowsers\n \"\n >\n {{\n 'You are about to forbid browsers from using Basic authentication. This will prevent users from using web applications on your tenant because you are going to set Basic authentication as the preferred login mode.'\n | translate\n }}\n </div>\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <label title=\"{{ 'Forbidden user agents' | translate }}\">\n {{ 'Forbidden user agents' | translate }}\n </label>\n <div\n class=\"input-group m-t-8\"\n *ngFor=\"\n let forbiddenUserAgent of authenticationRestrictions.forbiddenUserAgents;\n last as isLast;\n first as isFirst\n \"\n >\n <input\n type=\"text\"\n [name]=\"'forbiddenUserAgent' + forbiddenUserAgent.id\"\n [(ngModel)]=\"forbiddenUserAgent.value\"\n class=\"form-control\"\n data-cy=\"c8y-basic-auth--forbidden-agent\"\n placeholder=\"{{ 'e.g.' | translate }} forbidden-agent\"\n />\n <div class=\"input-group-btn col-sm-2\">\n <button\n *ngIf=\"!(isFirst && isLast && forbiddenUserAgent.value === '')\"\n title=\"{{ 'Remove' | translate }}\"\n [name]=\"'forbiddenUserAgentRemove' + forbiddenUserAgent.id\"\n type=\"button\"\n class=\"btn btn-dot text-primary\"\n (click)=\"forbiddenUserAgentsRemove(forbiddenUserAgent.id)\"\n >\n <i class=\"dlt-c8y-icon-minus-circle text-danger\"></i>\n </button>\n <button\n title=\"{{ 'Add' | translate }}\"\n type=\"button\"\n class=\"btn btn-dot text-primary\"\n (click)=\"add(authenticationRestrictions.forbiddenUserAgents)\"\n *ngIf=\"isLast\"\n >\n <i class=\"dlt-c8y-icon-plus-circle\"></i>\n </button>\n </div>\n </div>\n </div>\n <div class=\"col-sm-6\">\n <label title=\"{{ 'Trusted user agents' | translate }}\">\n {{ 'Trusted user agents' | translate }}\n </label>\n <div\n class=\"input-group m-t-8\"\n *ngFor=\"\n let trustedUserAgent of authenticationRestrictions.trustedUserAgents;\n last as isLast;\n first as isFirst\n \"\n >\n <input\n type=\"text\"\n [name]=\"'trustedUserAgent' + trustedUserAgent.id\"\n class=\"form-control\"\n placeholder=\"{{ 'e.g.' | translate }} trusted-agent\"\n data-cy=\"c8y-basic-auth--trusted-agent\"\n [(ngModel)]=\"trustedUserAgent.value\"\n />\n <div class=\"input-group-btn col-sm-2\">\n <button\n *ngIf=\"!(isFirst && isLast && trustedUserAgent.value === '')\"\n title=\"{{ 'Remove' | translate }}\"\n [name]=\"'trustedUserAgentRemove' + trustedUserAgent.id\"\n type=\"button\"\n class=\"btn btn-dot btn-dot--danger text-primary\"\n (click)=\"trustedUserAgentsRemove(trustedUserAgent.id)\"\n >\n <i class=\"dlt-c8y-icon-minus-circle\"></i>\n </button>\n <button\n title=\"{{ 'Add' | translate }}\"\n type=\"button\"\n (click)=\"add(authenticationRestrictions.trustedUserAgents)\"\n class=\"btn btn-dot text-primary\"\n *ngIf=\"isLast\"\n >\n <i class=\"dlt-c8y-icon-plus-circle\"></i>\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }], propDecorators: { authConfiguration: [{
type: Input
}] } });
class AuthConfigurationGuard {
constructor(permissions) {
this.permissions = permissions;
}
canActivate() {
return this.permissions.hasAnyRole([
Permissions.ROLE_TENANT_ADMIN,
Permissions.ROLE_TENANT_MANAGEMENT_ADMIN
]);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationGuard, deps: [{ token: i2.Permissions }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationGuard }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationGuard, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i2.Permissions }] });
class TypedOption {
constructor(category, key, type, defaultValue, value) {
this.category = category;
this.key = key;
this.type = type;
this.defaultValue = defaultValue;
this.value = value;
}
apply(option) {
this.category = option.category;
this.key = option.key;
this.value = option.value;
}
getValue() {
try {
return this.getValueByType();
}
catch (ex) {
return this.defaultValue;
}
}
getValueByType() {
switch (this.type) {
case 'boolean':
return this.value.toLowerCase() === 'true';
case 'number':
return this.parseNumberValue(this.value);
case 'string':
return this.parseStringValue(this.value);
default:
throw new TypeError();
}
}
parseNumberValue(stringValue) {
const value = Number.parseInt(stringValue, 10);
if (typeof value !== 'number' || isNaN(value)) {
throw new Error();
}
return value;
}
parseStringValue(value) {
if (!isString(value)) {
throw new Error();
}
return value;
}
}
class TenantLoginOptionMapper {
mapTo(tenantLoginOption) {
const loginOption = omit(this.prapareTenantLoginOption(tenantLoginOption), 'authenticationRestrictions');
if (isBasic(loginOption)) {
loginOption.authenticationRestrictions = this.mapAuthenticationRestrictionsTo(tenantLoginOption.authenticationRestrictions);
}
return loginOption;
}
mapFrom(originalLoginOption, newLoginOption) {
if (isBasic(originalLoginOption)) {
return this.mapBasicLoginOption(originalLoginOption, newLoginOption);
}
if (isOauthInternal(originalLoginOption)) {
return this.mapOauthInternalLoginOption(originalLoginOption, newLoginOption);
}
throw new Error(`TenantLoginOptionMapper: The tenant login option cannot be mapped. Login option with type: ${originalLoginOption.type} is not supported.`);
}
mapAuthenticationRestrictionsTo(authenticationRestrictions) {
const restrictions = defaults({}, omitBy(authenticationRestrictions, isEmpty), {
forbiddenUserAgents: [''],
trustedUserAgents: [''],
forbiddenClients: []
});
restrictions.forbiddenUserAgents = restrictions.forbiddenUserAgents.map(val => new UserAgent(val));
restrictions.trustedUserAgents = restrictions.trustedUserAgents.map(val => new UserAgent(val));
return restrictions;
}
mapBasicLoginOption(originalLoginOption, newLoginOption) {
const loginOption = omit(originalLoginOption, ['sessionConfiguration']);
loginOption.authenticationRestrictions = this.mapAuthenticationRestrictionsFrom(newLoginOption.authenticationRestrictions);
return loginOption;
}
mapOauthInternalLoginOption(originalLoginOption, newLoginOption) {
const loginOption = omit(originalLoginOption, ['authenticationRestrictions']);
newLoginOption.sessionConfiguration !== null
? (loginOption.sessionConfiguration = newLoginOption.sessionConfiguration)
: delete loginOption.sessionConfiguration;
return loginOption;
}
mapAuthenticationRestrictionsFrom(authenticationRestrictions) {
return {
trustedUserAgents: authenticationRestrictions.trustedUserAgents
.filter(({ value }) => value)
.map(({ value }) => value),
forbiddenUserAgents: authenticationRestrictions.forbiddenUserAgents
.filter(({ value }) => value)
.map(({ value }) => value),
forbiddenClients: authenticationRestrictions.forbiddenClients.filter(value => value)
};
}
prapareTenantLoginOption(tenantLoginOption) {
return omit(tenantLoginOption, [
'self',
'strengthValidity',
'tfaStrategy',
'greenMinLength',
'enforceStrength',
'strengthValidity',
'_type'
]);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TenantLoginOptionMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TenantLoginOptionMapper, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TenantLoginOptionMapper, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
class AuthConfigurationService {
constructor(tenantLoginOptionsService, tenantOptionsService, systemOptionsService, appState, tenantUiService, tenantLoginOptionMapper, tenantService) {
this.tenantLoginOptionsService = tenantLoginOptionsService;
this.tenantOptionsService = tenantOptionsService;
this.systemOptionsService = systemOptionsService;
this.appState = appState;
this.tenantUiService = tenantUiService;
this.tenantLoginOptionMapper = tenantLoginOptionMapper;
this.tenantService = tenantService;
this.systemOptionsWithDefaultValue = [
new TypedOption('password', 'limit.validity', 'number', null),
new TypedOption('password', 'enforce.strength', 'boolean', false),
new TypedOption('two-factor-authentication', 'tenant-scope-settings.enabled', 'boolean', false),
new TypedOption('two-factor-authentication', 'enabled', 'boolean', false),
// note: this definition is inconsistent with backend and is overridden in getSystemOptions$
new TypedOption('two-factor-authentication', 'enforced', 'boolean', false),
new TypedOption('two-factor-authentication', 'enforced.group', 'string', '')
];
this.tenantOptionsWithDefaultValue = [
new TypedOption('password', 'limit.validity', 'number', 0),
new TypedOption('password', 'strength.validity', 'boolean', false),
new TypedOption('two-factor-authentication', 'enabled', 'boolean', false),
new TypedOption('two-factor-authentication', 'token.validity', 'number', 43200), // 30 days
new TypedOption('two-factor-authentication', 'pin.validity', 'number', 30),
new TypedOption('two-factor-authentication', 'enforced', 'boolean', false),
new TypedOption('two-factor-authentication', 'strategy', 'string', 'SMS'),
new TypedOption('oauth.internal', 'basic-token.lifespan.seconds', 'number', null),
new TypedOption('configuration', 'tenant.login.ignore-case', 'boolean', false)
];
}
getAuthConfiguration$() {
const loginOptions$ = this.getLoginOptions$();
return forkJoin({
loginOptions: this.map(loginOptions$),
tenantOptions: this.getTenantOptions$(),
systemOptions: this.getSystemOptions$(),
smsGatewayAvailable: this.isSmsApplicationAvailable$(),
preferredLoginOptionType: this.getPreferredLoginOptionType$(loginOptions$)
});
}
save(newAuthConfiguration, previousAuthConfiguration) {
const tenantOptions = this.prepareTenantOptions(newAuthConfiguration, previousAuthConfiguration);
const updateTenantOptions = tenantOptions.map(tenantOption => {
const fixedOption = this.fixTfaStrategy(tenantOption);
if (fixedOption) {
return fixedOption;
}
return this.tenantOptionsService.create(tenantOption);
});
const basicLoginOption = this.prepareBasicLoginOption(newAuthConfiguration, previousAuthConfiguration);
const oauthInternalLoginOption = this.prepareOauthInternalLoginOption(newAuthConfiguration, previousAuthConfiguration);
return Promise.all([
this.saveOrUpdateLoginOption(basicLoginOption),
this.saveOrUpdateLoginOption(oauthInternalLoginOption),
...updateTenantOptions
]);
}
map(loginOptions$) {
return loginOptions$.pipe(map(loginOptions => loginOptions.map(loginOption => this.tenantLoginOptionMapper.mapTo(loginOption))));
}
saveOrUpdateLoginOption(loginOption) {
return loginOption.id
? this.tenantLoginOptionsService.update(loginOption)
: this.tenantLoginOptionsService.create(loginOption);
}
prepareBasicLoginOption(newAuthConfiguration, previousAuthConfiguration) {
const basicLoginOption = this.originalLoginOptionWithDefaults(previousAuthConfiguration, TenantLoginOptionType.BASIC);
basicLoginOption.visibleOnLoginPage = this.visibleOnLoginPage(newAuthConfiguration, TenantLoginOptionType.BASIC);
return this.tenantLoginOptionMapper.mapFrom(basicLoginOption, this.getLoginOptionFromAuthConfiguration(newAuthConfiguration, TenantLoginOptionType.BASIC));
}
prepareOauthInternalLoginOption(newAuthConfiguration, previousAuthConfiguration) {
const oauthInternalLoginOption = this.originalLoginOptionWithDefaults(previousAuthConfiguration, TenantLoginOptionType.OAUTH2_INTERNAL);
oauthInternalLoginOption.visibleOnLoginPage = this.visibleOnLoginPage(newAuthConfiguration, TenantLoginOptionType.OAUTH2_INTERNAL);
return this.tenantLoginOptionMapper.mapFrom(oauthInternalLoginOption, this.getLoginOptionFromAuthConfiguration(newAuthConfiguration, TenantLoginOptionType.OAUTH2_INTERNAL));
}
originalLoginOptionWithDefaults(previousAuthConfiguration, loginOptionType) {
return defaults({}, this.getLoginOptionFromAuthConfiguration(previousAuthConfiguration, loginOptionType), this.getDefaultLoginOption(loginOptionType));
}
getLoginOptionFromAuthConfiguration(authConfiguration, loginOptionType) {
return authConfiguration.loginOptions.find(loginOption => loginOption.type === loginOptionType);
}
visibleOnLoginPage(authConfiguration, loginOptionType) {
return authConfiguration.preferredLoginOptionType === loginOptionType;
}
prepareTenantOptions(newAuthConfiguration, previousAuthConfiguration) {
const getValue = (authCfg, tenantOption) => authCfg.tenantOptions[tenantOption.category][tenantOption.key];
const hasChanged = tenantOption => getValue(newAuthConfiguration, tenantOption) !==
getValue(previousAuthConfiguration, tenantOption);
return this.tenantOptionsWithDefaultValue
.filter(tenantOption => getValue(newAuthConfiguration, tenantOption) !== null)
.filter(tenantOption => hasChanged(tenantOption))
.map(tenantOption => ({
category: tenantOption.category,
key: tenantOption.key,
value: getValue(newAuthConfiguration, tenantOption).toString()
}));
}
getLoginOptions$() {
return forkJoin([
this.getLoginOption(TenantLoginOptionType.OAUTH2),
this.getLoginOption(TenantLoginOptionType.BASIC),
this.getLoginOption(TenantLoginOptionType.OAUTH2_INTERNAL)
]).pipe(map(loginOptions => loginOptions.filter(loginOption => !!loginOption)));
}
getLoginOption(tenantLoginOptionType) {
return from(this.tenantLoginOptionsService.detail(tenantLoginOptionType)).pipe(map(res => res.data), catchError(() => tenantLoginOptionType !== TenantLoginOptionType.OAUTH2
? of(this.getDefaultLoginOption(tenantLoginOptionType))
: of(null)));
}
getPreferredLoginOptionType$(loginOptions$) {
return loginOptions$.pipe(map(loginOptions => {
return this.tenantUiService.getPreferredLoginOption(loginOptions).type;
}));
}
getTenantOptions$() {
return forkJoin(this.tenantOptionsWithDefaultValue.map((option) => from(this.tenantOptionsService.detail(option)).pipe(map(res => {
option.apply(res.data);
return option;
}), catchError(() => of(option))))).pipe(map(options => this.getOptionsObject(options)));
}
getSystemOptions$() {
return forkJoin(this.systemOptionsWithDefaultValue.map((option) => {
const fixedOption = this.fixTfaEnforcedSystemOption(option);
if (fixedOption) {
return fixedOption;
}
return from(this.systemOptionsService.detail(option)).pipe(map(res => {
option.apply(res.data);
return option;
}), catchError(() => of(option)));
})).pipe(map(options => this.getOptionsObject(options)));
}
/**
* Returns an observable with fixed `two-factor-authentication.enforced` system option or null.
* This method fixes problem with inconsistent value. System option `two-factor-authentication.enforced` is list of tenants when UI using boolean value.
* This part will be removed after implementing new endpoint in MTM-50490.
*/
fixTfaEnforcedSystemOption(option) {
if (option.category === 'two-factor-authentication' && option.key === 'enforced') {
return from(this.tenantService.getTfaSettings(this.tenantUiService.currentTenant)).pipe(map(tfaSettings => {
option.value = tfaSettings.enforcedOnSystemLevel.toString();
return option;
}));
}
return null;
}
/**
* Returns a promise or null.
* This method is needed now, because simply changing TFA strategy tenant option does not trigger all the necessary backend logic to apply the change, therefore, we need to call tenant's `/tfa` endpoint, which applies the change for all users in the tenant.
* Within MTM-50490, we're going to simplify the process further by replacing multiple requests with one new endpoint that will handle saving of all authentication settings.
*/
fixTfaStrategy(option) {
if (option.category === 'two-factor-authentication' && option.key === 'strategy') {
const strategy = option.value === 'SMS' ? TfaStrategy.SMS : TfaStrategy.TOTP;
return this.tenantService.updateTfaStrategy(this.tenantUiService.currentTenant, strategy);
}
return null;
}
isSmsApplicationAvailable$() {
return from(this.appState.isApplicationAvailable('sms-gateway'));
}
getOptionsObject(options) {
return options.reduce((optionsObject, option) => {
optionsObject[option.category] = optionsObject[option.category] || {};
optionsObject[option.category][option.key] = option.getValue();
return optionsObject;
}, {});
}
getDefaultLoginOption(tenantLoginOptionType) {
return {
userManagementSource: UserManagementSource.INTERNAL,
grantType: GrantType.PASSWORD,
providerName: 'Cumulocity',
visibleOnLoginPage: false,
type: tenantLoginOptionType
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationService, deps: [{ token: i1$1.TenantLoginOptionsService }, { token: i1$1.TenantOptionsService }, { token: i1$1.SystemOptionsService }, { token: i2.AppStateService }, { token: i2.TenantUiService }, { token: TenantLoginOptionMapper }, { token: i1$1.TenantService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationService, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i1$1.TenantLoginOptionsService }, { type: i1$1.TenantOptionsService }, { type: i1$1.SystemOptionsService }, { type: i2.AppStateService }, { type: i2.TenantUiService }, { type: TenantLoginOptionMapper }, { type: i1$1.TenantService }] });
class LoginSettingsComponent {
constructor(tenantUiService) {
this.tenantUiService = tenantUiService;
this.PREFERRED_LOGIN_MODE_POPOVER = gettext('Main difference is the storage of the authentication information. With Basic Auth, it is saved in a session storage and with OAI-Secure in a HttpOnly cookie. OAI-Secure grant is recommended as the authentication information is not accessible via JavaScript. Single sign-on redirect allows a user to login with a single 3rd-party authorization server using the OAuth2 protocol.');
this.ENFORCED_BY_PLATFORM_POPOVER = gettext('The setting is enforced on the platform level.');
this.IGNORE_CASE_SENSITIVITY_POPOVER = gettext('If selected, the letter case of the username does not matter during login.');
this.tenantLoginOptionTypeEnum = TenantLoginOptionType;
this.PASSWORD_CATEGORY = 'password';
this.LIMIT_VALIDITY_KEY = 'limit.validity';
this.TENANT_STRENGTH_VALIDITY_KEY = 'strength.validity';
this.SYSTEM_STRENGTH_VALIDITY_KEY = 'enforce.strength';
}
ngOnChanges(changes) {
if (changes.authConfiguration && changes.authConfiguration.currentValue) {
this.isOauth2 = !!changes.authConfiguration.currentValue.loginOptions.find(this.tenantUiService.isOauth2);
}
}
get systemPasswordLimitValidity() {
return this.authConfiguration.systemOptions[this.PASSWORD_CATEGORY][this.LIMIT_VALIDITY_KEY];
}
get passwordLimitValidity() {
return this.systemPasswordLimitValidity !== null
? this.systemPasswordLimitValidity
: this.authConfiguration.tenantOptions[this.PASSWORD_CATEGORY][this.LIMIT_VALIDITY_KEY];
}
set passwordLimitValidity(value) {
if (this.systemPasswordLimitValidity === null) {
this.authConfiguration.tenantOptions[this.PASSWORD_CATEGORY][this.LIMIT_VALIDITY_KEY] = value;
}
}
get systemPasswordEnforceStrength() {
return this.authConfiguration.systemOptions[this.PASSWORD_CATEGORY][this.SYSTEM_STRENGTH_VALIDITY_KEY];
}
get passwordEnforceStrength() {
return this.systemPasswordEnforceStrength
? this.systemPasswordEnforceStrength
: this.authConfiguration.tenantOptions[this.PASSWORD_CATEGORY][this.TENANT_STRENGTH_VALIDITY_KEY];
}
set passwordEnforceStrength(value) {
if (!this.systemPasswordEnforceStrength) {
this.authConfiguration.tenantOptions[this.PASSWORD_CATEGORY][this.TENANT_STRENGTH_VALIDITY_KEY] = value;
}
}
get tenantLoginIgnoreCase() {
return this.authConfiguration.tenantOptions['configuration']['tenant.login.ignore-case'];
}
set tenantLoginIgnoreCase(value) {
this.authConfiguration.tenantOptions['configuration']['tenant.login.ignore-case'] = value;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: LoginSettingsComponent, deps: [{ token: i2.TenantUiService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: LoginSettingsComponent, isStandalone: true, selector: "c8y-login-settings", inputs: { authConfiguration: "authConfiguration" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"card-block separator-top overflow-auto\" *ngIf=\"authConfiguration\">\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">{{ 'Login settings' | translate }}</div>\n </div>\n\n <div class=\"col-sm-9\">\n <div class=\"row m-b-8\">\n <c8y-form-group class=\"col-sm-6\">\n <label>\n {{ 'Preferred login mode' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ PREFERRED_LOGIN_MODE_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n [attr.aria-label]=\"'Auth type' | translate\"\n class=\"form-control\"\n id=\"preferredLoginOptionType\"\n name=\"preferredLoginOptionType\"\n [(ngModel)]=\"authConfiguration.preferredLoginOptionType\"\n >\n <option value=\"{{ tenantLoginOptionTypeEnum.BASIC }}\" translate>Basic Auth</option>\n <option value=\"{{ tenantLoginOptionTypeEnum.OAUTH2_INTERNAL }}\" translate>\n OAI-Secure\n </option>\n <option value=\"{{ tenantLoginOptionTypeEnum.OAUTH2 }}\" [disabled]=\"!isOauth2\" translate>\n Single sign-on redirect\n </option>\n </select>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Password validity limit' | translate }}\">\n {{ 'Password validity limit' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ ENFORCED_BY_PLATFORM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"systemPasswordLimitValidity\"\n ></button>\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"passwordLimitValidity\"\n class=\"form-control text-right\"\n [(ngModel)]=\"passwordLimitValidity\"\n min=\"0\"\n max=\"999999\"\n step=\"1\"\n required\n [disabled]=\"systemPasswordLimitValidity\"\n />\n <span class=\"input-group-addon\" translate>days</span>\n </div>\n <p class=\"help-block\">\n {{ 'Default: 0 (unlimited validity)' | translate }}\n </p>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Password strength' | translate }}\">\n {{ 'Password strength' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ ENFORCED_BY_PLATFORM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"systemPasswordEnforceStrength\"\n ></button>\n </label>\n <div>\n <label\n title=\"{{ 'Enforce that all passwords are strong' | translate }}\"\n class=\"c8y-switch\"\n >\n <input\n type=\"checkbox\"\n name=\"passwordEnforceStrength\"\n data-cy=\"c8y-form-group--password-enforce-toggle-btn\"\n [(ngModel)]=\"passwordEnforceStrength\"\n [disabled]=\"systemPasswordEnforceStrength\"\n />\n <span></span>\n <span>{{ 'Enforce strong passwords (green)' | translate }}</span>\n </label>\n </div>\n </c8y-form-group>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n title=\"{{ 'Ignore case when logging in' | translate }}\"\n data-cy=\"c8y-authentication-configuration--ignore-case-when-logging-in\"\n class=\"c8y-switch\"\n >\n <input\n type=\"checkbox\"\n name=\"tenantLoginIgnoreCase\"\n [(ngModel)]=\"tenantLoginIgnoreCase\"\n />\n <span></span>\n <span>{{ 'Ignore case when logging in' | translate }}</span>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ IGNORE_CASE_SENSITIVITY_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n </c8y-form-group>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: MinValidationDirective, selector: "[min]", inputs: ["min"] }, { kind: "directive", type: MaxValidationDirective, selector: "[max]", inputs: ["max"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: LoginSettingsComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-login-settings', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
FormGroupComponent,
PopoverDirective,
FormsModule,
C8yTranslateDirective,
RequiredInputPlaceholderDirective,
MinValidationDirective,
MaxValidationDirective,
C8yTranslatePipe
], template: "<div class=\"card-block separator-top overflow-auto\" *ngIf=\"authConfiguration\">\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">{{ 'Login settings' | translate }}</div>\n </div>\n\n <div class=\"col-sm-9\">\n <div class=\"row m-b-8\">\n <c8y-form-group class=\"col-sm-6\">\n <label>\n {{ 'Preferred login mode' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ PREFERRED_LOGIN_MODE_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n [attr.aria-label]=\"'Auth type' | translate\"\n class=\"form-control\"\n id=\"preferredLoginOptionType\"\n name=\"preferredLoginOptionType\"\n [(ngModel)]=\"authConfiguration.preferredLoginOptionType\"\n >\n <option value=\"{{ tenantLoginOptionTypeEnum.BASIC }}\" translate>Basic Auth</option>\n <option value=\"{{ tenantLoginOptionTypeEnum.OAUTH2_INTERNAL }}\" translate>\n OAI-Secure\n </option>\n <option value=\"{{ tenantLoginOptionTypeEnum.OAUTH2 }}\" [disabled]=\"!isOauth2\" translate>\n Single sign-on redirect\n </option>\n </select>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Password validity limit' | translate }}\">\n {{ 'Password validity limit' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ ENFORCED_BY_PLATFORM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"systemPasswordLimitValidity\"\n ></button>\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"passwordLimitValidity\"\n class=\"form-control text-right\"\n [(ngModel)]=\"passwordLimitValidity\"\n min=\"0\"\n max=\"999999\"\n step=\"1\"\n required\n [disabled]=\"systemPasswordLimitValidity\"\n />\n <span class=\"input-group-addon\" translate>days</span>\n </div>\n <p class=\"help-block\">\n {{ 'Default: 0 (unlimited validity)' | translate }}\n </p>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Password strength' | translate }}\">\n {{ 'Password strength' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ ENFORCED_BY_PLATFORM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"systemPasswordEnforceStrength\"\n ></button>\n </label>\n <div>\n <label\n title=\"{{ 'Enforce that all passwords are strong' | translate }}\"\n class=\"c8y-switch\"\n >\n <input\n type=\"checkbox\"\n name=\"passwordEnforceStrength\"\n data-cy=\"c8y-form-group--password-enforce-toggle-btn\"\n [(ngModel)]=\"passwordEnforceStrength\"\n [disabled]=\"systemPasswordEnforceStrength\"\n />\n <span></span>\n <span>{{ 'Enforce strong passwords (green)' | translate }}</span>\n </label>\n </div>\n </c8y-form-group>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n title=\"{{ 'Ignore case when logging in' | translate }}\"\n data-cy=\"c8y-authentication-configuration--ignore-case-when-logging-in\"\n class=\"c8y-switch\"\n >\n <input\n type=\"checkbox\"\n name=\"tenantLoginIgnoreCase\"\n [(ngModel)]=\"tenantLoginIgnoreCase\"\n />\n <span></span>\n <span>{{ 'Ignore case when logging in' | translate }}</span>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ IGNORE_CASE_SENSITIVITY_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n </c8y-form-group>\n </div>\n </div>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i2.TenantUiService }], propDecorators: { authConfiguration: [{
type: Input
}] } });
class SessionConfigurationComponent {
constructor(tenantUiService, translateService) {
this.tenantUiService = tenantUiService;
this.translateService = translateService;
this.tenantLoginOptionTypeEnum = TenantLoginOptionType;
this.ABSOLUTE_TIMEOUT_VALIDATION_MESSAGE = gettext('The value must be greater than "Token lifespan" and not less than {{ minAbsoluteTimeout }}.');
this.RENEWAL_TIMEOUT_VALIDATION_MESSAGE = gettext('The value must be less than "Token lifespan".');
this.MAX_TOKEN_LIFESPAN_VALIDATION_MESSAGE = gettext('The value must be less than "Session absolute timeout".');
this.MIN_TOKEN_LIFESPAN_VALIDATION_MESSAGE = gettext('The value must be greater than "Session renewal timeout".');
this.USER_AGENT_VALIDATION_REQUIRED_POPOVER = gettext('If selected, then every request needs to use the same "User-Agent" header as the first request which initiated the session.');
this.MIN_ABSOLUTE_TIMEOUT = 15 * 60;
this.ABSOLUTE_TIMEOUT_VALIDATION_MESSAGE = this.translateService.instant(this.ABSOLUTE_TIMEOUT_VALIDATION_MESSAGE, { minAbsoluteTimeout: this.MIN_ABSOLUTE_TIMEOUT });
}
ngOnChanges(changes) {
if (changes.authConfiguration && changes.authConfiguration.currentValue) {
const oauthInternal = changes.authConfiguration.currentValue.loginOptions.find(isOauthInternal) || {};
this.originalSessionConfiguration = cloneDeep(oauthInternal.sessionConfiguration);
this.sessionConfiguration = oauthInternal.sessionConfiguration;
this.previousTokenLifespan =
this.authConfiguration.tenantOptions['oauth.internal']['basic-token.lifespan.seconds'];
}
}
get renewalTimeoutSeconds() {
const sessionConfiguration = this.sessionConfiguration;
return this.convertToSeconds(sessionConfiguration.renewalTimeoutMillis);
}
set renewalTimeoutSeconds(value) {
this.sessionConfiguration.renewalTimeoutMillis = this.convertToMillis(value);
}
get absoluteTimeoutSeconds() {
const sessionConfiguration = this.sessionConfiguration;
return this.convertToSeconds(sessionConfiguration.absoluteTimeoutMillis);
}
set absoluteTimeoutSeconds(value) {
this.sessionConfiguration.absoluteTimeoutMillis = this.convertToMillis(value);
}
get maximumNumberOfParallelSessions() {
return this.sessionConfiguration.maximumNumberOfParallelSessions;
}
set maximumNumberOfParallelSessions(value) {
this.sessionConfiguration.maximumNumberOfParallelSessions = value;
}
get userAgentValidationRequired() {
return this.sessionConfiguration.userAgentValidationRequired;
}
set userAgentValidationRequired(value) {
this.sessionConfiguration.userAgentValidationRequired = value;
}
get basicTokenLifespan() {
return this.authConfiguration.tenantOptions['oauth.internal']['basic-token.lifespan.seconds'];
}
set basicTokenLifespan(value) {
this.authConfiguration.tenantOptions['oauth.internal']['basic-token.lifespan.seconds'] = value;
}
get useSessionConfiguration() {
return !!this.sessionConfiguration;
}
set useSessionConfiguration(value) {
this.sessionConfiguration = value
? defaults({}, this.originalSessionConfiguration, {
absoluteTimeoutMillis: 1209600000, // 14 days
renewalTimeoutMillis: 86400000, // 1 day
maximumNumberOfParallelSessions: 5,
userAgentValidationRequired: false
})
: null;
this.basicTokenLifespan = this.previousTokenLifespan || 172800; // 2 days
}
get absoluteTimeoutConstraints() {
return {
min: Math.max(this.MIN_ABSOLUTE_TIMEOUT, this.basicTokenLifespan + 1)
};
}
get renewalTimeoutConstraints() {
return {
min: this.MIN_ABSOLUTE_TIMEOUT / 2,
max: this.basicTokenLifespan ? this.basicTokenLifespan - 1 : null
};
}
get basicTokenLifespanConstraints() {
return {
min: this.renewalTimeoutSeconds ? this.renewalTimeoutSeconds + 1 : null,
max: this.absoluteTimeoutSeconds ? this.absoluteTimeoutSeconds - 1 : null
};
}
get sessionConfiguration() {
return this.authConfiguration.loginOptions.find(isOauthInternal).sessionConfiguration;
}
set sessionConfiguration(value) {
this.authConfiguration.loginOptions.find(isOauthInternal).sessionConfiguration = value;
}
convertToMillis(seconds) {
return isFinite(seconds) ? seconds * 1000 : null;
}
convertToSeconds(milliseconds) {
return isFinite(milliseconds) ? Math.ceil(milliseconds / 1000) : null;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SessionConfigurationComponent, deps: [{ token: i2.TenantUiService }, { token: i2$1.TranslateService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: SessionConfigurationComponent, isStandalone: true, selector: "c8y-session-configuration", inputs: { authConfiguration: "authConfiguration" }, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"card-block separator-top overflow-auto\"\n *ngIf=\"authConfiguration.preferredLoginOptionType === tenantLoginOptionTypeEnum.OAUTH2_INTERNAL\"\n>\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ 'OAI-Secure session configuration' | translate }}\n </div>\n </div>\n\n <div class=\"col-sm-9\">\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"c8y-switch\" title=\"{{ 'Use session configuration' | translate }}\">\n <input\n type=\"checkbox\"\n name=\"useSessionConfiguration\"\n [(ngModel)]=\"useSessionConfiguration\"\n />\n <span></span>\n <span>{{ 'Use session configuration' | translate }}</span>\n </label>\n </c8y-form-group>\n </div>\n </div>\n\n <fieldset *ngIf=\"sessionConfiguration\">\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"c8y-switch\" title=\"{{ 'User agent validation required' | translate }}\">\n <input\n type=\"checkbox\"\n name=\"userAgentValidationRequired\"\n [(ngModel)]=\"userAgentValidationRequired\"\n />\n <span></span>\n <span>{{ 'User agent validation required' | translate }}</span>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ USER_AGENT_VALIDATION_REQUIRED_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n </c8y-form-group>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Session absolute timeout' | translate }}\">\n {{ 'Session absolute timeout' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"absoluteTimeoutSeconds\"\n class=\"form-control text-right\"\n [(ngModel)]=\"absoluteTimeoutSeconds\"\n [required]=\"useSessionConfiguration\"\n [min]=\"absoluteTimeoutConstraints.min\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>seconds</span>\n </div>\n <c8y-messages>\n <c8y-message\n name=\"min\"\n text=\"{{ ABSOLUTE_TIMEOUT_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n </c8y-messages>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Session renewal timeout' | translate }}\">\n {{ 'Session renewal timeout' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"renewalTimeoutSeconds\"\n class=\"form-control text-right\"\n [(ngModel)]=\"renewalTimeoutSeconds\"\n [required]=\"useSessionConfiguration\"\n [max]=\"renewalTimeoutConstraints.max\"\n [min]=\"renewalTimeoutConstraints.min\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>seconds</span>\n </div>\n <c8y-messages>\n <c8y-message\n name=\"max\"\n text=\"{{ RENEWAL_TIMEOUT_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n </c8y-messages>\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Maximum parallel sessions per user' | translate }}\">\n {{ 'Maximum parallel sessions per user' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"maximumNumberOfParallelSessions\"\n class=\"form-control text-right\"\n [(ngModel)]=\"maximumNumberOfParallelSessions\"\n [required]=\"useSessionConfiguration\"\n [min]=\"1\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>sessions</span>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Token lifespan' | translate }}\">\n {{ 'Token lifespan' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"basicTokenLifespan\"\n class=\"form-control text-right\"\n [(ngModel)]=\"basicTokenLifespan\"\n [required]=\"useSessionConfiguration\"\n [max]=\"basicTokenLifespanConstraints.max\"\n [min]=\"basicTokenLifespanConstraints.min\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>seconds</span>\n </div>\n <c8y-messages>\n <c8y-message\n name=\"max\"\n text=\"{{ MAX_TOKEN_LIFESPAN_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n <c8y-message\n name=\"min\"\n text=\"{{ MIN_TOKEN_LIFESPAN_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n </c8y-messages>\n </c8y-form-group>\n </div>\n </div>\n </fieldset>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: MinValidationDirective, selector: "[min]", inputs: ["min"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "component", type: MessagesComponent, selector: "c8y-messages", inputs: ["show", "defaults", "helpMessage"] }, { kind: "directive", type: MessageDirective, selector: "c8y-message", inputs: ["name", "text"] }, { kind: "directive", type: MaxValidationDirective, selector: "[max]", inputs: ["max"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SessionConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-session-configuration', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
FormGroupComponent,
FormsModule,
PopoverDirective,
RequiredInputPlaceholderDirective,
MinValidationDirective,
C8yTranslateDirective,
MessagesComponent,
MessageDirective,
MaxValidationDirective,
C8yTranslatePipe
], template: "<div\n class=\"card-block separator-top overflow-auto\"\n *ngIf=\"authConfiguration.preferredLoginOptionType === tenantLoginOptionTypeEnum.OAUTH2_INTERNAL\"\n>\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ 'OAI-Secure session configuration' | translate }}\n </div>\n </div>\n\n <div class=\"col-sm-9\">\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"c8y-switch\" title=\"{{ 'Use session configuration' | translate }}\">\n <input\n type=\"checkbox\"\n name=\"useSessionConfiguration\"\n [(ngModel)]=\"useSessionConfiguration\"\n />\n <span></span>\n <span>{{ 'Use session configuration' | translate }}</span>\n </label>\n </c8y-form-group>\n </div>\n </div>\n\n <fieldset *ngIf=\"sessionConfiguration\">\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"c8y-switch\" title=\"{{ 'User agent validation required' | translate }}\">\n <input\n type=\"checkbox\"\n name=\"userAgentValidationRequired\"\n [(ngModel)]=\"userAgentValidationRequired\"\n />\n <span></span>\n <span>{{ 'User agent validation required' | translate }}</span>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ USER_AGENT_VALIDATION_REQUIRED_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n </c8y-form-group>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Session absolute timeout' | translate }}\">\n {{ 'Session absolute timeout' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"absoluteTimeoutSeconds\"\n class=\"form-control text-right\"\n [(ngModel)]=\"absoluteTimeoutSeconds\"\n [required]=\"useSessionConfiguration\"\n [min]=\"absoluteTimeoutConstraints.min\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>seconds</span>\n </div>\n <c8y-messages>\n <c8y-message\n name=\"min\"\n text=\"{{ ABSOLUTE_TIMEOUT_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n </c8y-messages>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Session renewal timeout' | translate }}\">\n {{ 'Session renewal timeout' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"renewalTimeoutSeconds\"\n class=\"form-control text-right\"\n [(ngModel)]=\"renewalTimeoutSeconds\"\n [required]=\"useSessionConfiguration\"\n [max]=\"renewalTimeoutConstraints.max\"\n [min]=\"renewalTimeoutConstraints.min\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>seconds</span>\n </div>\n <c8y-messages>\n <c8y-message\n name=\"max\"\n text=\"{{ RENEWAL_TIMEOUT_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n </c8y-messages>\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Maximum parallel sessions per user' | translate }}\">\n {{ 'Maximum parallel sessions per user' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"maximumNumberOfParallelSessions\"\n class=\"form-control text-right\"\n [(ngModel)]=\"maximumNumberOfParallelSessions\"\n [required]=\"useSessionConfiguration\"\n [min]=\"1\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>sessions</span>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Token lifespan' | translate }}\">\n {{ 'Token lifespan' | translate }}\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n name=\"basicTokenLifespan\"\n class=\"form-control text-right\"\n [(ngModel)]=\"basicTokenLifespan\"\n [required]=\"useSessionConfiguration\"\n [max]=\"basicTokenLifespanConstraints.max\"\n [min]=\"basicTokenLifespanConstraints.min\"\n step=\"1\"\n />\n <span class=\"input-group-addon\" translate>seconds</span>\n </div>\n <c8y-messages>\n <c8y-message\n name=\"max\"\n text=\"{{ MAX_TOKEN_LIFESPAN_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n <c8y-message\n name=\"min\"\n text=\"{{ MIN_TOKEN_LIFESPAN_VALIDATION_MESSAGE | translate }}\"\n ></c8y-message>\n </c8y-messages>\n </c8y-form-group>\n </div>\n </div>\n </fieldset>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i2.TenantUiService }, { type: i2$1.TranslateService }], propDecorators: { authConfiguration: [{
type: Input
}] } });
// tslint:disable:no-string-literal
var TfaStateEnum;
(function (TfaStateEnum) {
TfaStateEnum[TfaStateEnum["TFA_UNDEFINED_BY_SYSTEM"] = 0] = "TFA_UNDEFINED_BY_SYSTEM";
TfaStateEnum[TfaStateEnum["TFA_ENFORCED_FOR_GROUP"] = 1] = "TFA_ENFORCED_FOR_GROUP";
TfaStateEnum[TfaStateEnum["TFA_ENABLED_BY_SYSTEM"] = 2] = "TFA_ENABLED_BY_SYSTEM";
TfaStateEnum[TfaStateEnum["TFA_ENFORCED_BY_SYSTEM"] = 3] = "TFA_ENFORCED_BY_SYSTEM";
})(TfaStateEnum || (TfaStateEnum = {}));
class TfaSettingsComponent {
constructor() {
this.preferredLoginOptionType = TenantLoginOptionType.BASIC;
this.tfaStateEnum = TfaStateEnum;
this.tfaStrategyEnum = TfaStrategy;
this.tenantLoginOptionTypeEnum = TenantLoginOptionType;
this.TOTP_REQUIRES_OAUTH_POPOVER = gettext('TOTP requires OAI-Secure login mode.');
this.SMS_APP_NOT_SUBSCRIBED_POPOVER = gettext('SMS strategy requires messaging application to be subscribed.');
this.TFA_IS_ENFORCED_BY_SYSTEM_POPOVER = gettext('The setting is enforced on the platform level.');
this.TFA_IS_ENABLED_BY_SYSTEM_POPOVER = gettext('The setting is enabled on the platform level.');
this.TOKEN_VALIDITY_DETERMINED_BY_JWT_POPOVER = gettext("In OAI-Secure login mode, the token's validity limit is determined by the JWT token and cannot be edited here.");
this.TFA_IS_ENABLED_BY_ENFORCE_FOR_GROUP_POPOVER = gettext('The setting is enabled on the platform level because it is enforced for particular roles.');
}
ngOnChanges(changes) {
if (changes.authConfiguration && changes.authConfiguration.currentValue) {
this.smsGatewayAvailable = changes.authConfiguration.currentValue.smsGatewayAvailable;
this.preferredLoginOptionType =
changes.authConfiguration.currentValue.preferredLoginOptionType;
}
}
ngDoCheck() {
if (this.preferredLoginOptionType !== this.authConfiguration.preferredLoginOptionType) {
this.preferredLoginOptionType = this.authConfiguration.preferredLoginOptionType;
this.tenantTfaStrategy = this.tfaBySmsCanBeSet ? TfaStrategy.SMS : TfaStrategy.TOTP;
}
}
get tenantTfaTokenValidity() {
return this.authConfiguration.tenantOptions['two-factor-authentication']['token.validity'];
}
set tenantTfaTokenValidity(value) {
this.authConfiguration.tenantOptions['two-factor-authentication']['token.validity'] = value;
}
get tenantTfaPinValidity() {
return this.authConfiguration.tenantOptions['two-factor-authentication']['pin.validity'];
}
set tenantTfaPinValidity(value) {
this.authConfiguration.tenantOptions['two-factor-authentication']['pin.validity'] = value;
}
get tenantTfaEnabled() {
return this.authConfiguration.tenantOptions['two-factor-authentication']['enabled'];
}
set tenantTfaEnabled(value) {
this.authConfiguration.tenantOptions['two-factor-authentication']['enabled'] = value;
}
get tenantTfaEnforced() {
return this.authConfiguration.tenantOptions['two-factor-authentication']['enforced'];
}
set tenantTfaEnforced(value) {
this.authConfiguration.tenantOptions['two-factor-authentication']['enforced'] = value;
}
get tenantTfaStrategy() {
return this.authConfiguration.tenantOptions['two-factor-authentication']['strategy'];
}
set tenantTfaStrategy(value) {
this.authConfiguration.tenantOptions['two-factor-authentication']['strategy'] = value;
}
get systemTfaEnforcedGroup() {
return this.authConfiguration.systemOptions['two-factor-authentication']['enforced.group'];
}
get systemTfaTenantScopeSettingEnabled() {
return this.authConfiguration.systemOptions['two-factor-authentication']['tenant-scope-settings.enabled'];
}
get systemTfaEnabled() {
return this.authConfiguration.systemOptions['two-factor-authentication']['enabled'];
}
get systemTfaEnforced() {
return this.authConfiguration.systemOptions['two-factor-authentication']['enforced'];
}
get tfaState() {
if (this.systemTfaEnforced) {
return this.tfaStateEnum.TFA_ENFORCED_BY_SYSTEM;
}
if (!isEmpty(this.systemTfaEnforcedGroup)) {
return this.tfaStateEnum.TFA_ENFORCED_FOR_GROUP;
}
if (this.systemTfaEnabled) {
return this.tfaStateEnum.TFA_ENABLED_BY_SYSTEM;
}
return this.tfaStateEnum.TFA_UNDEFINED_BY_SYSTEM;
}
get tfaBySmsCanBeSet() {
return ((this.tfaState !== this.tfaStateEnum.TFA_UNDEFINED_BY_SYSTEM || this.tenantTfaEnabled) &&
this.smsGatewayAvailable);
}
get tfaByTotpCanBeSet() {
return ((this.tfaState !== this.tfaStateEnum.TFA_UNDEFINED_BY_SYSTEM || this.tenantTfaEnabled) &&
this.preferredLoginOptionType === TenantLoginOptionType.OAUTH2_INTERNAL);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TfaSettingsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: TfaSettingsComponent, isStandalone: true, selector: "c8y-auth-tfa", inputs: { authConfiguration: "authConfiguration" }, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"card-block separator-top\"\n *ngIf=\"preferredLoginOptionType !== tenantLoginOptionTypeEnum.OAUTH2\"\n>\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ 'Two-factor authentication' | translate }}\n </div>\n </div>\n\n <div class=\"col-sm-9\">\n <c8y-form-group>\n <label\n class=\"c8y-switch\"\n title=\"{{ 'Enable two-factor authentication' | translate }}\"\n *ngIf=\"\n tfaState === tfaStateEnum.TFA_UNDEFINED_BY_SYSTEM;\n else enabledOrEnforcedOnSystemLevelTemplate\n \"\n >\n <input type=\"checkbox\" [(ngModel)]=\"tenantTfaEnabled\" name=\"tenantTfaEnabled\" />\n <span></span>\n <span>{{ 'Enable' | translate }}</span>\n </label>\n\n <ng-template #enabledOrEnforcedOnSystemLevelTemplate>\n <div [ngSwitch]=\"tfaState\">\n <span *ngSwitchCase=\"tfaStateEnum.TFA_ENABLED_BY_SYSTEM\">\n {{ 'Two-factor authentication is enabled on all users' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENABLED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n ></button>\n </span>\n <div *ngSwitchCase=\"tfaStateEnum.TFA_ENFORCED_BY_SYSTEM\">\n <span>\n {{ 'Two-factor authentication is enforced on all users' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENFORCED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n ></button>\n </span>\n </div>\n <div *ngSwitchCase=\"tfaStateEnum.TFA_ENFORCED_FOR_GROUP\">\n <span>\n <span translate [translateParams]=\"{ role: systemTfaEnforcedGroup }\" ngNonBindable>\n Two-factor authentication is enabled on all users and enforced on users with role\n {{ role }}.\n </span>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENABLED_BY_ENFORCE_FOR_GROUP_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n ></button>\n </span>\n </div>\n </div>\n </ng-template>\n </c8y-form-group>\n\n <fieldset *ngIf=\"tfaBySmsCanBeSet || tfaByTotpCanBeSet\">\n <div class=\"row\">\n <c8y-form-group class=\"col-sm-6\">\n <label title=\"{{ 'TFA strategy' | translate }}\">\n {{ 'TFA strategy' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ SMS_APP_NOT_SUBSCRIBED_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"!tfaBySmsCanBeSet\"\n ></button>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TOTP_REQUIRES_OAUTH_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"!tfaByTotpCanBeSet\"\n ></button>\n </label>\n\n <div class=\"c8y-select-wrapper\">\n <select\n [attr.aria-label]=\"'TFA' | translate\"\n class=\"form-control\"\n [(ngModel)]=\"tenantTfaStrategy\"\n name=\"tenantTfaStrategy\"\n >\n <option value=\"{{ tfaStrategyEnum.SMS }}\" translate [disabled]=\"!tfaBySmsCanBeSet\">\n SMS based\n </option>\n <option value=\"{{ tfaStrategyEnum.TOTP }}\" translate [disabled]=\"!tfaByTotpCanBeSet\">\n TOTP\n </option>\n </select>\n <span></span>\n </div>\n </c8y-form-group>\n </div>\n\n <div\n class=\"row\"\n *ngIf=\"\n tenantTfaStrategy === tfaStrategyEnum.TOTP &&\n tfaState !== tfaStateEnum.TFA_ENFORCED_BY_SYSTEM\n \"\n >\n <label title=\"{{ 'Enforcement' | translate }}\">{{ 'Enforcement' | translate }}</label>\n <div class=\"form-control-static\">\n <label\n title=\"{{ 'Enforce two-factor authentication on all users' | translate }}\"\n class=\"c8y-switch\"\n >\n <input type=\"checkbox\" name=\"tenantTfaEnforced\" [(ngModel)]=\"tenantTfaEnforced\" />\n <span></span>\n <span>{{ 'Enforce two-factor authentication on all users' | translate }}</span>\n </label>\n </div>\n </div>\n\n <div class=\"row\" *ngIf=\"tenantTfaStrategy === tfaStrategyEnum.SMS\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Token validity limit' | translate }}\">\n {{ 'Token validity limit' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENFORCED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n *ngIf=\"!systemTfaTenantScopeSettingEnabled\"\n ></button>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TOKEN_VALIDITY_DETERMINED_BY_JWT_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n *ngIf=\"\n systemTfaTenantScopeSettingEnabled &&\n preferredLoginOptionType === tenantLoginOptionTypeEnum.OAUTH2_INTERNAL\n \"\n ></button>\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n class=\"form-control text-right\"\n name=\"tenantTfaTokenValidity\"\n [(ngModel)]=\"tenantTfaTokenValidity\"\n [disabled]=\"\n !systemTfaTenantScopeSettingEnabled ||\n preferredLoginOptionType === tenantLoginOptionTypeEnum.OAUTH2_INTERNAL\n \"\n [required]=\"systemTfaTenantScopeSettingEnabled\"\n [max]=\"999999\"\n [min]=\"0\"\n />\n <span class=\"input-group-addon\" translate>minutes</span>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Verification code validity limit' | translate }}\">\n {{ 'Verification code validity limit' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENFORCED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n *ngIf=\"!systemTfaTenantScopeSettingEnabled\"\n ></button>\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n class=\"form-control text-right\"\n name=\"tenantTfaPinValidity\"\n [(ngModel)]=\"tenantTfaPinValidity\"\n [disabled]=\"!systemTfaTenantScopeSettingEnabled\"\n [required]=\"systemTfaTenantScopeSettingEnabled\"\n [max]=\"999999\"\n [min]=\"0\"\n />\n <span class=\"input-group-addon\" translate>minutes</span>\n </div>\n </c8y-form-group>\n </div>\n </div>\n </fieldset>\n <div\n *ngIf=\"\n preferredLoginOptionType !== tenantLoginOptionTypeEnum.OAUTH2_INTERNAL &&\n !smsGatewayAvailable\n \"\n >\n <div class=\"alert alert-warning\">\n <strong>{{ 'None of TFA strategy can be set.' | translate }}</strong>\n <br />\n {{ SMS_APP_NOT_SUBSCRIBED_POPOVER | translate }}\n <br />\n {{ TOTP_REQUIRES_OAUTH_POPOVER | translate }}\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.MaxValidator, selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]", inputs: ["max"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: MaxValidationDirective, selector: "[max]", inputs: ["max"] }, { kind: "directive", type: MinValidationDirective, selector: "[min]", inputs: ["min"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TfaSettingsComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-auth-tfa', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
FormGroupComponent,
FormsModule,
NgSwitch,
NgSwitchCase,
PopoverDirective,
C8yTranslateDirective,
RequiredInputPlaceholderDirective,
MaxValidationDirective,
MinValidationDirective,
C8yTranslatePipe
], template: "<div\n class=\"card-block separator-top\"\n *ngIf=\"preferredLoginOptionType !== tenantLoginOptionTypeEnum.OAUTH2\"\n>\n <div class=\"col-sm-2\">\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ 'Two-factor authentication' | translate }}\n </div>\n </div>\n\n <div class=\"col-sm-9\">\n <c8y-form-group>\n <label\n class=\"c8y-switch\"\n title=\"{{ 'Enable two-factor authentication' | translate }}\"\n *ngIf=\"\n tfaState === tfaStateEnum.TFA_UNDEFINED_BY_SYSTEM;\n else enabledOrEnforcedOnSystemLevelTemplate\n \"\n >\n <input type=\"checkbox\" [(ngModel)]=\"tenantTfaEnabled\" name=\"tenantTfaEnabled\" />\n <span></span>\n <span>{{ 'Enable' | translate }}</span>\n </label>\n\n <ng-template #enabledOrEnforcedOnSystemLevelTemplate>\n <div [ngSwitch]=\"tfaState\">\n <span *ngSwitchCase=\"tfaStateEnum.TFA_ENABLED_BY_SYSTEM\">\n {{ 'Two-factor authentication is enabled on all users' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENABLED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n ></button>\n </span>\n <div *ngSwitchCase=\"tfaStateEnum.TFA_ENFORCED_BY_SYSTEM\">\n <span>\n {{ 'Two-factor authentication is enforced on all users' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENFORCED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n ></button>\n </span>\n </div>\n <div *ngSwitchCase=\"tfaStateEnum.TFA_ENFORCED_FOR_GROUP\">\n <span>\n <span translate [translateParams]=\"{ role: systemTfaEnforcedGroup }\" ngNonBindable>\n Two-factor authentication is enabled on all users and enforced on users with role\n {{ role }}.\n </span>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENABLED_BY_ENFORCE_FOR_GROUP_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n ></button>\n </span>\n </div>\n </div>\n </ng-template>\n </c8y-form-group>\n\n <fieldset *ngIf=\"tfaBySmsCanBeSet || tfaByTotpCanBeSet\">\n <div class=\"row\">\n <c8y-form-group class=\"col-sm-6\">\n <label title=\"{{ 'TFA strategy' | translate }}\">\n {{ 'TFA strategy' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ SMS_APP_NOT_SUBSCRIBED_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"!tfaBySmsCanBeSet\"\n ></button>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TOTP_REQUIRES_OAUTH_POPOVER | translate }}\"\n placement=\"bottom\"\n triggers=\"focus\"\n *ngIf=\"!tfaByTotpCanBeSet\"\n ></button>\n </label>\n\n <div class=\"c8y-select-wrapper\">\n <select\n [attr.aria-label]=\"'TFA' | translate\"\n class=\"form-control\"\n [(ngModel)]=\"tenantTfaStrategy\"\n name=\"tenantTfaStrategy\"\n >\n <option value=\"{{ tfaStrategyEnum.SMS }}\" translate [disabled]=\"!tfaBySmsCanBeSet\">\n SMS based\n </option>\n <option value=\"{{ tfaStrategyEnum.TOTP }}\" translate [disabled]=\"!tfaByTotpCanBeSet\">\n TOTP\n </option>\n </select>\n <span></span>\n </div>\n </c8y-form-group>\n </div>\n\n <div\n class=\"row\"\n *ngIf=\"\n tenantTfaStrategy === tfaStrategyEnum.TOTP &&\n tfaState !== tfaStateEnum.TFA_ENFORCED_BY_SYSTEM\n \"\n >\n <label title=\"{{ 'Enforcement' | translate }}\">{{ 'Enforcement' | translate }}</label>\n <div class=\"form-control-static\">\n <label\n title=\"{{ 'Enforce two-factor authentication on all users' | translate }}\"\n class=\"c8y-switch\"\n >\n <input type=\"checkbox\" name=\"tenantTfaEnforced\" [(ngModel)]=\"tenantTfaEnforced\" />\n <span></span>\n <span>{{ 'Enforce two-factor authentication on all users' | translate }}</span>\n </label>\n </div>\n </div>\n\n <div class=\"row\" *ngIf=\"tenantTfaStrategy === tfaStrategyEnum.SMS\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Token validity limit' | translate }}\">\n {{ 'Token validity limit' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENFORCED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n *ngIf=\"!systemTfaTenantScopeSettingEnabled\"\n ></button>\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TOKEN_VALIDITY_DETERMINED_BY_JWT_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n *ngIf=\"\n systemTfaTenantScopeSettingEnabled &&\n preferredLoginOptionType === tenantLoginOptionTypeEnum.OAUTH2_INTERNAL\n \"\n ></button>\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n class=\"form-control text-right\"\n name=\"tenantTfaTokenValidity\"\n [(ngModel)]=\"tenantTfaTokenValidity\"\n [disabled]=\"\n !systemTfaTenantScopeSettingEnabled ||\n preferredLoginOptionType === tenantLoginOptionTypeEnum.OAUTH2_INTERNAL\n \"\n [required]=\"systemTfaTenantScopeSettingEnabled\"\n [max]=\"999999\"\n [min]=\"0\"\n />\n <span class=\"input-group-addon\" translate>minutes</span>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label title=\"{{ 'Verification code validity limit' | translate }}\">\n {{ 'Verification code validity limit' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ TFA_IS_ENFORCED_BY_SYSTEM_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n *ngIf=\"!systemTfaTenantScopeSettingEnabled\"\n ></button>\n </label>\n <div class=\"input-group\">\n <input\n type=\"number\"\n class=\"form-control text-right\"\n name=\"tenantTfaPinValidity\"\n [(ngModel)]=\"tenantTfaPinValidity\"\n [disabled]=\"!systemTfaTenantScopeSettingEnabled\"\n [required]=\"systemTfaTenantScopeSettingEnabled\"\n [max]=\"999999\"\n [min]=\"0\"\n />\n <span class=\"input-group-addon\" translate>minutes</span>\n </div>\n </c8y-form-group>\n </div>\n </div>\n </fieldset>\n <div\n *ngIf=\"\n preferredLoginOptionType !== tenantLoginOptionTypeEnum.OAUTH2_INTERNAL &&\n !smsGatewayAvailable\n \"\n >\n <div class=\"alert alert-warning\">\n <strong>{{ 'None of TFA strategy can be set.' | translate }}</strong>\n <br />\n {{ SMS_APP_NOT_SUBSCRIBED_POPOVER | translate }}\n <br />\n {{ TOTP_REQUIRES_OAUTH_POPOVER | translate }}\n </div>\n </div>\n </div>\n</div>\n" }]
}], propDecorators: { authConfiguration: [{
type: Input
}] } });
class AuthConfigurationComponent {
constructor(authConfigurationService, modalService, authService, alertService) {
this.authConfigurationService = authConfigurationService;
this.modalService = modalService;
this.authService = authService;
this.alertService = alertService;
this.reloading$ = new BehaviorSubject(false);
this.reload = new EventEmitter();
this.authConfiguration$ = this.reload.pipe(tap(() => this.reloading$.next(true)), switchMap(() => this.authConfigurationService.getAuthConfiguration$()), tap(() => this.reloading$.next(false)), shareReplay(1));
}
ngOnInit() {
this.authConfigurationSubscription = this.authConfiguration$.subscribe((authConfiguration) => {
this.authConfiguration = authConfiguration;
this.previousAuthConfiguration = cloneDeep(this.authConfiguration);
});
this.loadAuthConfig();
}
loadAuthConfig() {
this.reload.next();
}
ngOnDestroy() {
this.authConfigurationSubscription.unsubscribe();
}
async save() {
try {
await this.modalService.confirmLogout();
await this.authConfigurationService.save(this.authConfiguration, this.previousAuthConfiguration);
await this.authService.logout(true);
}
catch (ex) {
if (ex) {
this.alertService.addServerFailure(ex);
}
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationComponent, deps: [{ token: AuthConfigurationService }, { token: i2.ModalService }, { token: i2.SimplifiedAuthService }, { token: i2.AlertService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: AuthConfigurationComponent, isStandalone: true, selector: "c8y-auth-configuration", ngImport: i0, template: "<c8y-title>{{ 'Authentication' | translate }}</c8y-title>\n\n<c8y-breadcrumb>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Settings' | translate\"\n ></c8y-breadcrumb-item>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Authentication' | translate\"\n ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n <button\n class=\"btn btn-link\"\n title=\"{{ 'Reload' | translate }}\"\n (click)=\"loadAuthConfig()\"\n >\n <i\n c8yIcon=\"refresh\"\n [ngClass]=\"{ 'icon-spin': reloading$ | async }\"\n ></i>\n {{ 'Reload' | translate }}\n </button>\n</c8y-action-bar-item>\n\n<c8y-help src=\"/docs/authentication/basic-settings/#basic-settings\"></c8y-help>\n\n<form\n class=\"card card--fullpage\"\n #authConfigurationForm=\"ngForm\"\n novalidate\n>\n <div class=\"card-header separator\">\n <div class=\"card-title\">\n {{ 'Authentication' | translate }}\n </div>\n </div>\n <div\n class=\"inner-scroll\"\n *ngIf=\"authConfiguration\"\n >\n <c8y-login-settings [authConfiguration]=\"authConfiguration\"></c8y-login-settings>\n <c8y-basic-auth-settings [authConfiguration]=\"authConfiguration\"></c8y-basic-auth-settings>\n <c8y-session-configuration [authConfiguration]=\"authConfiguration\"></c8y-session-configuration>\n <c8y-auth-tfa [authConfiguration]=\"authConfiguration\"></c8y-auth-tfa>\n </div>\n <div class=\"card-footer separator\">\n <button\n class=\"btn btn-primary\"\n title=\"{{ 'Save' | translate }}\"\n type=\"submit\"\n (click)=\"save()\"\n [disabled]=\"!authConfigurationForm.form.valid || authConfigurationForm.form.pristine\"\n >\n {{ 'Save' | translate }}\n </button>\n </div>\n</form>\n", dependencies: [{ kind: "component", type: TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "component", type: BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "component", type: ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: HelpComponent, selector: "c8y-help", inputs: ["src", "isCollapsed", "priority", "icon"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LoginSettingsComponent, selector: "c8y-login-settings", inputs: ["authConfiguration"] }, { kind: "component", type: BasicAuthSettingsComponent, selector: "c8y-basic-auth-settings", inputs: ["authConfiguration"] }, { kind: "component", type: SessionConfigurationComponent, selector: "c8y-session-configuration", inputs: ["authConfiguration"] }, { kind: "component", type: TfaSettingsComponent, selector: "c8y-auth-tfa", inputs: ["authConfiguration"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-auth-configuration', imports: [
TitleComponent,
BreadcrumbComponent,
BreadcrumbItemComponent,
ActionBarItemComponent,
IconDirective,
NgClass,
HelpComponent,
FormsModule,
NgIf,
LoginSettingsComponent,
BasicAuthSettingsComponent,
SessionConfigurationComponent,
TfaSettingsComponent,
C8yTranslatePipe,
AsyncPipe
], template: "<c8y-title>{{ 'Authentication' | translate }}</c8y-title>\n\n<c8y-breadcrumb>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Settings' | translate\"\n ></c8y-breadcrumb-item>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Authentication' | translate\"\n ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n <button\n class=\"btn btn-link\"\n title=\"{{ 'Reload' | translate }}\"\n (click)=\"loadAuthConfig()\"\n >\n <i\n c8yIcon=\"refresh\"\n [ngClass]=\"{ 'icon-spin': reloading$ | async }\"\n ></i>\n {{ 'Reload' | translate }}\n </button>\n</c8y-action-bar-item>\n\n<c8y-help src=\"/docs/authentication/basic-settings/#basic-settings\"></c8y-help>\n\n<form\n class=\"card card--fullpage\"\n #authConfigurationForm=\"ngForm\"\n novalidate\n>\n <div class=\"card-header separator\">\n <div class=\"card-title\">\n {{ 'Authentication' | translate }}\n </div>\n </div>\n <div\n class=\"inner-scroll\"\n *ngIf=\"authConfiguration\"\n >\n <c8y-login-settings [authConfiguration]=\"authConfiguration\"></c8y-login-settings>\n <c8y-basic-auth-settings [authConfiguration]=\"authConfiguration\"></c8y-basic-auth-settings>\n <c8y-session-configuration [authConfiguration]=\"authConfiguration\"></c8y-session-configuration>\n <c8y-auth-tfa [authConfiguration]=\"authConfiguration\"></c8y-auth-tfa>\n </div>\n <div class=\"card-footer separator\">\n <button\n class=\"btn btn-primary\"\n title=\"{{ 'Save' | translate }}\"\n type=\"submit\"\n (click)=\"save()\"\n [disabled]=\"!authConfigurationForm.form.valid || authConfigurationForm.form.pristine\"\n >\n {{ 'Save' | translate }}\n </button>\n </div>\n</form>\n" }]
}], ctorParameters: () => [{ type: AuthConfigurationService }, { type: i2.ModalService }, { type: i2.SimplifiedAuthService }, { type: i2.AlertService }] });
class BasicSettingsModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicSettingsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: BasicSettingsModule, imports: [CoreModule,
PopoverModule,
SessionConfigurationComponent,
LoginSettingsComponent,
BasicAuthSettingsComponent,
AuthConfigurationComponent,
TfaSettingsComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicSettingsModule, providers: [
AuthConfigurationService,
TenantLoginOptionMapper,
hookRoute({
path: 'auth-configuration/basic_settings',
component: AuthConfigurationComponent,
canActivate: [AuthConfigurationGuard]
})
], imports: [CoreModule,
PopoverModule,
SessionConfigurationComponent,
LoginSettingsComponent,
BasicAuthSettingsComponent,
AuthConfigurationComponent,
TfaSettingsComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicSettingsModule, decorators: [{
type: NgModule,
args: [{
exports: [],
imports: [
CoreModule,
PopoverModule,
SessionConfigurationComponent,
LoginSettingsComponent,
BasicAuthSettingsComponent,
AuthConfigurationComponent,
TfaSettingsComponent
],
providers: [
AuthConfigurationService,
TenantLoginOptionMapper,
hookRoute({
path: 'auth-configuration/basic_settings',
component: AuthConfigurationComponent,
canActivate: [AuthConfigurationGuard]
})
]
}]
}] });
var TemplateType;
(function (TemplateType) {
TemplateType["CUSTOM"] = "CUSTOM";
TemplateType["AZURE"] = "AZURE";
TemplateType["KEYCLOAK"] = "KEYCLOAK";
})(TemplateType || (TemplateType = {}));
const templateTypeConfig = {
[TemplateType.CUSTOM]: {
name: 'CUSTOM',
value: 'CUSTOM',
label: gettext('Custom')
},
[TemplateType.AZURE]: {
name: 'AZURE',
value: 'AZURE',
label: gettext('Azure AD')
},
[TemplateType.KEYCLOAK]: {
name: 'KEYCLOAK',
value: 'KEYCLOAK',
label: gettext('Keycloak')
}
};
var ValidationMethod;
(function (ValidationMethod) {
ValidationMethod["USERINFO"] = "USERINFO";
ValidationMethod["INTROSPECTION"] = "INTROSPECTION";
})(ValidationMethod || (ValidationMethod = {}));
class SsoConfigurationService {
constructor(loginOptionsService) {
this.loginOptionsService = loginOptionsService;
this.ssoConfiguration$ = defer(() => this.loginOptionsService.detail(TenantLoginOptionType.OAUTH2)).pipe(map(res => res.data), catchError(({ res }) => {
if (res.status === HttpStatusCode.Forbidden)
return throwError(new Error());
else
return of(this.defaultConfiguration);
}), publishReplay(1, 1000), refCount(), take(1));
this.defaultConfiguration = {
authorizationRequest: {
body: '',
headers: {},
method: 'GET',
operation: 'REDIRECT',
requestParams: {
response_type: 'code',
client_id: '${clientId}',
redirect_uri: '${redirectUri}',
scope: ''
}
},
tokenRequest: {
body: 'grant_type=authorization_code&code=${code}&redirect_uri=${redirectUri}&client_id=${clientId}',
headers: {},
method: 'POST',
operation: 'EXECUTE',
requestParams: {
response_type: 'code',
client_id: '${clientId}',
redirect_uri: '${redirectUri}',
scope: ''
}
},
refreshRequest: {
body: 'grant_type=refresh_token&refresh_token=${refreshToken}&client_id=${clientId}',
headers: {
Authorization: ''
},
method: 'POST',
operation: 'EXECUTE',
requestParams: {
response_type: 'refresh',
client_id: '${clientId}'
}
},
logoutRequest: {
headers: {},
method: 'POST',
operation: 'REDIRECT',
requestParams: {}
},
type: TenantLoginOptionType.OAUTH2,
grantType: GrantType.AUTHORIZATION_CODE,
userManagementSource: UserManagementSource.REMOTE,
onNewUser: {
dynamicMapping: {
mappings: [],
inventoryMappings: [],
configuration: {
mapRolesOnlyForNewUser: false,
manageRolesOnlyFromAccessMapping: false,
mapFromIdToken: false
}
}
},
userIdConfig: {
jwtField: '',
useConstantValue: true
},
signatureVerificationConfig: {
manual: {
certIdFromField: false
}
},
template: TemplateType.CUSTOM,
clientId: '',
audience: '',
issuer: '',
buttonName: '',
redirectToPlatform: '',
providerName: '',
visibleOnLoginPage: true,
accessTokenToUserDataMappings: {},
externalTokenConfig: {
enabled: false
},
useIdToken: false
};
}
getSsoConfiguration$() {
return this.ssoConfiguration$;
}
save(ssoConfiguration) {
return this.loginOptionsService.save(ssoConfiguration);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationService, deps: [{ token: i1$1.TenantLoginOptionsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [{ type: i1$1.TenantLoginOptionsService }] });
class RequestConfiguration {
constructor(requestConfiguration) {
this.headers = new RequestConfigurationDynamicArray(requestConfiguration.headers);
this.method = requestConfiguration.method;
this.operation = requestConfiguration.operation;
this.requestParams = new RequestConfigurationDynamicArray(requestConfiguration.requestParams);
this.body = requestConfiguration.body;
this.url = requestConfiguration.url;
}
toRequest() {
return pickBy({
body: this.method === 'GET' ? '' : this.body,
headers: this.headers.toObject(),
method: this.method,
operation: this.operation,
requestParams: this.requestParams.toObject(),
url: this.url
}, identity);
}
}
// tslint:disable-next-line:max-classes-per-file
class RequestConfigurationDynamicArray extends Array {
constructor(obj) {
super();
this.push(...map$1(obj, (value, key) => ({
key,
value
})));
}
toObject() {
return this.reduce((obj, element) => {
obj[element.key] = element.value;
return obj;
}, {});
}
}
var AlgorithmType;
(function (AlgorithmType) {
AlgorithmType["PCKS"] = "PCKS";
AlgorithmType["RSA"] = "RSA";
})(AlgorithmType || (AlgorithmType = {}));
const algorithmTypeConfig = {
[AlgorithmType.PCKS]: {
name: 'PCKS',
value: 'PCKS',
label: gettext('X.509 certificate (PEM format)')
},
[AlgorithmType.RSA]: {
name: 'RSA',
value: 'RSA',
label: gettext('RSA public key (X.509 Subject Public Key Info)')
}
};
var CertificateType;
(function (CertificateType) {
CertificateType["CUSTOM"] = "CUSTOM";
CertificateType["AZURE"] = "AZURE";
CertificateType["ADFS"] = "ADFS";
CertificateType["JWKS"] = "JWKS";
})(CertificateType || (CertificateType = {}));
const certificateTypeConfig = {
[CertificateType.CUSTOM]: {
name: 'CUSTOM',
label: gettext('Custom'),
value: 'CUSTOM',
signatureVerificationConfigFragment: 'manual',
ordinal: 0
},
[CertificateType.AZURE]: {
name: 'AZURE',
label: 'Azure',
value: 'AZURE',
signatureVerificationConfigFragment: 'aad',
ordinal: 1
},
[CertificateType.ADFS]: {
name: 'ADFS',
label: gettext('ADFS manifest'),
value: 'ADFS',
signatureVerificationConfigFragment: 'adfsManifest',
ordinal: 2
},
[CertificateType.JWKS]: {
name: 'JWKS',
label: 'JWKS',
value: 'JWKS',
signatureVerificationConfigFragment: 'jwks',
ordinal: 3
}
};
class SignatureConfiguration {
constructor(signatureVerificationConfig) {
this.manual = new CustomSignatureVerification(signatureVerificationConfig.manual || { certIdFromField: false });
this.aad = signatureVerificationConfig.aad || { publicKeyDiscoveryUrl: '' };
this.jwks = signatureVerificationConfig.jwks || { jwksUri: '' };
this.adfsManifest = signatureVerificationConfig.adfsManifest || { manifestUrl: '' };
this.certificateTypeChosen = this.getCertificateType(signatureVerificationConfig);
}
toSignatureVerificationConfig() {
const result = {
manual: this.manual.toManual(),
aad: this.aad,
jwks: this.jwks,
adfsManifest: this.adfsManifest
};
return pick(result, certificateTypeConfig[this.certificateTypeChosen].signatureVerificationConfigFragment);
}
getCertificateType(signatureVerificationConfig) {
const templateCertificateType = findKey(certificateTypeConfig, certificateType => has(signatureVerificationConfig, certificateType.signatureVerificationConfigFragment));
return templateCertificateType || CertificateType.CUSTOM;
}
}
// tslint:disable-next-line:max-classes-per-file
class CustomSignatureVerification {
constructor(manual) {
this.customCertificates = [];
this.certIdFromField = manual.certIdFromField;
this.certIdField = manual.certIdField;
this.customCertificates = this.getCustomCertificates(manual);
}
getCustomCertificates(manual) {
const certificates = get(manual, 'certificates', []);
const customCertificates = map$1(certificates, (certificate, key) => ({
...certificate,
key,
validFrom: new Date(certificate.validFrom),
validTill: new Date(certificate.validTill)
}));
if (customCertificates.length === 0) {
const newCustomCertificate = { alg: 'RSA' };
customCertificates.push(newCustomCertificate);
}
return customCertificates;
}
addCustomCertificate() {
const newCustomCertificate = { alg: AlgorithmType.RSA, key: '', publicKey: '' };
this.customCertificates.push(newCustomCertificate);
}
removeCustomCertificate(customCertificate) {
const indexOfCustomCertificate = this.customCertificates.indexOf(customCertificate);
this.customCertificates.splice(indexOfCustomCertificate, 1);
}
toManual() {
const manual = this.getManualSignatureVerificationConfig();
manual.certificates = this.getSignatureCertificates();
return manual;
}
getSignatureCertificates() {
if (this.customCertificates.length < 2) {
this.customCertificates[0].key = 'default';
}
return reduce(this.customCertificates, (signatureCertificates, customCertificate) => ({
...signatureCertificates,
[customCertificate.key]: {
alg: customCertificate.alg,
publicKey: customCertificate.publicKey,
validFrom: customCertificate.validFrom,
validTill: customCertificate.validTill
}
}), {});
}
getManualSignatureVerificationConfig() {
let manual = {
certIdFromField: this.customCertificates.length > 1,
certIdField: this.certIdField
};
if (!manual.certIdFromField) {
manual = omit(manual, 'certIdField');
}
return manual;
}
}
const validationMethodConfig = {
[ValidationMethod.INTROSPECTION]: {
name: 'INTROSPECTION',
value: 'INTROSPECTION',
label: gettext('Introspection`Method of validating access token from external IAM system`'),
defaults: {
method: 'POST',
body: 'token=${accessToken}&client_id=${clientId}&client_secret=',
url: '',
headers: {},
operation: 'EXECUTE',
requestParams: {}
}
},
[ValidationMethod.USERINFO]: {
name: 'USERINFO',
value: 'USERINFO',
label: gettext('User info`Method of validating access token from external IAM system`'),
defaults: {
url: '',
method: 'GET',
body: '',
headers: { Authorization: 'Bearer ${accessToken}' },
operation: 'EXECUTE',
requestParams: {}
}
}
};
const defaultTokenValidationRequest = {
body: 'token=${accessToken}&client_id=${clientId}&client_secret=',
url: '',
headers: {},
method: 'POST',
operation: 'EXECUTE',
requestParams: {}
};
const defaultUserIdConfig = {
jwtField: '',
useConstantValue: true
};
class ExternalToken {
constructor(externalTokenConfig) {
const _externalTokenConfig = Object.assign({ enabled: false }, externalTokenConfig);
this.userOrAppIdConfig = _externalTokenConfig.userOrAppIdConfig || defaultUserIdConfig;
this.validationMethod = _externalTokenConfig.validationMethod || ValidationMethod.INTROSPECTION;
this.validationRequired = _externalTokenConfig.validationRequired;
this.enabled = _externalTokenConfig.enabled;
this.tokenValidationRequest = new RequestConfiguration(_externalTokenConfig.tokenValidationRequest || defaultTokenValidationRequest);
this.accessTokenValidityCheckIntervalInMinutes =
_externalTokenConfig.accessTokenValidityCheckIntervalInMinutes || 1;
}
toExternalTokenConfig() {
if (!this.enabled) {
return { enabled: this.enabled };
}
const externalTokenConfig = {
userOrAppIdConfig: this.userOrAppIdConfig,
validationRequired: this.validationRequired,
enabled: this.enabled
};
if (this.validationRequired) {
externalTokenConfig.validationMethod = this.validationMethod;
externalTokenConfig.tokenValidationRequest = this.tokenValidationRequest.toRequest();
externalTokenConfig.accessTokenValidityCheckIntervalInMinutes =
this.accessTokenValidityCheckIntervalInMinutes;
}
return externalTokenConfig;
}
}
class CustomConfigurationMapper {
mapFrom(templateModel) {
const ssoConfiguration = {
accessTokenToUserDataMappings: templateModel.accessTokenToUserDataMappings,
audience: templateModel.audience,
authorizationRequest: templateModel.authorizationRequest.toRequest(),
buttonName: templateModel.buttonName,
clientId: templateModel.clientId,
issuer: templateModel.issuer,
logoutRequest: templateModel.logoutRequest.toRequest(),
onNewUser: templateModel.onNewUser,
providerName: templateModel.providerName,
redirectToPlatform: templateModel.redirectToPlatform || null,
refreshRequest: templateModel.refreshRequest.toRequest(),
signatureVerificationConfig: templateModel.signatureVerificationConfig.toSignatureVerificationConfig(),
template: TemplateType.CUSTOM,
tokenRequest: templateModel.tokenRequest.toRequest(),
userIdConfig: templateModel.userIdConfig,
userManagementSource: templateModel.userManagementSource,
visibleOnLoginPage: templateModel.visibleOnLoginPage,
type: TenantLoginOptionType.OAUTH2,
grantType: GrantType.AUTHORIZATION_CODE,
externalTokenConfig: templateModel.externalTokenConfig.toExternalTokenConfig(),
useIdToken: templateModel.useIdToken
};
return ssoConfiguration;
}
mapTo(ssoConfiguration) {
return {
accessTokenToUserDataMappings: ssoConfiguration.accessTokenToUserDataMappings,
audience: ssoConfiguration.audience,
authorizationRequest: new RequestConfiguration(ssoConfiguration.authorizationRequest),
buttonName: ssoConfiguration.buttonName,
clientId: ssoConfiguration.clientId,
issuer: ssoConfiguration.issuer,
logoutRequest: new RequestConfiguration(ssoConfiguration.logoutRequest),
onNewUser: ssoConfiguration.onNewUser,
providerName: ssoConfiguration.providerName,
redirectToPlatform: ssoConfiguration.redirectToPlatform,
refreshRequest: new RequestConfiguration(ssoConfiguration.refreshRequest),
signatureVerificationConfig: new SignatureConfiguration(ssoConfiguration.signatureVerificationConfig),
template: TemplateType.CUSTOM,
tokenRequest: new RequestConfiguration(ssoConfiguration.tokenRequest),
userIdConfig: ssoConfiguration.userIdConfig,
userManagementSource: ssoConfiguration.userManagementSource,
visibleOnLoginPage: ssoConfiguration.visibleOnLoginPage,
certificateType: CertificateType.CUSTOM,
externalTokenConfig: new ExternalToken(ssoConfiguration.externalTokenConfig),
useIdToken: ssoConfiguration.useIdToken
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CustomConfigurationMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CustomConfigurationMapper, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CustomConfigurationMapper, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
class SsoConfigurationMapper {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationMapper, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationMapper, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}] });
class TemplateComponent {
constructor(configurationMapper) {
this.configurationMapper = configurationMapper;
this.ssoConfigurationChange = new EventEmitter();
}
ngOnInit() {
this.triggerSubscription = this.ssoConfigurationChangeTrigger.subscribe(() => {
this.emitSsoConfiguration();
});
}
ngOnChanges(changes) {
if (changes.ssoConfiguration && changes.ssoConfiguration.currentValue) {
this.mapSsoConfiguration(changes.ssoConfiguration.currentValue);
}
}
ngOnDestroy() {
this.triggerSubscription.unsubscribe();
}
mapSsoConfiguration(ssoConfiguration) {
this.templateModel = this.configurationMapper.mapTo(ssoConfiguration);
}
emitSsoConfiguration() {
const ssoConfiguration = this.configurationMapper.mapFrom(this.templateModel);
if (this.ssoConfiguration.id) {
ssoConfiguration.id = this.ssoConfiguration.id;
}
this.ssoConfigurationChange.emit(ssoConfiguration);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TemplateComponent, deps: [{ token: SsoConfigurationMapper }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: TemplateComponent, isStandalone: true, selector: "ng-component", inputs: { apps: "apps", groups: "groups", inventoryRoles: "inventoryRoles", ssoConfiguration: "ssoConfiguration", ssoConfigurationChangeTrigger: "ssoConfigurationChangeTrigger" }, outputs: { ssoConfigurationChange: "ssoConfigurationChange" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TemplateComponent, decorators: [{
type: Component,
args: [{
template: '',
standalone: true
}]
}], ctorParameters: () => [{ type: SsoConfigurationMapper }], propDecorators: { apps: [{
type: Input
}], groups: [{
type: Input
}], inventoryRoles: [{
type: Input
}], ssoConfiguration: [{
type: Input
}], ssoConfigurationChangeTrigger: [{
type: Input
}], ssoConfigurationChange: [{
type: Output
}] } });
class RequestConfigurationComponent {
constructor(controlContainer) {
this.controlContainer = controlContainer;
}
shouldShow(field) {
return field in this.templateModel;
}
get requestConfiguration() {
return this.templateModel[this.requestType];
}
addCustomValue(array) {
const customValue = {
key: '',
value: ''
};
array.push(customValue);
}
removeCustomValue(array, customValue) {
pull(array, customValue);
this.controlContainer.control.markAsDirty();
}
get showBody() {
return this.requestConfiguration.method === 'POST' && this.requestType !== 'logoutRequest';
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RequestConfigurationComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: RequestConfigurationComponent, isStandalone: true, selector: "c8y-request-configuration", inputs: { templateModel: "templateModel", requestName: "requestName", requestType: "requestType" }, ngImport: i0, template: "<fieldset\n class=\"p-24\"\n ngModelGroup=\"{{ requestName }}\"\n id=\"{{ requestType }}\"\n>\n <div class=\"row\">\n <div\n class=\"col-xs-12 col-sm-3 col-md-2 m-b-xs-8\"\n *ngIf=\"requestType !== 'tokenValidationRequest'\"\n >\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ requestName }}\n </div>\n </div>\n\n <div\n [ngClass]=\"\n requestType !== 'tokenValidationRequest' ? 'col-xs-12 col-sm-9 col-md-10 col-lg-9' : ''\n \"\n *ngIf=\"templateModel\"\n >\n <fieldset [ngClass]=\"requestType === 'tokenValidationRequest' ? 'c8y-fieldset p-24' : ''\">\n <legend *ngIf=\"requestType === 'tokenValidationRequest'\">\n {{ requestName }}\n </legend>\n\n <c8y-form-group>\n <label\n [for]=\"requestType + 'url'\"\n class=\"control-label\"\n translate\n >\n URL\n </label>\n <input\n type=\"url\"\n class=\"form-control\"\n name=\"url\"\n [id]=\"requestType + 'url'\"\n [(ngModel)]=\"requestConfiguration.url\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'http://www.example.com/' }\"\n c8yDefaultValidation=\"httpUrl\"\n [required]=\"requestType !== 'logoutRequest'\"\n />\n </c8y-form-group>\n\n <c8y-form-group *ngIf=\"showBody\">\n <label\n [for]=\"requestType + 'body'\"\n class=\"control-label\"\n translate\n >\n Body\n </label>\n <input\n type=\"text\"\n class=\"form-control\"\n name=\"body\"\n [id]=\"requestType + 'body'\"\n [(ngModel)]=\"requestConfiguration.body\"\n required\n />\n </c8y-form-group>\n </fieldset>\n\n <fieldset\n class=\"c8y-fieldset p-24\"\n *ngIf=\"requestType !== 'logoutRequest'\"\n >\n <legend translate>Headers</legend>\n <div\n class=\"tight-grid visible-md visible-lg\"\n *ngIf=\"requestConfiguration.headers.length > 0\"\n >\n <div class=\"col-md-6\">\n <p class=\"text-medium\">\n {{ 'Key' | translate }}\n </p>\n </div>\n <div class=\"col-md-5\">\n <p class=\"text-medium\">\n {{ 'Value' | translate }}\n </p>\n </div>\n </div>\n <div\n class=\"tight-grid\"\n data-cy=\"c8y-authentication-single-sign-on--request-header\"\n *ngFor=\"let header of requestConfiguration.headers; index as headerIndex\"\n >\n <div class=\"col-md-6\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'headerKey' + headerIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Key\n </label>\n <input\n class=\"form-control\"\n [name]=\"'headerKey' + headerIndex\"\n [id]=\"requestType + 'headerKey' + headerIndex\"\n [(ngModel)]=\"header.key\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'Authorization' }\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-5\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'headerValue' + headerIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Value\n </label>\n <input\n class=\"form-control\"\n [name]=\"'headerValue' + headerIndex\"\n [id]=\"requestType + 'headerValue' + headerIndex\"\n [(ngModel)]=\"header.value\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate: { example: 'Basic USY7jW9jb2RlX2=' }\n \"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-1\">\n <c8y-form-group>\n <button\n class=\"btn btn-link hidden-xs hidden-sm\"\n type=\"button\"\n title=\"{{ 'Remove' | translate }}\"\n (click)=\"removeCustomValue(requestConfiguration.headers, header)\"\n >\n <i\n c8yIcon=\"minus-circle\"\n class=\"text-danger\"\n ></i>\n </button>\n <button\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n title=\"{{ 'Remove' | translate }}\"\n type=\"button\"\n (click)=\"removeCustomValue(requestConfiguration.headers, header)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </c8y-form-group>\n </div>\n </div>\n <button\n class=\"btn btn-default m-t-8\"\n type=\"button\"\n title=\"{{ 'Add header' | translate }}\"\n (click)=\"addCustomValue(requestConfiguration.headers)\"\n >\n <i\n c8yIcon=\"plus-circle\"\n class=\"m-r-4\"\n ></i>\n <span translate>Add header</span>\n </button>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend translate>Request parameters</legend>\n <div\n class=\"tight-grid visible-md visible-lg\"\n *ngIf=\"requestConfiguration.requestParams.length > 0\"\n >\n <div class=\"col-md-6\">\n <p class=\"text-medium\">\n {{ 'Key' | translate }}\n </p>\n </div>\n <div class=\"col-md-5\">\n <p class=\"text-medium\">\n {{ 'Value' | translate }}\n </p>\n </div>\n </div>\n <div\n class=\"tight-grid\"\n data-cy=\"c8y-authentication-single-sign-on--request-parameter\"\n *ngFor=\"let requestParam of requestConfiguration.requestParams; index as paramIndex\"\n >\n <div class=\"col-md-6\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'paramKey' + paramIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Key\n </label>\n <input\n class=\"form-control\"\n [name]=\"'paramKey' + paramIndex\"\n [id]=\"requestType + 'paramKey' + paramIndex\"\n [(ngModel)]=\"requestParam.key\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'client_id' }\"\n required\n />\n </c8y-form-group>\n </div>\n\n <div class=\"col-md-5\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'paramValue' + paramIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Value\n </label>\n <input\n class=\"form-control\"\n [name]=\"'paramValue' + paramIndex\"\n [id]=\"requestType + 'paramValue' + paramIndex\"\n [(ngModel)]=\"requestParam.value\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: '${clientId}' }\"\n required\n />\n </c8y-form-group>\n </div>\n\n <div class=\"col-md-1\">\n <c8y-form-group>\n <button\n class=\"btn btn-link hidden-xs hidden-sm\"\n type=\"button\"\n title=\"{{ 'Remove' | translate }}\"\n (click)=\"removeCustomValue(requestConfiguration.requestParams, requestParam)\"\n >\n <i\n c8yIcon=\"minus-circle\"\n class=\"text-danger\"\n ></i>\n </button>\n\n <button\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n type=\"button\"\n title=\"{{ 'Remove' | translate }}\"\n (click)=\"removeCustomValue(requestConfiguration.requestParams, requestParam)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </c8y-form-group>\n </div>\n </div>\n\n <button\n class=\"btn btn-default m-t-8\"\n type=\"button\"\n title=\"{{ 'Add request parameter' | translate }}\"\n (click)=\"addCustomValue(requestConfiguration.requestParams)\"\n >\n <i\n c8yIcon=\"plus-circle\"\n class=\"m-r-4\"\n ></i>\n <span translate>Add request parameter</span>\n </button>\n </fieldset>\n </div>\n </div>\n</fieldset>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1.NgModelGroup, selector: "[ngModelGroup]", inputs: ["ngModelGroup"], exportAs: ["ngModelGroup"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: DefaultValidationDirective, selector: "[c8yDefaultValidation]", inputs: ["c8yDefaultValidation"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
__decorate([
memoize(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], RequestConfigurationComponent.prototype, "shouldShow", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: RequestConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-request-configuration', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
FormsModule,
NgIf,
NgClass,
FormGroupComponent,
C8yTranslateDirective,
RequiredInputPlaceholderDirective,
DefaultValidationDirective,
NgFor,
IconDirective,
C8yTranslatePipe
], template: "<fieldset\n class=\"p-24\"\n ngModelGroup=\"{{ requestName }}\"\n id=\"{{ requestType }}\"\n>\n <div class=\"row\">\n <div\n class=\"col-xs-12 col-sm-3 col-md-2 m-b-xs-8\"\n *ngIf=\"requestType !== 'tokenValidationRequest'\"\n >\n <div class=\"h4 text-normal text-right text-left-xs\">\n {{ requestName }}\n </div>\n </div>\n\n <div\n [ngClass]=\"\n requestType !== 'tokenValidationRequest' ? 'col-xs-12 col-sm-9 col-md-10 col-lg-9' : ''\n \"\n *ngIf=\"templateModel\"\n >\n <fieldset [ngClass]=\"requestType === 'tokenValidationRequest' ? 'c8y-fieldset p-24' : ''\">\n <legend *ngIf=\"requestType === 'tokenValidationRequest'\">\n {{ requestName }}\n </legend>\n\n <c8y-form-group>\n <label\n [for]=\"requestType + 'url'\"\n class=\"control-label\"\n translate\n >\n URL\n </label>\n <input\n type=\"url\"\n class=\"form-control\"\n name=\"url\"\n [id]=\"requestType + 'url'\"\n [(ngModel)]=\"requestConfiguration.url\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'http://www.example.com/' }\"\n c8yDefaultValidation=\"httpUrl\"\n [required]=\"requestType !== 'logoutRequest'\"\n />\n </c8y-form-group>\n\n <c8y-form-group *ngIf=\"showBody\">\n <label\n [for]=\"requestType + 'body'\"\n class=\"control-label\"\n translate\n >\n Body\n </label>\n <input\n type=\"text\"\n class=\"form-control\"\n name=\"body\"\n [id]=\"requestType + 'body'\"\n [(ngModel)]=\"requestConfiguration.body\"\n required\n />\n </c8y-form-group>\n </fieldset>\n\n <fieldset\n class=\"c8y-fieldset p-24\"\n *ngIf=\"requestType !== 'logoutRequest'\"\n >\n <legend translate>Headers</legend>\n <div\n class=\"tight-grid visible-md visible-lg\"\n *ngIf=\"requestConfiguration.headers.length > 0\"\n >\n <div class=\"col-md-6\">\n <p class=\"text-medium\">\n {{ 'Key' | translate }}\n </p>\n </div>\n <div class=\"col-md-5\">\n <p class=\"text-medium\">\n {{ 'Value' | translate }}\n </p>\n </div>\n </div>\n <div\n class=\"tight-grid\"\n data-cy=\"c8y-authentication-single-sign-on--request-header\"\n *ngFor=\"let header of requestConfiguration.headers; index as headerIndex\"\n >\n <div class=\"col-md-6\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'headerKey' + headerIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Key\n </label>\n <input\n class=\"form-control\"\n [name]=\"'headerKey' + headerIndex\"\n [id]=\"requestType + 'headerKey' + headerIndex\"\n [(ngModel)]=\"header.key\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'Authorization' }\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-5\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'headerValue' + headerIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Value\n </label>\n <input\n class=\"form-control\"\n [name]=\"'headerValue' + headerIndex\"\n [id]=\"requestType + 'headerValue' + headerIndex\"\n [(ngModel)]=\"header.value\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate: { example: 'Basic USY7jW9jb2RlX2=' }\n \"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-1\">\n <c8y-form-group>\n <button\n class=\"btn btn-link hidden-xs hidden-sm\"\n type=\"button\"\n title=\"{{ 'Remove' | translate }}\"\n (click)=\"removeCustomValue(requestConfiguration.headers, header)\"\n >\n <i\n c8yIcon=\"minus-circle\"\n class=\"text-danger\"\n ></i>\n </button>\n <button\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n title=\"{{ 'Remove' | translate }}\"\n type=\"button\"\n (click)=\"removeCustomValue(requestConfiguration.headers, header)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </c8y-form-group>\n </div>\n </div>\n <button\n class=\"btn btn-default m-t-8\"\n type=\"button\"\n title=\"{{ 'Add header' | translate }}\"\n (click)=\"addCustomValue(requestConfiguration.headers)\"\n >\n <i\n c8yIcon=\"plus-circle\"\n class=\"m-r-4\"\n ></i>\n <span translate>Add header</span>\n </button>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend translate>Request parameters</legend>\n <div\n class=\"tight-grid visible-md visible-lg\"\n *ngIf=\"requestConfiguration.requestParams.length > 0\"\n >\n <div class=\"col-md-6\">\n <p class=\"text-medium\">\n {{ 'Key' | translate }}\n </p>\n </div>\n <div class=\"col-md-5\">\n <p class=\"text-medium\">\n {{ 'Value' | translate }}\n </p>\n </div>\n </div>\n <div\n class=\"tight-grid\"\n data-cy=\"c8y-authentication-single-sign-on--request-parameter\"\n *ngFor=\"let requestParam of requestConfiguration.requestParams; index as paramIndex\"\n >\n <div class=\"col-md-6\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'paramKey' + paramIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Key\n </label>\n <input\n class=\"form-control\"\n [name]=\"'paramKey' + paramIndex\"\n [id]=\"requestType + 'paramKey' + paramIndex\"\n [(ngModel)]=\"requestParam.key\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'client_id' }\"\n required\n />\n </c8y-form-group>\n </div>\n\n <div class=\"col-md-5\">\n <c8y-form-group>\n <label\n [for]=\"requestType + 'paramValue' + paramIndex\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Value\n </label>\n <input\n class=\"form-control\"\n [name]=\"'paramValue' + paramIndex\"\n [id]=\"requestType + 'paramValue' + paramIndex\"\n [(ngModel)]=\"requestParam.value\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: '${clientId}' }\"\n required\n />\n </c8y-form-group>\n </div>\n\n <div class=\"col-md-1\">\n <c8y-form-group>\n <button\n class=\"btn btn-link hidden-xs hidden-sm\"\n type=\"button\"\n title=\"{{ 'Remove' | translate }}\"\n (click)=\"removeCustomValue(requestConfiguration.requestParams, requestParam)\"\n >\n <i\n c8yIcon=\"minus-circle\"\n class=\"text-danger\"\n ></i>\n </button>\n\n <button\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n type=\"button\"\n title=\"{{ 'Remove' | translate }}\"\n (click)=\"removeCustomValue(requestConfiguration.requestParams, requestParam)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </c8y-form-group>\n </div>\n </div>\n\n <button\n class=\"btn btn-default m-t-8\"\n type=\"button\"\n title=\"{{ 'Add request parameter' | translate }}\"\n (click)=\"addCustomValue(requestConfiguration.requestParams)\"\n >\n <i\n c8yIcon=\"plus-circle\"\n class=\"m-r-4\"\n ></i>\n <span translate>Add request parameter</span>\n </button>\n </fieldset>\n </div>\n </div>\n</fieldset>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }], propDecorators: { templateModel: [{
type: Input
}], requestName: [{
type: Input
}], requestType: [{
type: Input
}], shouldShow: [] } });
class UserIdConfigurationComponent {
constructor() {
this.withHeader = true;
this.componentId = 0;
}
static { this.id = 0; }
shouldShow(field) {
return field in this.userIdConfig;
}
ngOnInit() {
this.componentId = ++UserIdConfigurationComponent.id;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: UserIdConfigurationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: UserIdConfigurationComponent, isStandalone: true, selector: "c8y-user-id-configuration", inputs: { userIdConfig: "userIdConfig", withHeader: "withHeader" }, ngImport: i0, template: "<div [ngClass]=\"withHeader ? 'p-24' : 'd-contents'\">\n <div [ngClass]=\"withHeader ? 'row' : 'd-contents'\">\n <div\n class=\"col-xs-12 col-sm-3 col-md-2\"\n *ngIf=\"withHeader\"\n >\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n User ID\n </div>\n </div>\n <fieldset\n [ngClass]=\"withHeader ? 'col-xs-12 col-sm-9 col-md-10 col-lg-9' : 'c8y-fieldset p-24'\"\n >\n <legend *ngIf=\"!withHeader\">\n {{ 'User/App ID' | translate }}\n </legend>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group *ngIf=\"userIdConfig.useConstantValue\">\n <label\n class=\"control-label\"\n [for]=\"'constantValue' + componentId\"\n translate\n >\n Constant value\n </label>\n <input\n class=\"form-control\"\n type=\"text\"\n required\n [id]=\"'constantValue' + componentId\"\n [name]=\"'constantValue' + componentId\"\n [(ngModel)]=\"userIdConfig.constantValue\"\n />\n </c8y-form-group>\n <c8y-form-group *ngIf=\"!userIdConfig.useConstantValue\">\n <label\n class=\"control-label\"\n [for]=\"'jwtField' + componentId\"\n translate\n >\n JWT field\n </label>\n <input\n class=\"form-control\"\n type=\"text\"\n required\n [id]=\"'jwtField' + componentId\"\n [name]=\"'jwtField' + componentId\"\n [(ngModel)]=\"userIdConfig.jwtField\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'upn' }\"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n *ngIf=\"shouldShow('useConstantValue')\"\n >\n <div\n class=\"form-group\"\n *ngIf=\"shouldShow('useConstantValue')\"\n >\n <label\n class=\"c8y-switch m-t-24\"\n data-cy=\"c8y-authentication--external-token-configuration-constant-value-switcher\"\n title=\"{{ 'Use constant value' | translate }}\"\n [for]=\"'useConstantValue' + componentId\"\n >\n <input\n type=\"checkbox\"\n [name]=\"'useConstantValue' + componentId\"\n [id]=\"'useConstantValue' + componentId\"\n [(ngModel)]=\"userIdConfig.useConstantValue\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Use constant value' | translate }}</span>\n </label>\n </div>\n </div>\n </div>\n </div>\n </fieldset>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
__decorate([
memoize(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], UserIdConfigurationComponent.prototype, "shouldShow", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: UserIdConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-user-id-configuration', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgClass,
NgIf,
C8yTranslateDirective,
FormGroupComponent,
RequiredInputPlaceholderDirective,
FormsModule,
C8yTranslatePipe
], template: "<div [ngClass]=\"withHeader ? 'p-24' : 'd-contents'\">\n <div [ngClass]=\"withHeader ? 'row' : 'd-contents'\">\n <div\n class=\"col-xs-12 col-sm-3 col-md-2\"\n *ngIf=\"withHeader\"\n >\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n User ID\n </div>\n </div>\n <fieldset\n [ngClass]=\"withHeader ? 'col-xs-12 col-sm-9 col-md-10 col-lg-9' : 'c8y-fieldset p-24'\"\n >\n <legend *ngIf=\"!withHeader\">\n {{ 'User/App ID' | translate }}\n </legend>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group *ngIf=\"userIdConfig.useConstantValue\">\n <label\n class=\"control-label\"\n [for]=\"'constantValue' + componentId\"\n translate\n >\n Constant value\n </label>\n <input\n class=\"form-control\"\n type=\"text\"\n required\n [id]=\"'constantValue' + componentId\"\n [name]=\"'constantValue' + componentId\"\n [(ngModel)]=\"userIdConfig.constantValue\"\n />\n </c8y-form-group>\n <c8y-form-group *ngIf=\"!userIdConfig.useConstantValue\">\n <label\n class=\"control-label\"\n [for]=\"'jwtField' + componentId\"\n translate\n >\n JWT field\n </label>\n <input\n class=\"form-control\"\n type=\"text\"\n required\n [id]=\"'jwtField' + componentId\"\n [name]=\"'jwtField' + componentId\"\n [(ngModel)]=\"userIdConfig.jwtField\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'upn' }\"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n *ngIf=\"shouldShow('useConstantValue')\"\n >\n <div\n class=\"form-group\"\n *ngIf=\"shouldShow('useConstantValue')\"\n >\n <label\n class=\"c8y-switch m-t-24\"\n data-cy=\"c8y-authentication--external-token-configuration-constant-value-switcher\"\n title=\"{{ 'Use constant value' | translate }}\"\n [for]=\"'useConstantValue' + componentId\"\n >\n <input\n type=\"checkbox\"\n [name]=\"'useConstantValue' + componentId\"\n [id]=\"'useConstantValue' + componentId\"\n [(ngModel)]=\"userIdConfig.useConstantValue\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Use constant value' | translate }}</span>\n </label>\n </div>\n </div>\n </div>\n </div>\n </fieldset>\n </div>\n</div>\n" }]
}], propDecorators: { userIdConfig: [{
type: Input
}], withHeader: [{
type: Input
}], shouldShow: [] } });
class ExternalTokenConfigComponent {
constructor() {
this.validationMethods = validationMethodConfig;
}
get externalTokenConfig() {
return this.templateModel.externalTokenConfig;
}
onValidationMethodChange(event) {
this.externalTokenConfig.validationMethod = event;
this.externalTokenConfig.tokenValidationRequest = new RequestConfiguration(this.validationMethods[event].defaults);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ExternalTokenConfigComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: ExternalTokenConfigComponent, isStandalone: true, selector: "c8y-external-token-config", inputs: { templateModel: "templateModel" }, ngImport: i0, template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n External token configuration\n </div>\n </div>\n\n <div\n class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\"\n *ngIf=\"templateModel\"\n >\n <label\n class=\"c8y-switch\"\n data-cy=\"c8y-authentication--external-token-configuration-switcher\"\n title=\"{{ 'Allow authentication with access token from external IAM system' | translate }}\"\n >\n <input\n id=\"enabled\"\n name=\"enabled\"\n type=\"checkbox\"\n [(ngModel)]=\"externalTokenConfig.enabled\"\n />\n <span></span>\n <span class=\"control-label\">\n {{ 'Allow authentication with access token from external IAM system' | translate }}\n </span>\n </label>\n\n <div\n class=\"collapse\"\n [collapse]=\"!externalTokenConfig.enabled\"\n [isAnimated]=\"true\"\n >\n <ng-container *ngIf=\"externalTokenConfig.enabled\">\n <c8y-user-id-configuration\n [userIdConfig]=\"externalTokenConfig.userOrAppIdConfig\"\n [withHeader]=\"false\"\n ></c8y-user-id-configuration>\n\n <label\n class=\"c8y-switch\"\n title=\"{{ 'Validate access token' | translate }}\"\n for=\"validationRequired\"\n >\n <input\n id=\"validationRequired\"\n name=\"validationRequired\"\n type=\"checkbox\"\n [(ngModel)]=\"externalTokenConfig.validationRequired\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Validate access token' | translate }}</span>\n </label>\n <div\n class=\"collapse\"\n [collapse]=\"!externalTokenConfig.validationRequired\"\n [isAnimated]=\"true\"\n >\n <ng-container *ngIf=\"externalTokenConfig.validationRequired\">\n <div class=\"row\">\n <div class=\"col-sm-6 m-t-16\">\n <label\n class=\"control-label\"\n for=\"validationMethod\"\n translate\n >\n Validation method\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n id=\"validationMethod\"\n name=\"validationMethod\"\n [ngModel]=\"externalTokenConfig.validationMethod\"\n (ngModelChange)=\"onValidationMethodChange($event)\"\n >\n <option\n *ngFor=\"let validationMethod of validationMethods | keyvalue\"\n [ngValue]=\"validationMethod.key\"\n >\n {{ validationMethod.value.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <c8y-request-configuration\n [templateModel]=\"externalTokenConfig\"\n [requestName]=\"'Token validation request' | translate\"\n [requestType]=\"'tokenValidationRequest'\"\n ></c8y-request-configuration>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6 m-l-8\">\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"accessTokenValidityCheckIntervalInMinutes\"\n translate\n >\n Access token validation frequency\n </label>\n <div class=\"input-group\">\n <input\n class=\"form-control\"\n id=\"accessTokenValidityCheckIntervalInMinutes\"\n name=\"accessTokenValidityCheckIntervalInMinutes\"\n type=\"number\"\n required\n [(ngModel)]=\"externalTokenConfig.accessTokenValidityCheckIntervalInMinutes\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: '1' }\"\n step=\"1\"\n [min]=\"1\"\n />\n <span\n class=\"input-group-addon\"\n translate\n >\n minutes\n </span>\n </div>\n </c8y-form-group>\n </div>\n </div>\n </ng-container>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: CollapseDirective, selector: "[collapse]", inputs: ["display", "isAnimated", "collapse"], outputs: ["collapsed", "collapses", "expanded", "expands"], exportAs: ["bs-collapse"] }, { kind: "component", type: UserIdConfigurationComponent, selector: "c8y-user-id-configuration", inputs: ["userIdConfig", "withHeader"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: RequestConfigurationComponent, selector: "c8y-request-configuration", inputs: ["templateModel", "requestName", "requestType"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: MinValidationDirective, selector: "[min]", inputs: ["min"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ExternalTokenConfigComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-external-token-config', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
NgIf,
FormsModule,
CollapseDirective,
UserIdConfigurationComponent,
NgFor,
RequestConfigurationComponent,
FormGroupComponent,
RequiredInputPlaceholderDirective,
MinValidationDirective,
C8yTranslatePipe,
KeyValuePipe
], template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n External token configuration\n </div>\n </div>\n\n <div\n class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\"\n *ngIf=\"templateModel\"\n >\n <label\n class=\"c8y-switch\"\n data-cy=\"c8y-authentication--external-token-configuration-switcher\"\n title=\"{{ 'Allow authentication with access token from external IAM system' | translate }}\"\n >\n <input\n id=\"enabled\"\n name=\"enabled\"\n type=\"checkbox\"\n [(ngModel)]=\"externalTokenConfig.enabled\"\n />\n <span></span>\n <span class=\"control-label\">\n {{ 'Allow authentication with access token from external IAM system' | translate }}\n </span>\n </label>\n\n <div\n class=\"collapse\"\n [collapse]=\"!externalTokenConfig.enabled\"\n [isAnimated]=\"true\"\n >\n <ng-container *ngIf=\"externalTokenConfig.enabled\">\n <c8y-user-id-configuration\n [userIdConfig]=\"externalTokenConfig.userOrAppIdConfig\"\n [withHeader]=\"false\"\n ></c8y-user-id-configuration>\n\n <label\n class=\"c8y-switch\"\n title=\"{{ 'Validate access token' | translate }}\"\n for=\"validationRequired\"\n >\n <input\n id=\"validationRequired\"\n name=\"validationRequired\"\n type=\"checkbox\"\n [(ngModel)]=\"externalTokenConfig.validationRequired\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Validate access token' | translate }}</span>\n </label>\n <div\n class=\"collapse\"\n [collapse]=\"!externalTokenConfig.validationRequired\"\n [isAnimated]=\"true\"\n >\n <ng-container *ngIf=\"externalTokenConfig.validationRequired\">\n <div class=\"row\">\n <div class=\"col-sm-6 m-t-16\">\n <label\n class=\"control-label\"\n for=\"validationMethod\"\n translate\n >\n Validation method\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n id=\"validationMethod\"\n name=\"validationMethod\"\n [ngModel]=\"externalTokenConfig.validationMethod\"\n (ngModelChange)=\"onValidationMethodChange($event)\"\n >\n <option\n *ngFor=\"let validationMethod of validationMethods | keyvalue\"\n [ngValue]=\"validationMethod.key\"\n >\n {{ validationMethod.value.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <c8y-request-configuration\n [templateModel]=\"externalTokenConfig\"\n [requestName]=\"'Token validation request' | translate\"\n [requestType]=\"'tokenValidationRequest'\"\n ></c8y-request-configuration>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6 m-l-8\">\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"accessTokenValidityCheckIntervalInMinutes\"\n translate\n >\n Access token validation frequency\n </label>\n <div class=\"input-group\">\n <input\n class=\"form-control\"\n id=\"accessTokenValidityCheckIntervalInMinutes\"\n name=\"accessTokenValidityCheckIntervalInMinutes\"\n type=\"number\"\n required\n [(ngModel)]=\"externalTokenConfig.accessTokenValidityCheckIntervalInMinutes\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: '1' }\"\n step=\"1\"\n [min]=\"1\"\n />\n <span\n class=\"input-group-addon\"\n translate\n >\n minutes\n </span>\n </div>\n </c8y-form-group>\n </div>\n </div>\n </ng-container>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n</div>\n" }]
}], propDecorators: { templateModel: [{
type: Input
}] } });
class BasicConfigurationComponent {
constructor(tenantService) {
this.tenantService = tenantService;
this.REDIRECT_TO_THE_USER_INTERFACE_APPLICATION_TOOLTIP = gettext("The redirect URL is automatically set to the application used by the user. In case of an error, it will be correctly displayed on the application's page.");
this.flowControlledByUI = false;
this.redirectToPlatform = '';
}
shouldShow(field) {
return field in this.templateModel;
}
async ngOnChanges() {
const currentTenant = (await this.tenantService.current()).data;
const { domainName } = currentTenant;
this.redirectToPlatformWarningParams = {
host: `https://${domainName}`,
defaultRedirectUrl: `https://${domainName}/tenant/oauth`
};
this.redirectToPlatform = this.templateModel.redirectToPlatform || '';
this.flowControlledByUI = !this.templateModel.redirectToPlatform;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicConfigurationComponent, deps: [{ token: i1$1.TenantService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: BasicConfigurationComponent, isStandalone: true, selector: "c8y-basic-configuration", inputs: { templateModel: "templateModel" }, usesOnChanges: true, ngImport: i0, template: "<fieldset class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2 m-b-xs-8\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n Basic\n </div>\n </div>\n\n <div\n class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\"\n *ngIf=\"templateModel\"\n >\n <div class=\"row\">\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('keyCloakAddress')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"keyCloakAddress\"\n translate\n >\n Keycloak address\n </label>\n <input\n class=\"form-control\"\n id=\"keyCloakAddress\"\n name=\"keyCloakAddress\"\n type=\"url\"\n required\n [(ngModel)]=\"templateModel.keyCloakAddress\"\n [placeholder]=\"'e.g. {{ example }}' | translate : { example: 'https://example.de' }\"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('aadAddress')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"aadAddress\"\n translate\n >\n Azure AD address\n </label>\n <input\n class=\"form-control\"\n id=\"aadAddress\"\n name=\"aadAddress\"\n type=\"url\"\n required\n [(ngModel)]=\"templateModel.aadAddress\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate : { example: 'https://login.microsoftonline.de' }\n \"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('tenant')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"tenant\"\n translate\n >\n Tenant\n </label>\n <input\n class=\"form-control\"\n id=\"tenant\"\n name=\"tenant\"\n required\n [(ngModel)]=\"templateModel.tenant\"\n [placeholder]=\"'e.g. {{ example }}' | translate : { example: 'c8y.onmicrosoft.de' }\"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('applicationId')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"applicationId\"\n translate\n >\n Application ID\n </label>\n <input\n class=\"form-control\"\n id=\"applicationId\"\n name=\"applicationId\"\n required\n [(ngModel)]=\"templateModel.applicationId\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('realmName')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"realmName\"\n translate\n >\n Realm name\n </label>\n <input\n class=\"form-control\"\n id=\"realmName\"\n name=\"realmName\"\n required\n [(ngModel)]=\"templateModel.realmName\"\n />\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\" *ngIf=\"shouldShow('redirectToPlatform')\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"redirectToPlatform\"\n >\n {{ 'Redirect URL' | translate }}\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n [popover]=\"helpContent\"\n placement=\"bottom\"\n triggers=\"focus\"\n type=\"button\"\n [adaptivePosition]=\"false\"\n *ngIf=\"\n !flowControlledByUI &&\n redirectToPlatformWarningParams &&\n templateModel.redirectToPlatform !=\n redirectToPlatformWarningParams.defaultRedirectUrl\n \"\n ></button>\n <ng-template #helpContent>\n <span\n ngNonBindable\n translate\n [translateParams]=\"redirectToPlatformWarningParams\"\n >\n For correct application behavior you can use only \"{{ host }}\" or \"{{\n defaultRedirectUrl\n }}\", the latter one is recommended.\n </span>\n </ng-template>\n </label>\n <input\n class=\"form-control\"\n id=\"redirectToPlatform\"\n name=\"redirectToPlatform\"\n type=\"url\"\n [required]=\"!flowControlledByUI\"\n [disabled]=\"flowControlledByUI\"\n [(ngModel)]=\"templateModel.redirectToPlatform\"\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate\n : {\n example:\n redirectToPlatformWarningParams?.defaultRedirectUrl ||\n 'https://tenant.domain.com'\n }\n \"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n >\n <label\n class=\"c8y-switch m-t-24\"\n title=\"{{ 'Redirect to the user interface application`SSO authentication`' | translate }}\"\n for=\"flowControlledByUI\"\n >\n <input\n type=\"checkbox\"\n name=\"flowControlledByUI\"\n id=\"flowControlledByUI\"\n [(ngModel)]=\"flowControlledByUI\"\n (change)=\"templateModel.redirectToPlatform = flowControlledByUI ? '' : redirectToPlatform\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Redirect to the user interface application`SSO authentication`' | translate }}</span>\n <button\n type=\"button\"\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ REDIRECT_TO_THE_USER_INTERFACE_APPLICATION_TOOLTIP | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n </div>\n </div>\n <div class=\"col-sm-12\">\n <div *ngIf=\"flowControlledByUI && redirectToPlatform != ''\">\n <div class=\"alert alert-warning max-width-100 m-b-32\"\n ngNonBindable\n translate\n [translateParams]=\"{\n redirectURI: '<tenant_domain>/apps/*'\n }\">\n Make sure that \"Valid Redirect URIs\" in the authorization server is set to \"{{ redirectURI }}\" or to the full URIs of the used applications if the authorization server does not support patterns.\n </div>\n </div>\n <div *ngIf=\"!flowControlledByUI && redirectToPlatform === ''\">\n <div class=\"alert alert-warning max-width-100 m-b-32\"\n ngNonBindable\n translate\n [translateParams]=\"{\n redirectURI: '<tenant_domain>/tenant/oauth'\n }\">\n Make sure that \"Valid Redirect URIs\" in the authorization server is set to \"{{ redirectURI }}\".\n </div>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('clientSecret')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"clientSecret\"\n translate\n >\n Client secret\n </label>\n <input\n class=\"form-control\"\n id=\"clientSecret\"\n name=\"clientSecret\"\n required\n [(ngModel)]=\"templateModel.clientSecret\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('clientId')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"clientId\"\n translate\n >\n Client ID\n </label>\n <input\n class=\"form-control\"\n id=\"clientId\"\n name=\"clientId\"\n required\n [(ngModel)]=\"templateModel.clientId\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate : { example: '254234981c-78a8-4588\u2026' }\n \"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('issuer')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"issuer\"\n translate\n >\n Token issuer\n </label>\n <input\n class=\"form-control\"\n id=\"issuer\"\n name=\"issuer\"\n required\n [(ngModel)]=\"templateModel.issuer\"\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate : { example: 'https://login.microsoftonline.de/237652-3727' }\n \"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('scopeId')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"scopeId\"\n translate\n >\n Scope ID\n </label>\n <input\n class=\"form-control\"\n id=\"scopeId\"\n name=\"scopeId\"\n [(ngModel)]=\"templateModel.scopeId\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: '237652-3727' }\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('buttonName')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"buttonName\"\n translate\n >\n Button name\n </label>\n <input\n class=\"form-control\"\n id=\"buttonName\"\n name=\"buttonName\"\n required\n [(ngModel)]=\"templateModel.buttonName\"\n [placeholder]=\"'e.g. Log in with Azure AD' | translate\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('providerName')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"providerName\"\n translate\n >\n Provider name\n </label>\n <input\n class=\"form-control\"\n id=\"providerName\"\n name=\"providerName\"\n required\n [(ngModel)]=\"templateModel.providerName\"\n [placeholder]=\"'e.g. {{ example }}' | translate : { example: 'Azure AD' }\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('audience')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"audience\"\n translate\n >\n Audience\n </label>\n <input\n class=\"form-control\"\n id=\"audience\"\n name=\"audience\"\n required\n [(ngModel)]=\"templateModel.audience\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate : { example: 'https://test.example.com' }\n \"\n />\n </c8y-form-group>\n </div>\n </div>\n\n <div\n class=\"row\"\n *ngIf=\"shouldShow('visibleOnLoginPage')\"\n >\n <div class=\"col-sm-6\">\n <label\n class=\"c8y-switch\"\n title=\"{{ 'Visible on login page' | translate }}\"\n for=\"visibleOnLoginPage\"\n >\n <input\n id=\"visibleOnLoginPage\"\n name=\"visibleOnLoginPage\"\n type=\"checkbox\"\n [(ngModel)]=\"templateModel.visibleOnLoginPage\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Visible on login page' | translate }}</span>\n </label>\n </div>\n </div>\n </div>\n </div>\n</fieldset>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
__decorate([
memoize(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], BasicConfigurationComponent.prototype, "shouldShow", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: BasicConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-basic-configuration', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
NgIf,
FormGroupComponent,
RequiredInputPlaceholderDirective,
FormsModule,
PopoverDirective,
C8yTranslatePipe
], template: "<fieldset class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2 m-b-xs-8\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n Basic\n </div>\n </div>\n\n <div\n class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\"\n *ngIf=\"templateModel\"\n >\n <div class=\"row\">\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('keyCloakAddress')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"keyCloakAddress\"\n translate\n >\n Keycloak address\n </label>\n <input\n class=\"form-control\"\n id=\"keyCloakAddress\"\n name=\"keyCloakAddress\"\n type=\"url\"\n required\n [(ngModel)]=\"templateModel.keyCloakAddress\"\n [placeholder]=\"'e.g. {{ example }}' | translate : { example: 'https://example.de' }\"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('aadAddress')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"aadAddress\"\n translate\n >\n Azure AD address\n </label>\n <input\n class=\"form-control\"\n id=\"aadAddress\"\n name=\"aadAddress\"\n type=\"url\"\n required\n [(ngModel)]=\"templateModel.aadAddress\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate : { example: 'https://login.microsoftonline.de' }\n \"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('tenant')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"tenant\"\n translate\n >\n Tenant\n </label>\n <input\n class=\"form-control\"\n id=\"tenant\"\n name=\"tenant\"\n required\n [(ngModel)]=\"templateModel.tenant\"\n [placeholder]=\"'e.g. {{ example }}' | translate : { example: 'c8y.onmicrosoft.de' }\"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('applicationId')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"applicationId\"\n translate\n >\n Application ID\n </label>\n <input\n class=\"form-control\"\n id=\"applicationId\"\n name=\"applicationId\"\n required\n [(ngModel)]=\"templateModel.applicationId\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('realmName')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"realmName\"\n translate\n >\n Realm name\n </label>\n <input\n class=\"form-control\"\n id=\"realmName\"\n name=\"realmName\"\n required\n [(ngModel)]=\"templateModel.realmName\"\n />\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\" *ngIf=\"shouldShow('redirectToPlatform')\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"redirectToPlatform\"\n >\n {{ 'Redirect URL' | translate }}\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n [popover]=\"helpContent\"\n placement=\"bottom\"\n triggers=\"focus\"\n type=\"button\"\n [adaptivePosition]=\"false\"\n *ngIf=\"\n !flowControlledByUI &&\n redirectToPlatformWarningParams &&\n templateModel.redirectToPlatform !=\n redirectToPlatformWarningParams.defaultRedirectUrl\n \"\n ></button>\n <ng-template #helpContent>\n <span\n ngNonBindable\n translate\n [translateParams]=\"redirectToPlatformWarningParams\"\n >\n For correct application behavior you can use only \"{{ host }}\" or \"{{\n defaultRedirectUrl\n }}\", the latter one is recommended.\n </span>\n </ng-template>\n </label>\n <input\n class=\"form-control\"\n id=\"redirectToPlatform\"\n name=\"redirectToPlatform\"\n type=\"url\"\n [required]=\"!flowControlledByUI\"\n [disabled]=\"flowControlledByUI\"\n [(ngModel)]=\"templateModel.redirectToPlatform\"\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate\n : {\n example:\n redirectToPlatformWarningParams?.defaultRedirectUrl ||\n 'https://tenant.domain.com'\n }\n \"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n >\n <label\n class=\"c8y-switch m-t-24\"\n title=\"{{ 'Redirect to the user interface application`SSO authentication`' | translate }}\"\n for=\"flowControlledByUI\"\n >\n <input\n type=\"checkbox\"\n name=\"flowControlledByUI\"\n id=\"flowControlledByUI\"\n [(ngModel)]=\"flowControlledByUI\"\n (change)=\"templateModel.redirectToPlatform = flowControlledByUI ? '' : redirectToPlatform\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Redirect to the user interface application`SSO authentication`' | translate }}</span>\n <button\n type=\"button\"\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ REDIRECT_TO_THE_USER_INTERFACE_APPLICATION_TOOLTIP | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n ></button>\n </label>\n </div>\n </div>\n <div class=\"col-sm-12\">\n <div *ngIf=\"flowControlledByUI && redirectToPlatform != ''\">\n <div class=\"alert alert-warning max-width-100 m-b-32\"\n ngNonBindable\n translate\n [translateParams]=\"{\n redirectURI: '<tenant_domain>/apps/*'\n }\">\n Make sure that \"Valid Redirect URIs\" in the authorization server is set to \"{{ redirectURI }}\" or to the full URIs of the used applications if the authorization server does not support patterns.\n </div>\n </div>\n <div *ngIf=\"!flowControlledByUI && redirectToPlatform === ''\">\n <div class=\"alert alert-warning max-width-100 m-b-32\"\n ngNonBindable\n translate\n [translateParams]=\"{\n redirectURI: '<tenant_domain>/tenant/oauth'\n }\">\n Make sure that \"Valid Redirect URIs\" in the authorization server is set to \"{{ redirectURI }}\".\n </div>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('clientSecret')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"clientSecret\"\n translate\n >\n Client secret\n </label>\n <input\n class=\"form-control\"\n id=\"clientSecret\"\n name=\"clientSecret\"\n required\n [(ngModel)]=\"templateModel.clientSecret\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('clientId')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"clientId\"\n translate\n >\n Client ID\n </label>\n <input\n class=\"form-control\"\n id=\"clientId\"\n name=\"clientId\"\n required\n [(ngModel)]=\"templateModel.clientId\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate : { example: '254234981c-78a8-4588\u2026' }\n \"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('issuer')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"issuer\"\n translate\n >\n Token issuer\n </label>\n <input\n class=\"form-control\"\n id=\"issuer\"\n name=\"issuer\"\n required\n [(ngModel)]=\"templateModel.issuer\"\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate : { example: 'https://login.microsoftonline.de/237652-3727' }\n \"\n />\n </c8y-form-group>\n </div>\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('scopeId')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"scopeId\"\n translate\n >\n Scope ID\n </label>\n <input\n class=\"form-control\"\n id=\"scopeId\"\n name=\"scopeId\"\n [(ngModel)]=\"templateModel.scopeId\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: '237652-3727' }\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('buttonName')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"buttonName\"\n translate\n >\n Button name\n </label>\n <input\n class=\"form-control\"\n id=\"buttonName\"\n name=\"buttonName\"\n required\n [(ngModel)]=\"templateModel.buttonName\"\n [placeholder]=\"'e.g. Log in with Azure AD' | translate\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('providerName')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"providerName\"\n translate\n >\n Provider name\n </label>\n <input\n class=\"form-control\"\n id=\"providerName\"\n name=\"providerName\"\n required\n [(ngModel)]=\"templateModel.providerName\"\n [placeholder]=\"'e.g. {{ example }}' | translate : { example: 'Azure AD' }\"\n />\n </c8y-form-group>\n </div>\n\n <div\n class=\"col-sm-6\"\n *ngIf=\"shouldShow('audience')\"\n >\n <c8y-form-group>\n <label\n class=\"control-label\"\n for=\"audience\"\n translate\n >\n Audience\n </label>\n <input\n class=\"form-control\"\n id=\"audience\"\n name=\"audience\"\n required\n [(ngModel)]=\"templateModel.audience\"\n [placeholder]=\"\n 'e.g. {{ example }}' | translate : { example: 'https://test.example.com' }\n \"\n />\n </c8y-form-group>\n </div>\n </div>\n\n <div\n class=\"row\"\n *ngIf=\"shouldShow('visibleOnLoginPage')\"\n >\n <div class=\"col-sm-6\">\n <label\n class=\"c8y-switch\"\n title=\"{{ 'Visible on login page' | translate }}\"\n for=\"visibleOnLoginPage\"\n >\n <input\n id=\"visibleOnLoginPage\"\n name=\"visibleOnLoginPage\"\n type=\"checkbox\"\n [(ngModel)]=\"templateModel.visibleOnLoginPage\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Visible on login page' | translate }}</span>\n </label>\n </div>\n </div>\n </div>\n </div>\n</fieldset>\n" }]
}], ctorParameters: () => [{ type: i1$1.TenantService }], propDecorators: { templateModel: [{
type: Input
}], shouldShow: [] } });
class PaginatedListGroupComponent {
constructor() {
this.items = [];
this.itemsPerPage = 5;
this.currentPage = 1;
this.currentPageItems = [];
this.cdr = inject(ChangeDetectorRef);
this.host = inject(ElementRef);
this.renderer = inject(Renderer2);
}
ngOnInit() {
this.updateCurrentPageItems();
}
ngOnChanges() {
this.updateCurrentPageItems();
}
ngAfterViewInit() {
if (!this.itemTemplate) {
throw new Error('c8y-paginated-list-group requires an <ng-template> to be provided.');
}
this.updateCurrentPageItems();
}
pageChanged(event) {
this.currentPage = event.page;
this.itemsPerPage = event.itemsPerPage;
this.updateCurrentPageItems();
this.cdr.detectChanges();
// keep the pagination component in view after page change:
const pagination = this.host.nativeElement.querySelector('pagination');
if (pagination.scrollIntoView) {
pagination.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}
updateCurrentPageItems() {
this.currentPageItems = this.items.slice((this.currentPage - 1) * this.itemsPerPage, this.currentPage * this.itemsPerPage);
}
getItemIndex(item) {
return this.items.indexOf(item);
}
goToLastItem() {
const lastPage = Math.ceil(this.items.length / this.itemsPerPage) || 1;
this.currentPage = lastPage;
this.updateCurrentPageItems();
this.cdr.detectChanges();
const root = this.host.nativeElement;
const listItems = root.querySelectorAll('c8y-li:not(.sticky-bottom)');
if (listItems.length > 0) {
const lastItem = listItems[listItems.length - 1];
if (lastItem.scrollIntoView) {
lastItem.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
this.renderer.addClass(lastItem, 'highlighted');
setTimeout(() => this.renderer.removeClass(lastItem, 'highlighted'), 2000);
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: PaginatedListGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: PaginatedListGroupComponent, isStandalone: true, selector: "c8y-paginated-list-group", inputs: { items: "items", itemsPerPage: "itemsPerPage" }, queries: [{ propertyName: "itemTemplate", first: true, predicate: TemplateRef, descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"container-fluid\"\n *ngIf=\"items.length > 0\"\n>\n <c8y-list-group>\n <c8y-li *ngFor=\"let item of currentPageItems; let i = index\">\n <ng-container\n *ngTemplateOutlet=\"itemTemplate; context: { $implicit: item, index: getItemIndex(item) }\"\n ></ng-container>\n </c8y-li>\n <c8y-li class=\"sticky-bottom\">\n <pagination\n [totalItems]=\"items.length\"\n [(ngModel)]=\"currentPage\"\n [ngModelOptions]=\"{ standalone: true }\"\n [itemsPerPage]=\"itemsPerPage\"\n (pageChanged)=\"pageChanged($event)\"\n [maxSize]=\"10\"\n [boundaryLinks]=\"true\"\n previousText=\" \"\n nextText=\" \"\n firstText=\"«\"\n lastText=\"»\"\n ></pagination>\n </c8y-li>\n </c8y-list-group>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i2.ListGroupComponent, selector: "c8y-list-group" }, { kind: "component", type: i2.ListItemComponent, selector: "c8y-list-item, c8y-li", inputs: ["active", "highlighted", "emptyActions", "dense", "collapsed", "selectable"], outputs: ["collapsedChange"] }, { kind: "ngmodule", type: PaginationModule }, { kind: "component", type: i4.PaginationComponent, selector: "pagination", inputs: ["align", "maxSize", "boundaryLinks", "directionLinks", "firstText", "previousText", "nextText", "lastText", "rotate", "pageBtnClass", "disabled", "customPageTemplate", "customNextTemplate", "customPreviousTemplate", "customFirstTemplate", "customLastTemplate", "itemsPerPage", "totalItems"], outputs: ["numPages", "pageChanged"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: PaginatedListGroupComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-paginated-list-group', standalone: true, imports: [CoreModule, PaginationModule], template: "<div\n class=\"container-fluid\"\n *ngIf=\"items.length > 0\"\n>\n <c8y-list-group>\n <c8y-li *ngFor=\"let item of currentPageItems; let i = index\">\n <ng-container\n *ngTemplateOutlet=\"itemTemplate; context: { $implicit: item, index: getItemIndex(item) }\"\n ></ng-container>\n </c8y-li>\n <c8y-li class=\"sticky-bottom\">\n <pagination\n [totalItems]=\"items.length\"\n [(ngModel)]=\"currentPage\"\n [ngModelOptions]=\"{ standalone: true }\"\n [itemsPerPage]=\"itemsPerPage\"\n (pageChanged)=\"pageChanged($event)\"\n [maxSize]=\"10\"\n [boundaryLinks]=\"true\"\n previousText=\" \"\n nextText=\" \"\n firstText=\"«\"\n lastText=\"»\"\n ></pagination>\n </c8y-li>\n </c8y-list-group>\n</div>\n" }]
}], propDecorators: { items: [{
type: Input
}], itemsPerPage: [{
type: Input
}], itemTemplate: [{
type: ContentChild,
args: [TemplateRef]
}] } });
const relations = [
{
name: 'EQ',
value: 'EQ',
label: '=',
ordinal: 0
},
{
name: 'NEQ',
value: 'NEQ',
label: '!=',
ordinal: 1
},
{
name: 'GT',
value: 'GT',
label: '>',
ordinal: 2
},
{
name: 'LT',
value: 'LT',
label: '<',
ordinal: 3
},
{
name: 'GTE',
value: 'GTE',
label: '>=',
ordinal: 4
},
{
name: 'LTE',
value: 'LTE',
label: '<=',
ordinal: 5
},
{
name: 'IN',
value: 'IN',
label: gettext('in`value-range`'),
ordinal: 6
}
];
class ChildPredicatesComponent {
constructor(controlContainer) {
this.controlContainer = controlContainer;
this.onRemoveAllChildPredicates = new EventEmitter();
this.relations = relations;
}
removeChildPredicate(childPredicate) {
pull(this.childPredicates, childPredicate);
if (this.childPredicates.length === 0) {
this.onRemoveAllChildPredicates.emit();
}
this.controlContainer.control.markAsDirty();
}
addChildPredicate() {
this.childPredicates.push({
operator: 'EQ',
parameterPath: '',
value: ''
});
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ChildPredicatesComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: ChildPredicatesComponent, isStandalone: true, selector: "c8y-sso-child-predicates", inputs: { childPredicates: "childPredicates", accessMappingIndex: "accessMappingIndex" }, outputs: { onRemoveAllChildPredicates: "onRemoveAllChildPredicates" }, ngImport: i0, template: "<fieldset class=\"c8y-fieldset p-16\">\n <legend>{{ 'When' | translate }}</legend>\n <div class=\"tight-grid hidden-sm hidden-xs\">\n <div class=\"col-md-4\">\n <label translate>Key</label>\n </div>\n <div class=\"col-md-2\">\n <label translate>Operator`logical`</label>\n </div>\n <div class=\"col-md-4\">\n <label translate>Value</label>\n </div>\n </div>\n <div\n class=\"tight-grid\"\n *ngFor=\"let childPredicate of childPredicates; last as isLast; index as idx\"\n >\n <div class=\"col-md-4\">\n <c8y-form-group>\n <label\n [for]=\"'parameterPath' + accessMappingIndex + idx\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Key\n </label>\n <input\n [name]=\"'parameterPath' + accessMappingIndex + idx\"\n [id]=\"'parameterPath' + accessMappingIndex + idx\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"childPredicate.parameterPath\"\n placeholder=\"{{ 'Key' | translate }}\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-2\">\n <c8y-form-group>\n <label\n [for]=\"'operator' + accessMappingIndex + idx\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Operator`logical`\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n [name]=\"'operator' + accessMappingIndex + idx\"\n [id]=\"'operator' + accessMappingIndex + idx\"\n [(ngModel)]=\"childPredicate.operator\"\n required\n >\n <option\n *ngFor=\"let relation of relations\"\n [ngValue]=\"relation.value\"\n >\n {{ relation.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"col-md-4\">\n <c8y-form-group>\n <label\n [for]=\"'value' + accessMappingIndex + idx\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Value\n </label>\n <input\n [id]=\"'value' + accessMappingIndex + idx\"\n [name]=\"'value' + accessMappingIndex + idx\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"childPredicate.value\"\n placeholder=\"{{ 'Value' | translate }}\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-1\">\n <c8y-form-group>\n <button\n class=\"btn btn-dot btn-dot--danger hidden-xs hidden-sm\"\n name=\"removeButton\"\n (click)=\"removeChildPredicate(childPredicate)\"\n tooltip=\"{{ 'Remove' | translate }}\"\n [attr.aria-label]=\"'Remove' | translate\"\n [delay]=\"300\"\n type=\"button\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n </button>\n <button\n name=\"removeButton\"\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n (click)=\"removeChildPredicate(childPredicate)\"\n title=\"{{ 'Remove' | translate }}\"\n type=\"button\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </c8y-form-group>\n </div>\n <div class=\"col-md-1\">\n <c8y-form-group *ngIf=\"isLast\">\n <button\n title=\"{{ 'and' | translate }}\"\n class=\"btn btn-default btn-block btn-sm\"\n (click)=\"addChildPredicate()\"\n type=\"button\"\n translate\n >\n and\n </button>\n </c8y-form-group>\n </div>\n </div>\n</fieldset>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: TooltipDirective, selector: "[tooltip], [tooltipHtml]", inputs: ["adaptivePosition", "tooltip", "placement", "triggers", "container", "containerClass", "boundariesElement", "isOpen", "isDisabled", "delay", "tooltipHtml", "tooltipPlacement", "tooltipIsOpen", "tooltipEnable", "tooltipAppendToBody", "tooltipAnimation", "tooltipClass", "tooltipContext", "tooltipPopupDelay", "tooltipFadeDuration", "tooltipTrigger"], outputs: ["tooltipChange", "onShown", "onHidden", "tooltipStateChanged"], exportAs: ["bs-tooltip"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ChildPredicatesComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-child-predicates', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
NgFor,
FormGroupComponent,
RequiredInputPlaceholderDirective,
FormsModule,
TooltipDirective,
IconDirective,
NgIf,
C8yTranslatePipe
], template: "<fieldset class=\"c8y-fieldset p-16\">\n <legend>{{ 'When' | translate }}</legend>\n <div class=\"tight-grid hidden-sm hidden-xs\">\n <div class=\"col-md-4\">\n <label translate>Key</label>\n </div>\n <div class=\"col-md-2\">\n <label translate>Operator`logical`</label>\n </div>\n <div class=\"col-md-4\">\n <label translate>Value</label>\n </div>\n </div>\n <div\n class=\"tight-grid\"\n *ngFor=\"let childPredicate of childPredicates; last as isLast; index as idx\"\n >\n <div class=\"col-md-4\">\n <c8y-form-group>\n <label\n [for]=\"'parameterPath' + accessMappingIndex + idx\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Key\n </label>\n <input\n [name]=\"'parameterPath' + accessMappingIndex + idx\"\n [id]=\"'parameterPath' + accessMappingIndex + idx\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"childPredicate.parameterPath\"\n placeholder=\"{{ 'Key' | translate }}\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-2\">\n <c8y-form-group>\n <label\n [for]=\"'operator' + accessMappingIndex + idx\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Operator`logical`\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n [name]=\"'operator' + accessMappingIndex + idx\"\n [id]=\"'operator' + accessMappingIndex + idx\"\n [(ngModel)]=\"childPredicate.operator\"\n required\n >\n <option\n *ngFor=\"let relation of relations\"\n [ngValue]=\"relation.value\"\n >\n {{ relation.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </c8y-form-group>\n </div>\n <div class=\"col-md-4\">\n <c8y-form-group>\n <label\n [for]=\"'value' + accessMappingIndex + idx\"\n class=\"visible-sm visible-xs\"\n translate\n >\n Value\n </label>\n <input\n [id]=\"'value' + accessMappingIndex + idx\"\n [name]=\"'value' + accessMappingIndex + idx\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"childPredicate.value\"\n placeholder=\"{{ 'Value' | translate }}\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-1\">\n <c8y-form-group>\n <button\n class=\"btn btn-dot btn-dot--danger hidden-xs hidden-sm\"\n name=\"removeButton\"\n (click)=\"removeChildPredicate(childPredicate)\"\n tooltip=\"{{ 'Remove' | translate }}\"\n [attr.aria-label]=\"'Remove' | translate\"\n [delay]=\"300\"\n type=\"button\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n </button>\n <button\n name=\"removeButton\"\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n (click)=\"removeChildPredicate(childPredicate)\"\n title=\"{{ 'Remove' | translate }}\"\n type=\"button\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </c8y-form-group>\n </div>\n <div class=\"col-md-1\">\n <c8y-form-group *ngIf=\"isLast\">\n <button\n title=\"{{ 'and' | translate }}\"\n class=\"btn btn-default btn-block btn-sm\"\n (click)=\"addChildPredicate()\"\n type=\"button\"\n translate\n >\n and\n </button>\n </c8y-form-group>\n </div>\n </div>\n</fieldset>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }], propDecorators: { childPredicates: [{
type: Input
}], accessMappingIndex: [{
type: Input
}], onRemoveAllChildPredicates: [{
type: Output
}] } });
class DynamicAccessMappingComponent {
constructor(controlContainer) {
this.controlContainer = controlContainer;
this.onRemoveAccessMapping = new EventEmitter();
}
ngOnChanges() {
if (this.accessMapping && this.apps && this.groups) {
this.setSelectedItems();
}
}
onRemoveAllChildPredicates() {
this.onRemoveAccessMapping.emit(this.accessMapping);
}
getIds(selectedItems) {
return selectedItems.map(item => parseInt(item.id, 10));
}
setSelectedItems() {
if (this.accessMapping) {
if (this.accessMapping.thenGroups) {
this.selectedGroups = this.groups.filter(item => this.accessMapping.thenGroups.includes(item.id));
}
if (this.accessMapping.thenApplications) {
this.selectedApps = this.apps.filter(item => this.accessMapping.thenApplications.includes(+item.id));
}
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DynamicAccessMappingComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: DynamicAccessMappingComponent, isStandalone: true, selector: "c8y-sso-dynamic-access-mapping", inputs: { groups: "groups", apps: "apps", accessMapping: "accessMapping", accessMappingIndex: "accessMappingIndex" }, outputs: { onRemoveAccessMapping: "onRemoveAccessMapping" }, usesOnChanges: true, ngImport: i0, template: "<fieldset class=\"c8y-fieldset p-8\">\n <div *ngIf=\"accessMapping.when.childPredicates.length != 0\">\n <c8y-sso-child-predicates\n [childPredicates]=\"accessMapping.when.childPredicates\"\n [accessMappingIndex]=\"'am' + accessMappingIndex\"\n (onRemoveAllChildPredicates)=\"onRemoveAllChildPredicates()\"\n ></c8y-sso-child-predicates>\n\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>\n {{ 'Provide access to' | translate }}\n </legend>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n title=\"{{ 'Default global roles' | translate }}\"\n >\n <label\n class=\"control-label\"\n [for]=\"'groups' + accessMappingIndex\"\n >\n {{ 'Default global roles' | translate }}\n </label>\n <c8y-select-legacy\n [id]=\"'groups' + accessMappingIndex\"\n [items]=\"groups\"\n [selected]=\"selectedGroups\"\n [disableApplyOnNoSelection]=\"true\"\n (onChange)=\"\n controlContainer.control.markAsDirty();\n selectedGroups = $event;\n accessMapping.thenGroups = getIds($event)\n \"\n [addDropdownContainerToBody]=\"true\"\n ></c8y-select-legacy>\n </div>\n </div>\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n title=\"{{ 'Default applications' | translate }}\"\n >\n <label\n class=\"control-label\"\n [for]=\"'apps' + accessMappingIndex\"\n >\n {{ 'Default applications' | translate }}\n </label>\n <c8y-select-legacy\n [id]=\"'apps' + accessMappingIndex\"\n [items]=\"apps\"\n [selected]=\"selectedApps\"\n [disableApplyOnNoSelection]=\"true\"\n (onChange)=\"\n controlContainer.control.markAsDirty();\n selectedApps = $event;\n accessMapping.thenApplications = getIds($event)\n \"\n [addDropdownContainerToBody]=\"true\"\n ></c8y-select-legacy>\n </div>\n </div>\n </div>\n </fieldset>\n </div>\n</fieldset>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ChildPredicatesComponent, selector: "c8y-sso-child-predicates", inputs: ["childPredicates", "accessMappingIndex"], outputs: ["onRemoveAllChildPredicates"] }, { kind: "component", type: SelectLegacyComponent, selector: "c8y-select-legacy", inputs: ["placeholder", "selectedLabel", "applyLabel", "items", "selected", "updateItems", "disableApplyOnNoSelection", "addDropdownContainerToBody"], outputs: ["onChange"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: DynamicAccessMappingComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-dynamic-access-mapping', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [NgIf, ChildPredicatesComponent, SelectLegacyComponent, C8yTranslatePipe], template: "<fieldset class=\"c8y-fieldset p-8\">\n <div *ngIf=\"accessMapping.when.childPredicates.length != 0\">\n <c8y-sso-child-predicates\n [childPredicates]=\"accessMapping.when.childPredicates\"\n [accessMappingIndex]=\"'am' + accessMappingIndex\"\n (onRemoveAllChildPredicates)=\"onRemoveAllChildPredicates()\"\n ></c8y-sso-child-predicates>\n\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>\n {{ 'Provide access to' | translate }}\n </legend>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n title=\"{{ 'Default global roles' | translate }}\"\n >\n <label\n class=\"control-label\"\n [for]=\"'groups' + accessMappingIndex\"\n >\n {{ 'Default global roles' | translate }}\n </label>\n <c8y-select-legacy\n [id]=\"'groups' + accessMappingIndex\"\n [items]=\"groups\"\n [selected]=\"selectedGroups\"\n [disableApplyOnNoSelection]=\"true\"\n (onChange)=\"\n controlContainer.control.markAsDirty();\n selectedGroups = $event;\n accessMapping.thenGroups = getIds($event)\n \"\n [addDropdownContainerToBody]=\"true\"\n ></c8y-select-legacy>\n </div>\n </div>\n <div class=\"col-sm-6\">\n <div\n class=\"form-group\"\n title=\"{{ 'Default applications' | translate }}\"\n >\n <label\n class=\"control-label\"\n [for]=\"'apps' + accessMappingIndex\"\n >\n {{ 'Default applications' | translate }}\n </label>\n <c8y-select-legacy\n [id]=\"'apps' + accessMappingIndex\"\n [items]=\"apps\"\n [selected]=\"selectedApps\"\n [disableApplyOnNoSelection]=\"true\"\n (onChange)=\"\n controlContainer.control.markAsDirty();\n selectedApps = $event;\n accessMapping.thenApplications = getIds($event)\n \"\n [addDropdownContainerToBody]=\"true\"\n ></c8y-select-legacy>\n </div>\n </div>\n </div>\n </fieldset>\n </div>\n</fieldset>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }], propDecorators: { groups: [{
type: Input
}], apps: [{
type: Input
}], accessMapping: [{
type: Input
}], onRemoveAccessMapping: [{
type: Output
}], accessMappingIndex: [{
type: Input
}] } });
class InventoryRolesModalComponent {
constructor(modal) {
this.modal = modal;
this.resultEmitter = new EventEmitter();
this.label = gettext('Groups');
}
dismiss() {
this.modal.hide();
}
select() {
this.resultEmitter.emit(this.selectedGroups);
this.modal.hide();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: InventoryRolesModalComponent, deps: [{ token: i1$3.BsModalRef }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: InventoryRolesModalComponent, isStandalone: true, selector: "c8y-sso-inventory-roles-modal", ngImport: i0, template: "<div class=\"viewport-modal\">\n <div class=\"modal-header dialog-header\">\n <i c8yIcon=\"c8y-group-open\"></i>\n <h4 id=\"modal-title\">{{ 'Select from inventory' | translate }}</h4>\n </div>\n <div class=\"modal-inner-scroll\">\n <div\n id=\"modal-body\"\n class=\"bg-component\"\n >\n <c8y-asset-selector\n class=\"d-contents\"\n [(ngModel)]=\"selectedGroups\"\n [config]=\"{\n label: label,\n showFilter: true,\n multi: true,\n groupsSelectable: true,\n columnHeaders: false,\n singleColumn: true,\n groupsOnly: true\n }\"\n ></c8y-asset-selector>\n </div>\n </div>\n\n <div class=\"modal-footer\">\n <button\n class=\"btn btn-default\"\n type=\"button\"\n title=\"{{ 'Cancel' | translate }}\"\n (click)=\"dismiss()\"\n >\n {{ 'Cancel' | translate }}\n </button>\n <button\n class=\"btn btn-primary\"\n type=\"button\"\n title=\"{{ 'Select' | translate }}\"\n (click)=\"select()\"\n >\n {{ 'Select' | translate }}\n </button>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "component", type: AssetSelectorComponent, selector: "c8y-asset-selector", inputs: ["config", "active", "index", "asset", "selectedDevice", "selected", "rootNode", "selectedItems", "container", "isNodeSelectable", "disabled"], outputs: ["onSelected", "onClearSelected", "onRowSelected", "onLoad"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: InventoryRolesModalComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-inventory-roles-modal', imports: [IconDirective, AssetSelectorComponent, FormsModule, C8yTranslatePipe], template: "<div class=\"viewport-modal\">\n <div class=\"modal-header dialog-header\">\n <i c8yIcon=\"c8y-group-open\"></i>\n <h4 id=\"modal-title\">{{ 'Select from inventory' | translate }}</h4>\n </div>\n <div class=\"modal-inner-scroll\">\n <div\n id=\"modal-body\"\n class=\"bg-component\"\n >\n <c8y-asset-selector\n class=\"d-contents\"\n [(ngModel)]=\"selectedGroups\"\n [config]=\"{\n label: label,\n showFilter: true,\n multi: true,\n groupsSelectable: true,\n columnHeaders: false,\n singleColumn: true,\n groupsOnly: true\n }\"\n ></c8y-asset-selector>\n </div>\n </div>\n\n <div class=\"modal-footer\">\n <button\n class=\"btn btn-default\"\n type=\"button\"\n title=\"{{ 'Cancel' | translate }}\"\n (click)=\"dismiss()\"\n >\n {{ 'Cancel' | translate }}\n </button>\n <button\n class=\"btn btn-primary\"\n type=\"button\"\n title=\"{{ 'Select' | translate }}\"\n (click)=\"select()\"\n >\n {{ 'Select' | translate }}\n </button>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1$3.BsModalRef }] });
class InventoryRolesMappingComponent {
constructor(controlContainer, bsModal) {
this.controlContainer = controlContainer;
this.bsModal = bsModal;
this.inventoryRoles = [];
this.selectedInventoryRoles = [];
this.onRemoveInventoryMapping = new EventEmitter();
}
ngOnChanges() {
this.setSelectedInventoryRoles();
}
onRemoveAllChildPredicates() {
this.onRemoveInventoryMapping.emit(this.inventoryMapping);
}
getIds(selectedItems) {
return selectedItems.map(item => item.id);
}
removeInventoryRole(inventoryRole) {
this.inventoryMapping.thenInventoryRoles = this.inventoryMapping.thenInventoryRoles.filter(value => value.managedObject !== inventoryRole.managedObject);
delete this.selectedInventoryRoles[inventoryRole.managedObject];
}
addInventoryRoles() {
const currentlySelectedGroups = this.inventoryMapping.thenInventoryRoles.map(inventoryRole => ({ id: inventoryRole.managedObject }));
const modal = this.bsModal.show(InventoryRolesModalComponent, {
ignoreBackdropClick: true,
class: 'modal-sm',
ariaDescribedby: 'modal-body',
ariaLabelledBy: 'modal-title',
initialState: {
selectedGroups: currentlySelectedGroups
}
});
modal.content.resultEmitter
.pipe(take(1), tap(() => this.controlContainer.control.markAsDirty()))
.subscribe(selectedGroups => {
const newSelectedGroups = selectedGroups.filter(group => !currentlySelectedGroups.some(({ id }) => id === group.id));
const newInventoryRoles = newSelectedGroups.map(group => ({ managedObject: group.id, roleIds: [] }));
this.inventoryMapping.thenInventoryRoles =
this.inventoryMapping.thenInventoryRoles.concat(newInventoryRoles);
});
}
setSelectedInventoryRoles() {
if (this.inventoryMapping && this.inventoryMapping.thenInventoryRoles && this.inventoryRoles) {
this.inventoryMapping.thenInventoryRoles.forEach(inventoryRole => {
this.selectedInventoryRoles[inventoryRole.managedObject] = this.inventoryRoles.filter(item => inventoryRole.roleIds.includes(+item.id));
});
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: InventoryRolesMappingComponent, deps: [{ token: i1.ControlContainer }, { token: i1$3.BsModalService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: InventoryRolesMappingComponent, isStandalone: true, selector: "c8y-sso-inventory-roles-mapping", inputs: { inventoryMapping: "inventoryMapping", inventoryMappingIndex: "inventoryMappingIndex", inventoryRoles: "inventoryRoles" }, outputs: { onRemoveInventoryMapping: "onRemoveInventoryMapping" }, usesOnChanges: true, ngImport: i0, template: "<fieldset class=\"c8y-fieldset p-t-8 p-b-8 p-l-16 p-r-16\">\n <div *ngIf=\"inventoryMapping.when.childPredicates.length !== 0\">\n <c8y-sso-child-predicates\n [childPredicates]=\"inventoryMapping.when.childPredicates\"\n [accessMappingIndex]=\"'irm' + inventoryMappingIndex\"\n (onRemoveAllChildPredicates)=\"onRemoveAllChildPredicates()\"\n ></c8y-sso-child-predicates>\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>\n {{ 'Provide inventory roles' | translate }}\n </legend>\n <div\n class=\"p-l-8 p-r-8\"\n *ngIf=\"inventoryMapping.thenInventoryRoles.length !== 0\"\n >\n <div class=\"tight-grid p-b-8 separator-bottom hidden-sm hidden-xs\">\n <div class=\"col-md-5\">\n <label translate>Groups</label>\n </div>\n <div class=\"col-md-6\">\n <label translate>Inventory roles</label>\n </div>\n </div>\n <div\n class=\"tight-grid d-flex-md a-i-center p-t-8 p-b-8 separator-bottom\"\n *ngFor=\"let inventoryRole of inventoryMapping.thenInventoryRoles; index as idx\"\n >\n <div class=\"col-md-5\">\n <div class=\"d-flex a-i-center\">\n <!-- TODO:\n We need to retrive the icon here, for groups there are 3 possible icons:\n \u2022 Regular group\n \u2022 Remote group\n \u2022 Smartgroup\n Besides groups, there's also Assets from DTM, in which each asset has a different icon\n -->\n <i\n class=\"m-r-8 text-16\"\n c8yIcon=\"c8y-group\"\n ></i>\n <span\n class=\"text-truncate\"\n title=\"{{ inventoryRole.managedObject | moName | async }}\"\n >\n {{ inventoryRole.managedObject | moName | async }}\n </span>\n </div>\n </div>\n <div class=\"col-md-6\">\n <div\n class=\"form-group m-b-0\"\n title=\"{{ 'Inventory roles' | translate }}\"\n >\n <c8y-select-legacy\n [id]=\"'ir' + idx + '_' + 'irm' + inventoryMappingIndex\"\n [items]=\"inventoryRoles\"\n [selected]=\"selectedInventoryRoles[inventoryRole.managedObject]\"\n [disableApplyOnNoSelection]=\"true\"\n (onChange)=\"\n controlContainer.control.markAsDirty();\n selectedInventoryRoles[inventoryRole.managedObject] = $event;\n inventoryRole.roleIds = getIds($event)\n \"\n [addDropdownContainerToBody]=\"true\"\n ></c8y-select-legacy>\n </div>\n </div>\n <div class=\"col-md-1\">\n <button\n class=\"btn btn-dot btn-dot--danger hidden-xs hidden-sm\"\n [attr.aria-label]=\"'Remove' | translate\"\n tooltip=\"{{ 'Remove' | translate }}\"\n name=\"removeButton\"\n type=\"button\"\n (click)=\"controlContainer.control.markAsDirty(); removeInventoryRole(inventoryRole)\"\n [delay]=\"300\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n </button>\n <button\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n title=\"{{ 'Remove' | translate }}\"\n name=\"removeButton\"\n type=\"button\"\n (click)=\"controlContainer.control.markAsDirty(); removeInventoryRole(inventoryRole)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </div>\n </div>\n </div>\n\n <button\n class=\"btn btn-default m-t-16\"\n title=\"{{ 'Add inventory roles' | translate }}\"\n id=\"add-inventory-roles-button\"\n type=\"button\"\n (click)=\"addInventoryRoles()\"\n >\n <i\n class=\"m-r-4\"\n c8yIcon=\"plus-circle\"\n ></i>\n {{ 'Add inventory roles' | translate }}\n </button>\n </fieldset>\n </div>\n</fieldset>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ChildPredicatesComponent, selector: "c8y-sso-child-predicates", inputs: ["childPredicates", "accessMappingIndex"], outputs: ["onRemoveAllChildPredicates"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "component", type: SelectLegacyComponent, selector: "c8y-select-legacy", inputs: ["placeholder", "selectedLabel", "applyLabel", "items", "selected", "updateItems", "disableApplyOnNoSelection", "addDropdownContainerToBody"], outputs: ["onChange"] }, { kind: "directive", type: TooltipDirective, selector: "[tooltip], [tooltipHtml]", inputs: ["adaptivePosition", "tooltip", "placement", "triggers", "container", "containerClass", "boundariesElement", "isOpen", "isDisabled", "delay", "tooltipHtml", "tooltipPlacement", "tooltipIsOpen", "tooltipEnable", "tooltipAppendToBody", "tooltipAnimation", "tooltipClass", "tooltipContext", "tooltipPopupDelay", "tooltipFadeDuration", "tooltipTrigger"], outputs: ["tooltipChange", "onShown", "onHidden", "tooltipStateChanged"], exportAs: ["bs-tooltip"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: MoNamePipe, name: "moName" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: InventoryRolesMappingComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-inventory-roles-mapping', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
ChildPredicatesComponent,
C8yTranslateDirective,
NgFor,
IconDirective,
SelectLegacyComponent,
TooltipDirective,
C8yTranslatePipe,
AsyncPipe,
MoNamePipe
], template: "<fieldset class=\"c8y-fieldset p-t-8 p-b-8 p-l-16 p-r-16\">\n <div *ngIf=\"inventoryMapping.when.childPredicates.length !== 0\">\n <c8y-sso-child-predicates\n [childPredicates]=\"inventoryMapping.when.childPredicates\"\n [accessMappingIndex]=\"'irm' + inventoryMappingIndex\"\n (onRemoveAllChildPredicates)=\"onRemoveAllChildPredicates()\"\n ></c8y-sso-child-predicates>\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>\n {{ 'Provide inventory roles' | translate }}\n </legend>\n <div\n class=\"p-l-8 p-r-8\"\n *ngIf=\"inventoryMapping.thenInventoryRoles.length !== 0\"\n >\n <div class=\"tight-grid p-b-8 separator-bottom hidden-sm hidden-xs\">\n <div class=\"col-md-5\">\n <label translate>Groups</label>\n </div>\n <div class=\"col-md-6\">\n <label translate>Inventory roles</label>\n </div>\n </div>\n <div\n class=\"tight-grid d-flex-md a-i-center p-t-8 p-b-8 separator-bottom\"\n *ngFor=\"let inventoryRole of inventoryMapping.thenInventoryRoles; index as idx\"\n >\n <div class=\"col-md-5\">\n <div class=\"d-flex a-i-center\">\n <!-- TODO:\n We need to retrive the icon here, for groups there are 3 possible icons:\n \u2022 Regular group\n \u2022 Remote group\n \u2022 Smartgroup\n Besides groups, there's also Assets from DTM, in which each asset has a different icon\n -->\n <i\n class=\"m-r-8 text-16\"\n c8yIcon=\"c8y-group\"\n ></i>\n <span\n class=\"text-truncate\"\n title=\"{{ inventoryRole.managedObject | moName | async }}\"\n >\n {{ inventoryRole.managedObject | moName | async }}\n </span>\n </div>\n </div>\n <div class=\"col-md-6\">\n <div\n class=\"form-group m-b-0\"\n title=\"{{ 'Inventory roles' | translate }}\"\n >\n <c8y-select-legacy\n [id]=\"'ir' + idx + '_' + 'irm' + inventoryMappingIndex\"\n [items]=\"inventoryRoles\"\n [selected]=\"selectedInventoryRoles[inventoryRole.managedObject]\"\n [disableApplyOnNoSelection]=\"true\"\n (onChange)=\"\n controlContainer.control.markAsDirty();\n selectedInventoryRoles[inventoryRole.managedObject] = $event;\n inventoryRole.roleIds = getIds($event)\n \"\n [addDropdownContainerToBody]=\"true\"\n ></c8y-select-legacy>\n </div>\n </div>\n <div class=\"col-md-1\">\n <button\n class=\"btn btn-dot btn-dot--danger hidden-xs hidden-sm\"\n [attr.aria-label]=\"'Remove' | translate\"\n tooltip=\"{{ 'Remove' | translate }}\"\n name=\"removeButton\"\n type=\"button\"\n (click)=\"controlContainer.control.markAsDirty(); removeInventoryRole(inventoryRole)\"\n [delay]=\"300\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n </button>\n <button\n class=\"btn btn-danger btn-block btn-sm visible-xs visible-sm\"\n title=\"{{ 'Remove' | translate }}\"\n name=\"removeButton\"\n type=\"button\"\n (click)=\"controlContainer.control.markAsDirty(); removeInventoryRole(inventoryRole)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n <span translate>Remove</span>\n </button>\n </div>\n </div>\n </div>\n\n <button\n class=\"btn btn-default m-t-16\"\n title=\"{{ 'Add inventory roles' | translate }}\"\n id=\"add-inventory-roles-button\"\n type=\"button\"\n (click)=\"addInventoryRoles()\"\n >\n <i\n class=\"m-r-4\"\n c8yIcon=\"plus-circle\"\n ></i>\n {{ 'Add inventory roles' | translate }}\n </button>\n </fieldset>\n </div>\n</fieldset>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }, { type: i1$3.BsModalService }], propDecorators: { inventoryMapping: [{
type: Input
}], inventoryMappingIndex: [{
type: Input
}], inventoryRoles: [{
type: Input
}], onRemoveInventoryMapping: [{
type: Output
}] } });
class AccessMappingComponent {
constructor(controlContainer, cdr) {
this.controlContainer = controlContainer;
this.cdr = cdr;
this.USE_ACCESS_MAPPING_ON_USER_CREATION_TOOLTIP = gettext('The access mapping will be executed only once during the first login, then the administrator can edit the user roles. During the next login, these mappings will not be executed.');
this.USE_ACCESS_MAPPING_ON_USER_CREATION_OPTION = gettext('Use dynamic access mapping only on user creation');
this.UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_TOOLTIP = gettext('The access mapping will be executed only once during the first login, then the administrator can edit the user roles. During the next login only the roles listed in the access mappings will be updated.');
this.UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_OPTION = gettext('Roles selected in the rules below will be reassigned to a user on each log in and other ones will be unchanged');
this.CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_TOOLTIP = gettext('The access mapping will be executed during the first login. The administrator cannot edit the SSO user roles. During the next login all the roles will be cleared and the mapping will be executed again.');
this.CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_OPTION = gettext('Roles selected in the rules below will be reassigned to a user on each log in and other ones will be cleared');
this.RETRIVE_FROM_ACCESS_TOKEN = gettext('Retrieve from Access token');
this.RETRIVE_FROM_ID_TOKEN = gettext('Retrieve from ID token');
}
ngOnChanges() {
if (this.templateModel && this.apps && this.groups) {
this.setDynamicMapping();
}
}
addAccessMapping() {
const emptyMapping = {
when: {
operator: 'AND',
childPredicates: [{ parameterPath: '', operator: 'EQ', value: '' }]
},
thenGroups: [],
thenApplications: []
};
const accessMappings = this.templateModel.onNewUser.dynamicMapping.mappings;
this.templateModel.onNewUser.dynamicMapping.mappings = [...accessMappings, emptyMapping];
this.cdr.detectChanges(); // Ensure items are updated in the pagination component before navigating
this.paginatedAccessMappings.goToLastItem();
}
addInventoryMapping() {
const emptyInventoryMapping = {
when: {
operator: 'AND',
childPredicates: [{ parameterPath: '', operator: 'EQ', value: '' }]
},
thenInventoryRoles: []
};
const inventoryMappings = this.templateModel.onNewUser.dynamicMapping.inventoryMappings;
this.templateModel.onNewUser.dynamicMapping.inventoryMappings = [
...inventoryMappings,
emptyInventoryMapping
];
this.cdr.detectChanges(); // Ensure items are updated in the pagination component before navigating
this.paginatedInventoryMappings.goToLastItem();
}
onRemove(accessMapping) {
const accessMappings = this.templateModel.onNewUser.dynamicMapping.mappings;
this.templateModel.onNewUser.dynamicMapping.mappings = accessMappings.filter(mapping => mapping !== accessMapping);
}
onRemoveInventoryMapping(inventoryMapping) {
const inventoryMappings = this.templateModel.onNewUser.dynamicMapping.inventoryMappings;
this.templateModel.onNewUser.dynamicMapping.inventoryMappings = inventoryMappings.filter(mapping => mapping !== inventoryMapping);
}
setDynamicMappingConfiguration(mapRolesOnlyForNewUser, manageRolesOnlyFromAccessMapping = false) {
this.dynamicMappingConfiguration.mapRolesOnlyForNewUser = mapRolesOnlyForNewUser;
this.dynamicMappingConfiguration.manageRolesOnlyFromAccessMapping =
manageRolesOnlyFromAccessMapping;
this.controlContainer.control.markAsDirty();
}
get mapRolesOnlyForNewUser() {
return this.dynamicMappingConfiguration.mapRolesOnlyForNewUser;
}
get manageRolesOnlyFromAccessMapping() {
return this.dynamicMappingConfiguration.manageRolesOnlyFromAccessMapping;
}
get mapFromIdToken() {
return this.dynamicMappingConfiguration.mapFromIdToken;
}
setMapFromIdToken(mapFromIdToken) {
this.dynamicMappingConfiguration.mapFromIdToken = mapFromIdToken;
this.controlContainer.control.markAsDirty();
}
get dynamicMappingConfiguration() {
return this.templateModel.onNewUser.dynamicMapping.configuration;
}
setDynamicMapping() {
defaultsDeep(this.templateModel.onNewUser, {
dynamicMapping: {
mappings: [],
inventoryMappings: [],
configuration: {
mapRolesOnlyForNewUser: false,
manageRolesOnlyFromAccessMapping: false
}
}
});
const { configuration } = this.templateModel.onNewUser.dynamicMapping;
const { mapRolesOnlyForNewUser, manageRolesOnlyFromAccessMapping, mapFromIdToken } = configuration;
configuration.mapFromIdToken =
mapFromIdToken !== undefined
? mapFromIdToken
: mapRolesOnlyForNewUser === false && manageRolesOnlyFromAccessMapping === false;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AccessMappingComponent, deps: [{ token: i1.ControlContainer }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: AccessMappingComponent, isStandalone: true, selector: "c8y-sso-access-mapping", inputs: { apps: "apps", groups: "groups", inventoryRoles: "inventoryRoles", templateModel: "templateModel" }, viewQueries: [{ propertyName: "paginatedAccessMappings", first: true, predicate: ["paginatedAccessMappings"], descendants: true }, { propertyName: "paginatedInventoryMappings", first: true, predicate: ["paginatedInventoryMappings"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n Access mapping\n </div>\n </div>\n\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>{{ 'Source of dynamic access mapping' | translate }}</legend>\n <c8y-form-group>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingSource\"\n type=\"radio\"\n data-cy=\"dynamic-access-mapping-from-access-token\"\n [checked]=\"!mapFromIdToken\"\n (change)=\"setMapFromIdToken(false)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}</span>\n </label>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ RETRIVE_FROM_ID_TOKEN | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingSource\"\n type=\"radio\"\n data-cy=\"dynamic-access-mapping-from-id-token\"\n [checked]=\"mapFromIdToken\"\n (change)=\"setMapFromIdToken(true)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ID_TOKEN | translate }}</span>\n </label>\n </c8y-form-group>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>{{ 'Dynamic access mapping principle' | translate }}</legend>\n <c8y-form-group>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ USE_ACCESS_MAPPING_ON_USER_CREATION_OPTION | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingConfiguration\"\n type=\"radio\"\n data-cy=\"c8y-inventory-roles-mapping--on-user-creation\"\n [checked]=\"mapRolesOnlyForNewUser\"\n (change)=\"setDynamicMappingConfiguration(true)\"\n />\n <span></span>\n <span>{{ USE_ACCESS_MAPPING_ON_USER_CREATION_OPTION | translate }}</span>\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ USE_ACCESS_MAPPING_ON_USER_CREATION_TOOLTIP | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n type=\"button\"\n ></button>\n </label>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_OPTION | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingConfiguration\"\n type=\"radio\"\n data-cy=\"c8y-inventory-roles-mapping--other-ones-will-be-unchanged\"\n [checked]=\"!mapRolesOnlyForNewUser && manageRolesOnlyFromAccessMapping\"\n (change)=\"setDynamicMappingConfiguration(false, true)\"\n />\n <span></span>\n <span>\n {{ UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_OPTION | translate }}\n </span>\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{\n UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_TOOLTIP | translate\n }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n type=\"button\"\n ></button>\n </label>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_OPTION | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingConfiguration\"\n type=\"radio\"\n data-cy=\"c8y-inventory-roles-mapping--other-ones-will-be-cleared\"\n [checked]=\"!mapRolesOnlyForNewUser && !manageRolesOnlyFromAccessMapping\"\n (change)=\"setDynamicMappingConfiguration(false, false)\"\n />\n <span></span>\n <span>\n {{ CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_OPTION | translate }}\n </span>\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_TOOLTIP | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n type=\"button\"\n ></button>\n </label>\n </c8y-form-group>\n </fieldset>\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>{{ 'Dynamic access mapping' | translate }}</legend>\n <c8y-ui-empty-state\n [icon]=\"'list'\"\n [title]=\"'No access mapping rules defined.' | translate\"\n [subtitle]=\"'Click below to add a new mapping.' | translate\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.mappings.length === 0\"\n [horizontal]=\"true\"\n ></c8y-ui-empty-state>\n <div\n class=\"container-fluid\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.mappings.length > 0\"\n >\n <c8y-paginated-list-group\n #paginatedAccessMappings\n [items]=\"templateModel.onNewUser.dynamicMapping.mappings\"\n >\n <ng-template\n let-accessMapping\n let-index=\"index\"\n >\n <c8y-sso-dynamic-access-mapping\n [accessMapping]=\"accessMapping\"\n (onRemoveAccessMapping)=\"onRemove(accessMapping)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [accessMappingIndex]=\"index\"\n ></c8y-sso-dynamic-access-mapping>\n </ng-template>\n </c8y-paginated-list-group>\n </div>\n <div class=\"p-t-16\">\n <button\n class=\"btn btn-default\"\n title=\"{{ 'Add access mapping' | translate }}\"\n id=\"add-access-mapping-button\"\n type=\"button\"\n (click)=\"addAccessMapping()\"\n >\n <i\n class=\"m-r-4\"\n c8yIcon=\"plus-circle\"\n ></i>\n {{ 'Add access mapping' | translate }}\n </button>\n </div>\n </fieldset>\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>\n {{ 'Inventory roles mapping' | translate }}\n </legend>\n <c8y-ui-empty-state\n [icon]=\"'list'\"\n [title]=\"'No inventory roles mapping rules defined.' | translate\"\n [subtitle]=\"'Click below to add a new mapping.' | translate\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.inventoryMappings.length === 0\"\n [horizontal]=\"true\"\n ></c8y-ui-empty-state>\n <div\n class=\"container-fluid\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.inventoryMappings.length > 0\"\n >\n <c8y-paginated-list-group\n #paginatedInventoryMappings\n [items]=\"templateModel.onNewUser.dynamicMapping.inventoryMappings\"\n >\n <ng-template\n let-inventoryMapping\n let-index=\"index\"\n >\n <c8y-sso-inventory-roles-mapping\n [inventoryRoles]=\"inventoryRoles\"\n [inventoryMapping]=\"inventoryMapping\"\n (onRemoveInventoryMapping)=\"onRemoveInventoryMapping(inventoryMapping)\"\n [inventoryMappingIndex]=\"index\"\n ></c8y-sso-inventory-roles-mapping>\n </ng-template>\n </c8y-paginated-list-group>\n </div>\n <div class=\"p-t-16\">\n <button\n class=\"btn btn-default\"\n title=\"{{ 'Add inventory roles mapping' | translate }}\"\n id=\"add-inventory-mapping-button\"\n type=\"button\"\n (click)=\"addInventoryMapping()\"\n >\n <i\n class=\"m-r-4\"\n c8yIcon=\"plus-circle\"\n ></i>\n {{ 'Add inventory roles mapping' | translate }}\n </button>\n </div>\n </fieldset>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: EmptyStateComponent, selector: "c8y-ui-empty-state", inputs: ["icon", "title", "subtitle", "horizontal"] }, { kind: "component", type: PaginatedListGroupComponent, selector: "c8y-paginated-list-group", inputs: ["items", "itemsPerPage"] }, { kind: "component", type: DynamicAccessMappingComponent, selector: "c8y-sso-dynamic-access-mapping", inputs: ["groups", "apps", "accessMapping", "accessMappingIndex"], outputs: ["onRemoveAccessMapping"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "component", type: InventoryRolesMappingComponent, selector: "c8y-sso-inventory-roles-mapping", inputs: ["inventoryMapping", "inventoryMappingIndex", "inventoryRoles"], outputs: ["onRemoveInventoryMapping"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AccessMappingComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-access-mapping', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
FormGroupComponent,
PopoverDirective,
NgIf,
EmptyStateComponent,
PaginatedListGroupComponent,
DynamicAccessMappingComponent,
IconDirective,
InventoryRolesMappingComponent,
C8yTranslatePipe
], template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n Access mapping\n </div>\n </div>\n\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>{{ 'Source of dynamic access mapping' | translate }}</legend>\n <c8y-form-group>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingSource\"\n type=\"radio\"\n data-cy=\"dynamic-access-mapping-from-access-token\"\n [checked]=\"!mapFromIdToken\"\n (change)=\"setMapFromIdToken(false)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}</span>\n </label>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ RETRIVE_FROM_ID_TOKEN | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingSource\"\n type=\"radio\"\n data-cy=\"dynamic-access-mapping-from-id-token\"\n [checked]=\"mapFromIdToken\"\n (change)=\"setMapFromIdToken(true)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ID_TOKEN | translate }}</span>\n </label>\n </c8y-form-group>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>{{ 'Dynamic access mapping principle' | translate }}</legend>\n <c8y-form-group>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ USE_ACCESS_MAPPING_ON_USER_CREATION_OPTION | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingConfiguration\"\n type=\"radio\"\n data-cy=\"c8y-inventory-roles-mapping--on-user-creation\"\n [checked]=\"mapRolesOnlyForNewUser\"\n (change)=\"setDynamicMappingConfiguration(true)\"\n />\n <span></span>\n <span>{{ USE_ACCESS_MAPPING_ON_USER_CREATION_OPTION | translate }}</span>\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ USE_ACCESS_MAPPING_ON_USER_CREATION_TOOLTIP | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n type=\"button\"\n ></button>\n </label>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_OPTION | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingConfiguration\"\n type=\"radio\"\n data-cy=\"c8y-inventory-roles-mapping--other-ones-will-be-unchanged\"\n [checked]=\"!mapRolesOnlyForNewUser && manageRolesOnlyFromAccessMapping\"\n (change)=\"setDynamicMappingConfiguration(false, true)\"\n />\n <span></span>\n <span>\n {{ UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_OPTION | translate }}\n </span>\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{\n UPDATE_ROLES_LISTED_IN_ACCESS_MAPPING_ON_EACH_LOG_IN_TOOLTIP | translate\n }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n type=\"button\"\n ></button>\n </label>\n <label\n class=\"c8y-radio input-sm\"\n title=\"{{ CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_OPTION | translate }}\"\n >\n <input\n name=\"dynamicAccessMappingConfiguration\"\n type=\"radio\"\n data-cy=\"c8y-inventory-roles-mapping--other-ones-will-be-cleared\"\n [checked]=\"!mapRolesOnlyForNewUser && !manageRolesOnlyFromAccessMapping\"\n (change)=\"setDynamicMappingConfiguration(false, false)\"\n />\n <span></span>\n <span>\n {{ CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_OPTION | translate }}\n </span>\n <button\n class=\"btn-help\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ CLEAR_AND_UPDATED_ROLES_ON_EACH_LOG_IN_TOOLTIP | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n container=\"body\"\n type=\"button\"\n ></button>\n </label>\n </c8y-form-group>\n </fieldset>\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>{{ 'Dynamic access mapping' | translate }}</legend>\n <c8y-ui-empty-state\n [icon]=\"'list'\"\n [title]=\"'No access mapping rules defined.' | translate\"\n [subtitle]=\"'Click below to add a new mapping.' | translate\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.mappings.length === 0\"\n [horizontal]=\"true\"\n ></c8y-ui-empty-state>\n <div\n class=\"container-fluid\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.mappings.length > 0\"\n >\n <c8y-paginated-list-group\n #paginatedAccessMappings\n [items]=\"templateModel.onNewUser.dynamicMapping.mappings\"\n >\n <ng-template\n let-accessMapping\n let-index=\"index\"\n >\n <c8y-sso-dynamic-access-mapping\n [accessMapping]=\"accessMapping\"\n (onRemoveAccessMapping)=\"onRemove(accessMapping)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [accessMappingIndex]=\"index\"\n ></c8y-sso-dynamic-access-mapping>\n </ng-template>\n </c8y-paginated-list-group>\n </div>\n <div class=\"p-t-16\">\n <button\n class=\"btn btn-default\"\n title=\"{{ 'Add access mapping' | translate }}\"\n id=\"add-access-mapping-button\"\n type=\"button\"\n (click)=\"addAccessMapping()\"\n >\n <i\n class=\"m-r-4\"\n c8yIcon=\"plus-circle\"\n ></i>\n {{ 'Add access mapping' | translate }}\n </button>\n </div>\n </fieldset>\n <fieldset class=\"c8y-fieldset p-16\">\n <legend>\n {{ 'Inventory roles mapping' | translate }}\n </legend>\n <c8y-ui-empty-state\n [icon]=\"'list'\"\n [title]=\"'No inventory roles mapping rules defined.' | translate\"\n [subtitle]=\"'Click below to add a new mapping.' | translate\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.inventoryMappings.length === 0\"\n [horizontal]=\"true\"\n ></c8y-ui-empty-state>\n <div\n class=\"container-fluid\"\n *ngIf=\"templateModel.onNewUser.dynamicMapping.inventoryMappings.length > 0\"\n >\n <c8y-paginated-list-group\n #paginatedInventoryMappings\n [items]=\"templateModel.onNewUser.dynamicMapping.inventoryMappings\"\n >\n <ng-template\n let-inventoryMapping\n let-index=\"index\"\n >\n <c8y-sso-inventory-roles-mapping\n [inventoryRoles]=\"inventoryRoles\"\n [inventoryMapping]=\"inventoryMapping\"\n (onRemoveInventoryMapping)=\"onRemoveInventoryMapping(inventoryMapping)\"\n [inventoryMappingIndex]=\"index\"\n ></c8y-sso-inventory-roles-mapping>\n </ng-template>\n </c8y-paginated-list-group>\n </div>\n <div class=\"p-t-16\">\n <button\n class=\"btn btn-default\"\n title=\"{{ 'Add inventory roles mapping' | translate }}\"\n id=\"add-inventory-mapping-button\"\n type=\"button\"\n (click)=\"addInventoryMapping()\"\n >\n <i\n class=\"m-r-4\"\n c8yIcon=\"plus-circle\"\n ></i>\n {{ 'Add inventory roles mapping' | translate }}\n </button>\n </div>\n </fieldset>\n </div>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }, { type: i0.ChangeDetectorRef }], propDecorators: { apps: [{
type: Input
}], groups: [{
type: Input
}], inventoryRoles: [{
type: Input
}], templateModel: [{
type: Input
}], paginatedAccessMappings: [{
type: ViewChild,
args: ['paginatedAccessMappings']
}], paginatedInventoryMappings: [{
type: ViewChild,
args: ['paginatedInventoryMappings']
}] } });
class UserDataMappingComponent {
constructor(controlContainer) {
this.controlContainer = controlContainer;
this.CLAIM_NAMES = gettext('Token claims can be checked in Audit Logs under Single sign-on type.');
this.RETRIVE_FROM_ACCESS_TOKEN = gettext('Retrieve from Access token');
this.RETRIVE_FROM_ID_TOKEN = gettext('Retrieve from ID token');
}
ngAfterContentInit() {
if (!this.templateModel.accessTokenToUserDataMappings) {
this.templateModel.accessTokenToUserDataMappings = {};
}
}
get useIdToken() {
return this.templateModel.useIdToken || false;
}
setUseIdToken(useIdToken) {
this.templateModel.useIdToken = useIdToken;
this.controlContainer.control.markAsDirty();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: UserDataMappingComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: UserDataMappingComponent, isStandalone: true, selector: "c8y-sso-user-data-mapping", inputs: { templateModel: "templateModel" }, ngImport: i0, template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n User data mappings\n </div>\n </div>\n\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>{{ 'Source of user data mapping' | translate }}</legend>\n <c8y-form-group>\n <label\n title=\"{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}\"\n class=\"c8y-radio input-sm\"\n >\n <input\n type=\"radio\"\n name=\"userAccessMappingSource\"\n data-cy=\"user-access-mapping-from-access-token\"\n [checked]=\"!useIdToken\"\n (change)=\"setUseIdToken(false)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}</span>\n </label>\n <label\n title=\"{{ RETRIVE_FROM_ID_TOKEN | translate }}\"\n class=\"c8y-radio input-sm\"\n >\n <input\n type=\"radio\"\n name=\"userAccessMappingSource\"\n data-cy=\"user-access-mapping-from-id-token\"\n [checked]=\"useIdToken\"\n (change)=\"setUseIdToken(true)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ID_TOKEN | translate }}</span>\n </label>\n </c8y-form-group>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>\n {{ 'Claim names' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ CLAIM_NAMES | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n ></button>\n </legend>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"firstName\"\n class=\"control-label\"\n translate\n >\n First name\n </label>\n <input\n class=\"form-control\"\n name=\"firstName\"\n id=\"firstName\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.firstNameClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'given_name' }\"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"lastName\"\n class=\"control-label\"\n translate\n >\n Last name\n </label>\n <input\n class=\"form-control\"\n name=\"lastName\"\n id=\"lastName\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.lastNameClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'family_name' }\"\n />\n </c8y-form-group>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"email\"\n class=\"control-label\"\n translate\n >\n Email\n </label>\n <input\n class=\"form-control\"\n name=\"email\"\n id=\"email\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.emailClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'email' }\"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"phoneNumber\"\n class=\"control-label\"\n translate\n >\n Phone number\n </label>\n <input\n class=\"form-control\"\n name=\"phoneNumber\"\n id=\"phoneNumber\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.phoneNumberClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'phone_number' }\"\n />\n </c8y-form-group>\n </div>\n </div>\n </fieldset>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: UserDataMappingComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-user-data-mapping', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
FormGroupComponent,
PopoverDirective,
FormsModule,
C8yTranslatePipe
], template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n User data mappings\n </div>\n </div>\n\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>{{ 'Source of user data mapping' | translate }}</legend>\n <c8y-form-group>\n <label\n title=\"{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}\"\n class=\"c8y-radio input-sm\"\n >\n <input\n type=\"radio\"\n name=\"userAccessMappingSource\"\n data-cy=\"user-access-mapping-from-access-token\"\n [checked]=\"!useIdToken\"\n (change)=\"setUseIdToken(false)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ACCESS_TOKEN | translate }}</span>\n </label>\n <label\n title=\"{{ RETRIVE_FROM_ID_TOKEN | translate }}\"\n class=\"c8y-radio input-sm\"\n >\n <input\n type=\"radio\"\n name=\"userAccessMappingSource\"\n data-cy=\"user-access-mapping-from-id-token\"\n [checked]=\"useIdToken\"\n (change)=\"setUseIdToken(true)\"\n />\n <span></span>\n <span>{{ RETRIVE_FROM_ID_TOKEN | translate }}</span>\n </label>\n </c8y-form-group>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>\n {{ 'Claim names' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ CLAIM_NAMES | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n ></button>\n </legend>\n\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"firstName\"\n class=\"control-label\"\n translate\n >\n First name\n </label>\n <input\n class=\"form-control\"\n name=\"firstName\"\n id=\"firstName\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.firstNameClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'given_name' }\"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"lastName\"\n class=\"control-label\"\n translate\n >\n Last name\n </label>\n <input\n class=\"form-control\"\n name=\"lastName\"\n id=\"lastName\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.lastNameClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'family_name' }\"\n />\n </c8y-form-group>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"email\"\n class=\"control-label\"\n translate\n >\n Email\n </label>\n <input\n class=\"form-control\"\n name=\"email\"\n id=\"email\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.emailClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'email' }\"\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"phoneNumber\"\n class=\"control-label\"\n translate\n >\n Phone number\n </label>\n <input\n class=\"form-control\"\n name=\"phoneNumber\"\n id=\"phoneNumber\"\n [(ngModel)]=\"templateModel.accessTokenToUserDataMappings.phoneNumberClaimName\"\n [placeholder]=\"'e.g. {{ example }}' | translate: { example: 'phone_number' }\"\n />\n </c8y-form-group>\n </div>\n </div>\n </fieldset>\n </div>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }], propDecorators: { templateModel: [{
type: Input
}] } });
class SignatureConfigurationComponent {
constructor(controlContainer, dateFormatService) {
this.controlContainer = controlContainer;
this.dateFormatService = dateFormatService;
this.certificateType = CertificateType;
this.certificateTypes = certificateTypeConfig;
this.algorithmTypes = algorithmTypeConfig;
this.CERTIFICATE_ID_FIELD_POPOVER = gettext('This is the name of the field in the token whose value will be used to select one of the certificates below which has matching "Certificate ID value".');
}
ngOnInit() {
this.dateInputFormat = this.dateFormatService.getDateFormat();
}
shouldShow(field) {
return field in this.templateModel;
}
removeCustomCertificate(customCertificate) {
this.templateModel.signatureVerificationConfig.manual.removeCustomCertificate(customCertificate);
this.controlContainer.control.markAsDirty();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SignatureConfigurationComponent, deps: [{ token: i1.ControlContainer }, { token: i2.DateFormatService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: SignatureConfigurationComponent, isStandalone: true, selector: "c8y-sso-signature-configuration", inputs: { templateModel: "templateModel" }, ngImport: i0, template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n Signature verification\n </div>\n </div>\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <div\n *ngIf=\"shouldShow('certificateType')\"\n class=\"form-group p-relative\"\n >\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <label\n for=\"certificateType\"\n class=\"control-label\"\n translate\n >\n Verifier\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n id=\"certificateType\"\n name=\"certificateType\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.certificateTypeChosen\"\n >\n <option\n *ngFor=\"let certificateType of certificateTypes | keyvalue\"\n [ngValue]=\"certificateType.key\"\n >\n {{ certificateType.value.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </div>\n </div>\n </div>\n <div\n id=\"adfs\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.ADFS\n \"\n class=\"row\"\n >\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"adfsManifestUrl\"\n class=\"control-label\"\n translate\n >\n ADFS manifest URL\n </label>\n <input\n type=\"url\"\n class=\"form-control\"\n required\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate\n : {\n example: 'https://adfs.tenant.com/federationmetadata/federationmetadata.xml'\n }\n \"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.adfsManifest.manifestUrl\"\n name=\"adfsManifestUrl\"\n id=\"adfsManifestUrl\"\n />\n </c8y-form-group>\n </div>\n </div>\n\n <div\n id=\"add\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.AZURE\n \"\n >\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"publicKeyDiscoveryUrl\"\n class=\"control-label\"\n translate\n >\n Public key discovery URL\n </label>\n <input\n type=\"url\"\n id=\"publicKeyDiscoveryUrl\"\n class=\"form-control\"\n required\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate\n : { example: 'https://login.microsoftonline.de/tenant/discovery/keys' }\n \"\n name=\"publicKeyDiscoveryUrl\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.aad.publicKeyDiscoveryUrl\"\n />\n </c8y-form-group>\n </div>\n </div>\n </div>\n\n <div\n id=\"jwks\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.JWKS\n \"\n >\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"jwksPublicKeyDiscoveryUrl\"\n class=\"control-label\"\n translate\n >\n JWKS URL\n </label>\n <input\n type=\"url\"\n class=\"form-control\"\n id=\"jwksPublicKeyDiscoveryUrl\"\n required\n [placeholder]=\"\n 'e.g. {{ example }}' | translate: { example: 'http://www.example.com/' }\n \"\n name=\"jwksUri\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.jwks.jwksUri\"\n />\n </c8y-form-group>\n </div>\n </div>\n </div>\n\n <div\n id=\"manual\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.CUSTOM\n \"\n >\n <fieldset\n class=\"c8y-fieldset p-24\"\n *ngIf=\"templateModel.signatureVerificationConfig.manual.customCertificates.length > 1\"\n >\n <legend>\n {{ 'Manual' | translate }}\n </legend>\n <div class=\"row\">\n <div class=\"col-md-6\">\n <label\n for=\"certIdField\"\n class=\"control-label\"\n >\n {{ 'Certificate ID field' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ CERTIFICATE_ID_FIELD_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n ></button>\n </label>\n <input\n type=\"text\"\n class=\"form-control\"\n name=\"certIdField\"\n id=\"certIdField\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.manual.certIdField\"\n required\n />\n </div>\n </div>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>\n {{ 'Certificates' | translate }}\n </legend>\n <fieldset\n class=\"c8y-fieldset p-16\"\n *ngFor=\"\n let customCertificate of templateModel.signatureVerificationConfig.manual\n .customCertificates;\n index as crtIndex\n \"\n >\n <div class=\"row\">\n <div\n class=\"col-sm-6\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.manual.customCertificates.length > 1\n \"\n >\n <c8y-form-group>\n <label\n [for]=\"'customCertificateValue' + crtIndex\"\n class=\"control-label\"\n translate\n >\n Certificate ID value\n </label>\n <input\n [name]=\"'customCertificateValue' + crtIndex\"\n [id]=\"'customCertificateValue' + crtIndex\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"customCertificate.key\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"control-label\">\n {{ 'Type' | translate }}\n </label>\n <label\n title=\"{{ algorithmType.value.label | translate }}\"\n class=\"c8y-radio input-sm\"\n *ngFor=\"let algorithmType of algorithmTypes | keyvalue; index as algIndex\"\n >\n <input\n type=\"radio\"\n [name]=\"'alg' + crtIndex + algIndex\"\n [value]=\"algorithmType.key\"\n [(ngModel)]=\"customCertificate.alg\"\n />\n <span></span>\n <span>{{ algorithmType.value.label | translate }}</span>\n </label>\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\">\n <div class=\"col-md-5\">\n <c8y-form-group>\n <label\n class=\"control-label\"\n [for]=\"'publicKey' + crtIndex\"\n *ngIf=\"customCertificate.alg === algorithmTypes.PCKS.value\"\n translate\n >\n Certificate in PEM format\n </label>\n <label\n class=\"control-label\"\n [for]=\"'publicKey' + crtIndex\"\n *ngIf=\"customCertificate.alg === algorithmTypes.RSA.value\"\n translate\n >\n Public key in PEM format\n </label>\n <input\n [name]=\"'publicKey' + crtIndex\"\n [id]=\"'publicKey' + crtIndex\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"customCertificate.publicKey\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-3\">\n <div class=\"form-group datepicker\">\n <c8y-form-group>\n <label\n [for]=\"'validFromPicker' + crtIndex\"\n class=\"control-label\"\n >\n {{ 'Valid from' | translate }}\n </label>\n <input\n [name]=\"'validFromPicker' + crtIndex\"\n [id]=\"'validFromPicker' + crtIndex\"\n [(ngModel)]=\"customCertificate.validFrom\"\n class=\"form-control\"\n [attr.aria-label]=\"'Date from' | translate\"\n placeholder=\"{{ 'Date from' | translate }}\"\n [bsConfig]=\"{ customTodayClass: 'today', adaptivePosition: true, dateInputFormat: dateInputFormat }\"\n [maxDate]=\"customCertificate.validTill\"\n bsDatepicker\n required\n />\n </c8y-form-group>\n </div>\n </div>\n <div class=\"col-md-3\">\n <div class=\"form-group datepicker\">\n <c8y-form-group>\n <label\n [for]=\"'validTillPicker' + crtIndex\"\n class=\"control-label\"\n >\n {{ 'Valid till' | translate }}\n </label>\n <input\n [name]=\"'validTillPicker' + crtIndex\"\n [id]=\"'validTillPicker' + crtIndex\"\n [(ngModel)]=\"customCertificate.validTill\"\n class=\"form-control\"\n placeholder=\"{{ 'Date to' | translate }}\"\n [attr.aria-label]=\"'Date to' | translate\"\n [bsConfig]=\"{ customTodayClass: 'today', adaptivePosition: true, dateInputFormat: dateInputFormat }\"\n bsDatepicker\n [minDate]=\"customCertificate.validFrom\"\n required\n />\n </c8y-form-group>\n </div>\n </div>\n <div\n class=\"col-md-1\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.manual.customCertificates.length > 1\n \"\n >\n <label> </label>\n <button\n class=\"btn btn-danger btn-sm visible-xs visible-sm\"\n type=\"button\"\n title=\"{{ 'Delete certificate' | translate }}\"\n (click)=\"removeCustomCertificate(customCertificate)\"\n >\n <i\n c8yIcon=\"minus-circle\"\n class=\"m-r-4\"\n ></i>\n <span>{{ 'Delete certificate' | translate }}</span>\n </button>\n\n <button\n class=\"btn btn-dot btn-dot--danger visible-md visible-lg\"\n type=\"button\"\n tooltip=\"{{ 'Delete certificate' | translate }}\"\n placement=\"top\"\n [adaptivePosition]=\"false\"\n [attr.aria-label]=\"'Delete certificate' | translate\"\n [delay]=\"300\"\n (click)=\"removeCustomCertificate(customCertificate)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n </button>\n </div>\n </div>\n </fieldset>\n <button\n class=\"btn btn-default m-t-8\"\n type=\"button\"\n title=\"{{ 'Add certificate' | translate }}\"\n (click)=\"templateModel.signatureVerificationConfig.manual.addCustomCertificate()\"\n name=\"addCertificate\"\n >\n <i\n c8yIcon=\"plus-circle\"\n class=\"m-r-4\"\n ></i>\n <span>{{ 'Add certificate' | translate }}</span>\n </button>\n </fieldset>\n </div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "directive", type: BsDatepickerInputDirective, selector: "input[bsDatepicker]" }, { kind: "directive", type: BsDatepickerDirective, selector: "[bsDatepicker]", inputs: ["placement", "triggers", "outsideClick", "container", "outsideEsc", "isDisabled", "minDate", "maxDate", "ignoreMinMaxErrors", "minMode", "daysDisabled", "datesDisabled", "datesEnabled", "dateCustomClasses", "dateTooltipTexts", "isOpen", "bsValue", "bsConfig"], outputs: ["onShown", "onHidden", "bsValueChange"], exportAs: ["bsDatepicker"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: TooltipDirective, selector: "[tooltip], [tooltipHtml]", inputs: ["adaptivePosition", "tooltip", "placement", "triggers", "container", "containerClass", "boundariesElement", "isOpen", "isDisabled", "delay", "tooltipHtml", "tooltipPlacement", "tooltipIsOpen", "tooltipEnable", "tooltipAppendToBody", "tooltipAnimation", "tooltipClass", "tooltipContext", "tooltipPopupDelay", "tooltipFadeDuration", "tooltipTrigger"], outputs: ["tooltipChange", "onShown", "onHidden", "tooltipStateChanged"], exportAs: ["bs-tooltip"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
__decorate([
memoize(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], SignatureConfigurationComponent.prototype, "shouldShow", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SignatureConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-signature-configuration', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
NgIf,
FormsModule,
NgFor,
FormGroupComponent,
RequiredInputPlaceholderDirective,
PopoverDirective,
BsDatepickerInputDirective,
BsDatepickerDirective,
IconDirective,
TooltipDirective,
C8yTranslatePipe,
KeyValuePipe
], template: "<div class=\"p-24\">\n <div class=\"row\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div\n class=\"h4 text-normal text-right text-left-xs\"\n translate\n >\n Signature verification\n </div>\n </div>\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <div\n *ngIf=\"shouldShow('certificateType')\"\n class=\"form-group p-relative\"\n >\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <label\n for=\"certificateType\"\n class=\"control-label\"\n translate\n >\n Verifier\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n id=\"certificateType\"\n name=\"certificateType\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.certificateTypeChosen\"\n >\n <option\n *ngFor=\"let certificateType of certificateTypes | keyvalue\"\n [ngValue]=\"certificateType.key\"\n >\n {{ certificateType.value.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </div>\n </div>\n </div>\n <div\n id=\"adfs\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.ADFS\n \"\n class=\"row\"\n >\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"adfsManifestUrl\"\n class=\"control-label\"\n translate\n >\n ADFS manifest URL\n </label>\n <input\n type=\"url\"\n class=\"form-control\"\n required\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate\n : {\n example: 'https://adfs.tenant.com/federationmetadata/federationmetadata.xml'\n }\n \"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.adfsManifest.manifestUrl\"\n name=\"adfsManifestUrl\"\n id=\"adfsManifestUrl\"\n />\n </c8y-form-group>\n </div>\n </div>\n\n <div\n id=\"add\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.AZURE\n \"\n >\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"publicKeyDiscoveryUrl\"\n class=\"control-label\"\n translate\n >\n Public key discovery URL\n </label>\n <input\n type=\"url\"\n id=\"publicKeyDiscoveryUrl\"\n class=\"form-control\"\n required\n [placeholder]=\"\n 'e.g. {{ example }}'\n | translate\n : { example: 'https://login.microsoftonline.de/tenant/discovery/keys' }\n \"\n name=\"publicKeyDiscoveryUrl\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.aad.publicKeyDiscoveryUrl\"\n />\n </c8y-form-group>\n </div>\n </div>\n </div>\n\n <div\n id=\"jwks\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.JWKS\n \"\n >\n <div class=\"row\">\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label\n for=\"jwksPublicKeyDiscoveryUrl\"\n class=\"control-label\"\n translate\n >\n JWKS URL\n </label>\n <input\n type=\"url\"\n class=\"form-control\"\n id=\"jwksPublicKeyDiscoveryUrl\"\n required\n [placeholder]=\"\n 'e.g. {{ example }}' | translate: { example: 'http://www.example.com/' }\n \"\n name=\"jwksUri\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.jwks.jwksUri\"\n />\n </c8y-form-group>\n </div>\n </div>\n </div>\n\n <div\n id=\"manual\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.certificateTypeChosen === certificateType.CUSTOM\n \"\n >\n <fieldset\n class=\"c8y-fieldset p-24\"\n *ngIf=\"templateModel.signatureVerificationConfig.manual.customCertificates.length > 1\"\n >\n <legend>\n {{ 'Manual' | translate }}\n </legend>\n <div class=\"row\">\n <div class=\"col-md-6\">\n <label\n for=\"certIdField\"\n class=\"control-label\"\n >\n {{ 'Certificate ID field' | translate }}\n <button\n class=\"btn-help btn-help--sm\"\n type=\"button\"\n [attr.aria-label]=\"'Help' | translate\"\n popover=\"{{ CERTIFICATE_ID_FIELD_POPOVER | translate }}\"\n placement=\"right\"\n triggers=\"focus\"\n ></button>\n </label>\n <input\n type=\"text\"\n class=\"form-control\"\n name=\"certIdField\"\n id=\"certIdField\"\n [(ngModel)]=\"templateModel.signatureVerificationConfig.manual.certIdField\"\n required\n />\n </div>\n </div>\n </fieldset>\n\n <fieldset class=\"c8y-fieldset p-24\">\n <legend>\n {{ 'Certificates' | translate }}\n </legend>\n <fieldset\n class=\"c8y-fieldset p-16\"\n *ngFor=\"\n let customCertificate of templateModel.signatureVerificationConfig.manual\n .customCertificates;\n index as crtIndex\n \"\n >\n <div class=\"row\">\n <div\n class=\"col-sm-6\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.manual.customCertificates.length > 1\n \"\n >\n <c8y-form-group>\n <label\n [for]=\"'customCertificateValue' + crtIndex\"\n class=\"control-label\"\n translate\n >\n Certificate ID value\n </label>\n <input\n [name]=\"'customCertificateValue' + crtIndex\"\n [id]=\"'customCertificateValue' + crtIndex\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"customCertificate.key\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-sm-6\">\n <c8y-form-group>\n <label class=\"control-label\">\n {{ 'Type' | translate }}\n </label>\n <label\n title=\"{{ algorithmType.value.label | translate }}\"\n class=\"c8y-radio input-sm\"\n *ngFor=\"let algorithmType of algorithmTypes | keyvalue; index as algIndex\"\n >\n <input\n type=\"radio\"\n [name]=\"'alg' + crtIndex + algIndex\"\n [value]=\"algorithmType.key\"\n [(ngModel)]=\"customCertificate.alg\"\n />\n <span></span>\n <span>{{ algorithmType.value.label | translate }}</span>\n </label>\n </c8y-form-group>\n </div>\n </div>\n\n <div class=\"row\">\n <div class=\"col-md-5\">\n <c8y-form-group>\n <label\n class=\"control-label\"\n [for]=\"'publicKey' + crtIndex\"\n *ngIf=\"customCertificate.alg === algorithmTypes.PCKS.value\"\n translate\n >\n Certificate in PEM format\n </label>\n <label\n class=\"control-label\"\n [for]=\"'publicKey' + crtIndex\"\n *ngIf=\"customCertificate.alg === algorithmTypes.RSA.value\"\n translate\n >\n Public key in PEM format\n </label>\n <input\n [name]=\"'publicKey' + crtIndex\"\n [id]=\"'publicKey' + crtIndex\"\n type=\"text\"\n class=\"form-control\"\n [(ngModel)]=\"customCertificate.publicKey\"\n required\n />\n </c8y-form-group>\n </div>\n <div class=\"col-md-3\">\n <div class=\"form-group datepicker\">\n <c8y-form-group>\n <label\n [for]=\"'validFromPicker' + crtIndex\"\n class=\"control-label\"\n >\n {{ 'Valid from' | translate }}\n </label>\n <input\n [name]=\"'validFromPicker' + crtIndex\"\n [id]=\"'validFromPicker' + crtIndex\"\n [(ngModel)]=\"customCertificate.validFrom\"\n class=\"form-control\"\n [attr.aria-label]=\"'Date from' | translate\"\n placeholder=\"{{ 'Date from' | translate }}\"\n [bsConfig]=\"{ customTodayClass: 'today', adaptivePosition: true, dateInputFormat: dateInputFormat }\"\n [maxDate]=\"customCertificate.validTill\"\n bsDatepicker\n required\n />\n </c8y-form-group>\n </div>\n </div>\n <div class=\"col-md-3\">\n <div class=\"form-group datepicker\">\n <c8y-form-group>\n <label\n [for]=\"'validTillPicker' + crtIndex\"\n class=\"control-label\"\n >\n {{ 'Valid till' | translate }}\n </label>\n <input\n [name]=\"'validTillPicker' + crtIndex\"\n [id]=\"'validTillPicker' + crtIndex\"\n [(ngModel)]=\"customCertificate.validTill\"\n class=\"form-control\"\n placeholder=\"{{ 'Date to' | translate }}\"\n [attr.aria-label]=\"'Date to' | translate\"\n [bsConfig]=\"{ customTodayClass: 'today', adaptivePosition: true, dateInputFormat: dateInputFormat }\"\n bsDatepicker\n [minDate]=\"customCertificate.validFrom\"\n required\n />\n </c8y-form-group>\n </div>\n </div>\n <div\n class=\"col-md-1\"\n *ngIf=\"\n templateModel.signatureVerificationConfig.manual.customCertificates.length > 1\n \"\n >\n <label> </label>\n <button\n class=\"btn btn-danger btn-sm visible-xs visible-sm\"\n type=\"button\"\n title=\"{{ 'Delete certificate' | translate }}\"\n (click)=\"removeCustomCertificate(customCertificate)\"\n >\n <i\n c8yIcon=\"minus-circle\"\n class=\"m-r-4\"\n ></i>\n <span>{{ 'Delete certificate' | translate }}</span>\n </button>\n\n <button\n class=\"btn btn-dot btn-dot--danger visible-md visible-lg\"\n type=\"button\"\n tooltip=\"{{ 'Delete certificate' | translate }}\"\n placement=\"top\"\n [adaptivePosition]=\"false\"\n [attr.aria-label]=\"'Delete certificate' | translate\"\n [delay]=\"300\"\n (click)=\"removeCustomCertificate(customCertificate)\"\n >\n <i c8yIcon=\"minus-circle\"></i>\n </button>\n </div>\n </div>\n </fieldset>\n <button\n class=\"btn btn-default m-t-8\"\n type=\"button\"\n title=\"{{ 'Add certificate' | translate }}\"\n (click)=\"templateModel.signatureVerificationConfig.manual.addCustomCertificate()\"\n name=\"addCertificate\"\n >\n <i\n c8yIcon=\"plus-circle\"\n class=\"m-r-4\"\n ></i>\n <span>{{ 'Add certificate' | translate }}</span>\n </button>\n </fieldset>\n </div>\n </div>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: i1.ControlContainer }, { type: i2.DateFormatService }], propDecorators: { templateModel: [{
type: Input
}], shouldShow: [] } });
class CustomTemplateComponent extends TemplateComponent {
constructor(customConfigurationMapper) {
super(customConfigurationMapper);
this.customConfigurationMapper = customConfigurationMapper;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CustomTemplateComponent, deps: [{ token: CustomConfigurationMapper }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: CustomTemplateComponent, isStandalone: true, selector: "c8y-custom-template", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"templateModel\">\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Authorization request' | translate\"\n [requestType]=\"'authorizationRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Token request' | translate\"\n [requestType]=\"'tokenRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Refresh request' | translate\"\n [requestType]=\"'refreshRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Logout request' | translate\"\n [requestType]=\"'logoutRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-external-token-config [templateModel]=\"templateModel\"></c8y-external-token-config>\n <hr />\n <c8y-basic-configuration [templateModel]=\"templateModel\"></c8y-basic-configuration>\n <hr />\n <c8y-sso-access-mapping\n [templateModel]=\"templateModel\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-sso-access-mapping>\n <hr />\n <c8y-sso-user-data-mapping [templateModel]=\"templateModel\"></c8y-sso-user-data-mapping>\n <c8y-user-id-configuration\n [userIdConfig]=\"templateModel.userIdConfig\"\n ></c8y-user-id-configuration>\n <hr />\n <c8y-sso-signature-configuration\n [templateModel]=\"templateModel\"\n ></c8y-sso-signature-configuration>\n</ng-container>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: RequestConfigurationComponent, selector: "c8y-request-configuration", inputs: ["templateModel", "requestName", "requestType"] }, { kind: "component", type: ExternalTokenConfigComponent, selector: "c8y-external-token-config", inputs: ["templateModel"] }, { kind: "component", type: BasicConfigurationComponent, selector: "c8y-basic-configuration", inputs: ["templateModel"] }, { kind: "component", type: AccessMappingComponent, selector: "c8y-sso-access-mapping", inputs: ["apps", "groups", "inventoryRoles", "templateModel"] }, { kind: "component", type: UserDataMappingComponent, selector: "c8y-sso-user-data-mapping", inputs: ["templateModel"] }, { kind: "component", type: UserIdConfigurationComponent, selector: "c8y-user-id-configuration", inputs: ["userIdConfig", "withHeader"] }, { kind: "component", type: SignatureConfigurationComponent, selector: "c8y-sso-signature-configuration", inputs: ["templateModel"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CustomTemplateComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-custom-template', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
RequestConfigurationComponent,
ExternalTokenConfigComponent,
BasicConfigurationComponent,
AccessMappingComponent,
UserDataMappingComponent,
UserIdConfigurationComponent,
SignatureConfigurationComponent,
C8yTranslatePipe
], template: "<ng-container *ngIf=\"templateModel\">\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Authorization request' | translate\"\n [requestType]=\"'authorizationRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Token request' | translate\"\n [requestType]=\"'tokenRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Refresh request' | translate\"\n [requestType]=\"'refreshRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Logout request' | translate\"\n [requestType]=\"'logoutRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-external-token-config [templateModel]=\"templateModel\"></c8y-external-token-config>\n <hr />\n <c8y-basic-configuration [templateModel]=\"templateModel\"></c8y-basic-configuration>\n <hr />\n <c8y-sso-access-mapping\n [templateModel]=\"templateModel\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-sso-access-mapping>\n <hr />\n <c8y-sso-user-data-mapping [templateModel]=\"templateModel\"></c8y-sso-user-data-mapping>\n <c8y-user-id-configuration\n [userIdConfig]=\"templateModel.userIdConfig\"\n ></c8y-user-id-configuration>\n <hr />\n <c8y-sso-signature-configuration\n [templateModel]=\"templateModel\"\n ></c8y-sso-signature-configuration>\n</ng-container>\n" }]
}], ctorParameters: () => [{ type: CustomConfigurationMapper }] });
class AadConfigurationMapper {
constructor() {
this.defaults = {
visibleOnLoginPage: true
};
this.urlPattern = /^(.+)\/((.+?)\/oauth2\/(authorize|token))$/;
}
mapFrom(templateModel) {
const baseUrl = `${templateModel.aadAddress}/${templateModel.tenant}/oauth2`;
const ssoConfiguration = {
audience: templateModel.applicationId,
clientId: templateModel.applicationId,
logoutRequest: templateModel.redirectAfterLogout
? {
method: 'POST',
url: `${baseUrl}/logout`,
requestParams: {
post_logout_redirect_uri: templateModel.redirectAfterLogoutUrl
},
headers: {},
body: '',
operation: 'REDIRECT'
}
: {
method: 'POST',
headers: {},
operation: 'REDIRECT',
requestParams: {}
},
authorizationRequest: {
method: 'GET',
url: `${baseUrl}/authorize`,
requestParams: {
redirect_uri: '${redirectUri}',
client_id: '${clientId}',
response_type: 'code'
},
headers: {},
body: '',
operation: 'REDIRECT'
},
tokenRequest: {
method: 'POST',
url: `${baseUrl}/token`,
requestParams: {},
headers: {},
body: this.getQueryString({
grant_type: 'authorization_code',
code: '${code}',
redirect_uri: '${redirectUri}',
resource: '${clientId}',
client_id: '${clientId}',
client_secret: encodeURIComponent(templateModel.clientSecret)
}),
operation: 'EXECUTE'
},
refreshRequest: {
method: 'POST',
url: `${baseUrl}/token`,
requestParams: {},
headers: {},
body: this.getQueryString({
grant_type: 'refresh_token',
refresh_token: '${refreshToken}',
resource: '${clientId}',
client_id: '${clientId}',
client_secret: encodeURIComponent(templateModel.clientSecret)
}),
operation: 'EXECUTE'
},
buttonName: templateModel.buttonName,
providerName: 'Azure AD',
issuer: templateModel.issuer,
onNewUser: templateModel.onNewUser,
accessTokenToUserDataMappings: templateModel.accessTokenToUserDataMappings,
redirectToPlatform: templateModel.redirectToPlatform || null,
template: TemplateType.AZURE,
userIdConfig: {
useConstantValue: false,
jwtField: templateModel.userIdConfig.jwtField
},
visibleOnLoginPage: templateModel.visibleOnLoginPage,
signatureVerificationConfig: templateModel.signatureVerificationConfig.toSignatureVerificationConfig(),
userManagementSource: UserManagementSource.REMOTE,
type: TenantLoginOptionType.OAUTH2,
grantType: GrantType.AUTHORIZATION_CODE,
externalTokenConfig: templateModel.externalTokenConfig.toExternalTokenConfig(),
useIdToken: templateModel.useIdToken
};
return ssoConfiguration;
}
mapTo(ssoConfiguration) {
const ssoConfigurationForAad = cloneDeep(ssoConfiguration);
const applicationsId = at(ssoConfigurationForAad, ['audience', 'clientId']);
this.setupDefaults(ssoConfigurationForAad);
this.setupUserIdConfig(ssoConfigurationForAad);
this.setupSignatureVerificationConfig(ssoConfigurationForAad);
const aadConfiguration = {
aadAddress: this.getAadAddress(ssoConfigurationForAad),
tenant: this.getTenant(ssoConfigurationForAad),
applicationId: this.getFirstDefined(applicationsId),
redirectToPlatform: ssoConfigurationForAad.redirectToPlatform,
clientSecret: this.getClientSecret(ssoConfigurationForAad),
issuer: ssoConfigurationForAad.issuer,
buttonName: ssoConfigurationForAad.buttonName,
visibleOnLoginPage: ssoConfigurationForAad.visibleOnLoginPage,
redirectAfterLogout: this.getRedirectAfterLogout(ssoConfigurationForAad),
redirectAfterLogoutUrl: this.getRedirectAfterLogoutUrl(ssoConfigurationForAad),
accessTokenToUserDataMappings: ssoConfigurationForAad.accessTokenToUserDataMappings,
userIdConfig: {
jwtField: ssoConfigurationForAad.userIdConfig.jwtField
},
publicKeyDiscoveryUrl: ssoConfigurationForAad.signatureVerificationConfig.aad.publicKeyDiscoveryUrl,
signatureVerificationConfig: new SignatureConfiguration(ssoConfigurationForAad.signatureVerificationConfig),
onNewUser: ssoConfigurationForAad.onNewUser,
externalTokenConfig: new ExternalToken(ssoConfigurationForAad.externalTokenConfig),
useIdToken: ssoConfiguration.useIdToken
};
return aadConfiguration;
}
setupDefaults(ssoConfiguration) {
defaults(ssoConfiguration, this.defaults);
}
getAadAddress(ssoConfiguration) {
const urls = this.getUrlsFromRequests(ssoConfiguration);
const aadAddresses = map$1(urls, url => this.getAadAddressFromUrl(url));
return this.getFirstDefined(aadAddresses);
}
getTenant(ssoConfiguration) {
const urls = this.getUrlsFromRequests(ssoConfiguration);
const tenants = map$1(urls, url => this.getTenantFromUrl(url));
return this.getFirstDefined(tenants);
}
getUrlsFromRequests(ssoConfiguration) {
return at(ssoConfiguration, [
'authorizationRequest.url',
'tokenRequest.url',
'refreshRequest.url'
]);
}
getAadAddressFromUrl(url) {
const [, aadAddress] = (url || '').match(this.urlPattern) || [];
return aadAddress;
}
getTenantFromUrl(url) {
const [, , , tenant] = (url || '').match(this.urlPattern) || [];
return tenant;
}
getClientSecret(ssoConfiguration) {
const bodies = at(ssoConfiguration, ['tokenRequest.body', 'refreshRequest.body']);
const clientSecrets = map$1(bodies, body => this.getClientSecretFromBody(body));
return this.getFirstDefined(clientSecrets);
}
getClientSecretFromBody(body) {
const [, clientSecret] = (body || '').match(/client_secret=([^&]+)/) || [];
return clientSecret ? decodeURIComponent(clientSecret) : undefined;
}
setupUserIdConfig(ssoConfiguration) {
defaultsDeep(ssoConfiguration, { userIdConfig: { jwtField: 'upn' } });
}
setupSignatureVerificationConfig(ssoConfiguration) {
defaultsDeep(ssoConfiguration, {
signatureVerificationConfig: { aad: { publicKeyDiscoveryUrl: '' } }
});
ssoConfiguration.signatureVerificationConfig = pick(ssoConfiguration.signatureVerificationConfig, 'aad');
}
getRedirectAfterLogout(ssoConfiguration) {
return has(ssoConfiguration, 'logoutRequest.requestParams.post_logout_redirect_uri')
? true
: false;
}
getRedirectAfterLogoutUrl(ssoConfiguration) {
return ssoConfiguration.logoutRequest.requestParams.post_logout_redirect_uri
? ssoConfiguration.logoutRequest.requestParams.post_logout_redirect_uri
: null;
}
getFirstDefined(values) {
return head(reject(values, isUndefined));
}
getQueryString(params) {
return map$1(params, (value, key) => `${key}=${value}`).join('&');
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AadConfigurationMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AadConfigurationMapper, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AadConfigurationMapper, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
class LogoutConfigurationComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: LogoutConfigurationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: LogoutConfigurationComponent, isStandalone: true, selector: "c8y-sso-logout-configuration", inputs: { templateModel: "templateModel" }, ngImport: i0, template: "<div class=\"col-md-12 p-t-16\">\n <div class=\"row m-l-8 m-r-8\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div class=\"h4 text-normal text-right text-left-xs\" translate>Logout configuration</div>\n </div>\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <c8y-form-group>\n <label\n for=\"redirectAfterLogout\"\n title=\"{{ 'Redirect after logout' | translate }}\"\n class=\"c8y-switch\"\n >\n <input\n type=\"checkbox\"\n [(ngModel)]=\"templateModel.redirectAfterLogout\"\n name=\"redirectAfterLogout\"\n id=\"redirectAfterLogout\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Redirect after logout' | translate }}</span>\n </label>\n </c8y-form-group>\n\n <c8y-form-group *ngIf=\"templateModel.redirectAfterLogout\">\n <label for=\"redirectAfterLogoutUrl\" class=\"control-label\" translate>Redirect URL</label>\n <input\n class=\"form-control\"\n name=\"redirectAfterLogoutUrl\"\n id=\"redirectAfterLogoutUrl\"\n type=\"url\"\n [(ngModel)]=\"templateModel.redirectAfterLogoutUrl\"\n placeholder=\"{{ 'e.g. https://my-tenant.cumulocity.com/apps/cockpit' | translate }}\"\n c8yDefaultValidation=\"httpUrl\"\n required\n />\n </c8y-form-group>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "component", type: FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: DefaultValidationDirective, selector: "[c8yDefaultValidation]", inputs: ["c8yDefaultValidation"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: LogoutConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-logout-configuration', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
C8yTranslateDirective,
FormGroupComponent,
FormsModule,
NgIf,
RequiredInputPlaceholderDirective,
DefaultValidationDirective,
C8yTranslatePipe
], template: "<div class=\"col-md-12 p-t-16\">\n <div class=\"row m-l-8 m-r-8\">\n <div class=\"col-xs-12 col-sm-3 col-md-2\">\n <div class=\"h4 text-normal text-right text-left-xs\" translate>Logout configuration</div>\n </div>\n <div class=\"col-xs-12 col-sm-9 col-md-10 col-lg-9\">\n <c8y-form-group>\n <label\n for=\"redirectAfterLogout\"\n title=\"{{ 'Redirect after logout' | translate }}\"\n class=\"c8y-switch\"\n >\n <input\n type=\"checkbox\"\n [(ngModel)]=\"templateModel.redirectAfterLogout\"\n name=\"redirectAfterLogout\"\n id=\"redirectAfterLogout\"\n />\n <span></span>\n <span class=\"control-label\">{{ 'Redirect after logout' | translate }}</span>\n </label>\n </c8y-form-group>\n\n <c8y-form-group *ngIf=\"templateModel.redirectAfterLogout\">\n <label for=\"redirectAfterLogoutUrl\" class=\"control-label\" translate>Redirect URL</label>\n <input\n class=\"form-control\"\n name=\"redirectAfterLogoutUrl\"\n id=\"redirectAfterLogoutUrl\"\n type=\"url\"\n [(ngModel)]=\"templateModel.redirectAfterLogoutUrl\"\n placeholder=\"{{ 'e.g. https://my-tenant.cumulocity.com/apps/cockpit' | translate }}\"\n c8yDefaultValidation=\"httpUrl\"\n required\n />\n </c8y-form-group>\n </div>\n </div>\n</div>\n" }]
}], propDecorators: { templateModel: [{
type: Input
}] } });
class AadTemplateComponent extends TemplateComponent {
constructor(aadConfigurationMapper) {
super(aadConfigurationMapper);
this.aadConfigurationMapper = aadConfigurationMapper;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AadTemplateComponent, deps: [{ token: AadConfigurationMapper }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: AadTemplateComponent, isStandalone: true, selector: "c8y-aad-template", usesInheritance: true, ngImport: i0, template: "<div *ngIf=\"templateModel\">\n <c8y-basic-configuration [templateModel]=\"templateModel\"></c8y-basic-configuration>\n <hr />\n <c8y-sso-logout-configuration [templateModel]=\"templateModel\"></c8y-sso-logout-configuration>\n <hr />\n <c8y-external-token-config [templateModel]=\"templateModel\"></c8y-external-token-config>\n <hr />\n <c8y-sso-access-mapping\n [templateModel]=\"templateModel\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-sso-access-mapping>\n <hr />\n <c8y-sso-user-data-mapping [templateModel]=\"templateModel\"></c8y-sso-user-data-mapping>\n <c8y-user-id-configuration\n [userIdConfig]=\"templateModel.userIdConfig\"\n ></c8y-user-id-configuration>\n <hr />\n <c8y-sso-signature-configuration\n [templateModel]=\"templateModel\"\n ></c8y-sso-signature-configuration>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: BasicConfigurationComponent, selector: "c8y-basic-configuration", inputs: ["templateModel"] }, { kind: "component", type: LogoutConfigurationComponent, selector: "c8y-sso-logout-configuration", inputs: ["templateModel"] }, { kind: "component", type: ExternalTokenConfigComponent, selector: "c8y-external-token-config", inputs: ["templateModel"] }, { kind: "component", type: AccessMappingComponent, selector: "c8y-sso-access-mapping", inputs: ["apps", "groups", "inventoryRoles", "templateModel"] }, { kind: "component", type: UserDataMappingComponent, selector: "c8y-sso-user-data-mapping", inputs: ["templateModel"] }, { kind: "component", type: UserIdConfigurationComponent, selector: "c8y-user-id-configuration", inputs: ["userIdConfig", "withHeader"] }, { kind: "component", type: SignatureConfigurationComponent, selector: "c8y-sso-signature-configuration", inputs: ["templateModel"] }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AadTemplateComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-aad-template', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
BasicConfigurationComponent,
LogoutConfigurationComponent,
ExternalTokenConfigComponent,
AccessMappingComponent,
UserDataMappingComponent,
UserIdConfigurationComponent,
SignatureConfigurationComponent
], template: "<div *ngIf=\"templateModel\">\n <c8y-basic-configuration [templateModel]=\"templateModel\"></c8y-basic-configuration>\n <hr />\n <c8y-sso-logout-configuration [templateModel]=\"templateModel\"></c8y-sso-logout-configuration>\n <hr />\n <c8y-external-token-config [templateModel]=\"templateModel\"></c8y-external-token-config>\n <hr />\n <c8y-sso-access-mapping\n [templateModel]=\"templateModel\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-sso-access-mapping>\n <hr />\n <c8y-sso-user-data-mapping [templateModel]=\"templateModel\"></c8y-sso-user-data-mapping>\n <c8y-user-id-configuration\n [userIdConfig]=\"templateModel.userIdConfig\"\n ></c8y-user-id-configuration>\n <hr />\n <c8y-sso-signature-configuration\n [templateModel]=\"templateModel\"\n ></c8y-sso-signature-configuration>\n</div>\n" }]
}], ctorParameters: () => [{ type: AadConfigurationMapper }] });
class KeyCloakConfigurationMapper {
constructor() {
this.urlPattern = /^(.+)\/auth\/realms\/((.+?))$/;
}
mapFrom(templateModel) {
const ssoConfiguration = {
template: TemplateType.KEYCLOAK,
buttonName: templateModel.buttonName,
userIdConfig: templateModel.userIdConfig,
userManagementSource: UserManagementSource.REMOTE,
type: TenantLoginOptionType.OAUTH2,
onNewUser: templateModel.onNewUser,
issuer: `${templateModel.keyCloakAddress}/auth/realms/${templateModel.realmName}`,
redirectToPlatform: templateModel.redirectToPlatform || null,
providerName: 'keycloak',
audience: templateModel.audience,
clientId: templateModel.clientId,
logoutRequest: templateModel.logoutRequest.toRequest(),
visibleOnLoginPage: templateModel.visibleOnLoginPage,
signatureVerificationConfig: {
jwks: {
jwksUri: `${templateModel.keyCloakAddress}/auth/realms/${templateModel.realmName}/protocol/openid-connect/certs`
}
},
tokenRequest: {
headers: {},
method: 'POST',
requestParams: {},
operation: 'EXECUTE',
url: `${templateModel.keyCloakAddress}/auth/realms/${templateModel.realmName}/protocol/openid-connect/token`,
body: 'grant_type=authorization_code&code=${code}&redirect_uri=${redirectUri}&client_id=${clientId}&client_secret=' +
templateModel.clientSecret
},
authorizationRequest: {
headers: {},
method: 'GET',
requestParams: {
scope: templateModel.scopeId,
client_id: '${clientId}',
redirect_uri: '${redirectUri}',
response_type: 'code'
},
operation: 'REDIRECT',
url: `${templateModel.keyCloakAddress}/auth/realms/${templateModel.realmName}/protocol/openid-connect/auth`,
body: ''
},
refreshRequest: {
headers: {},
method: 'POST',
requestParams: {
client_id: '${clientId}',
redirect_uri: '${redirectUri}',
response_type: 'refresh'
},
operation: 'EXECUTE',
url: `${templateModel.keyCloakAddress}/auth/realms/${templateModel.realmName}/protocol/openid-connect/token`,
body: 'grant_type=refresh_token&refresh_token=${refreshToken}&client_id=${clientId}&client_secret=' +
templateModel.clientSecret
},
grantType: GrantType.AUTHORIZATION_CODE,
accessTokenToUserDataMappings: templateModel.accessTokenToUserDataMappings,
externalTokenConfig: templateModel.externalTokenConfig.toExternalTokenConfig(),
useIdToken: templateModel.useIdToken
};
return ssoConfiguration;
}
mapTo(ssoConfiguration) {
return {
keyCloakAddress: this.getKeyCloakAddressFromUrl(ssoConfiguration.issuer),
realmName: this.getRealmName(ssoConfiguration.issuer),
clientId: ssoConfiguration.clientId,
clientSecret: this.getClientSecret(ssoConfiguration),
scopeId: this.getScopeId(ssoConfiguration),
buttonName: ssoConfiguration.buttonName,
userIdConfig: ssoConfiguration.userIdConfig,
onNewUser: ssoConfiguration.onNewUser,
redirectToPlatform: ssoConfiguration.redirectToPlatform,
audience: ssoConfiguration.audience,
logoutRequest: new RequestConfiguration(ssoConfiguration.logoutRequest),
visibleOnLoginPage: ssoConfiguration.visibleOnLoginPage,
accessTokenToUserDataMappings: ssoConfiguration.accessTokenToUserDataMappings,
externalTokenConfig: new ExternalToken(ssoConfiguration.externalTokenConfig),
useIdToken: ssoConfiguration.useIdToken
};
}
getKeyCloakAddressFromUrl(url) {
const [, keyCloakAddress] = (url || '').match(this.urlPattern) || [];
return keyCloakAddress;
}
getRealmName(url) {
const [, , realmName] = (url || '').match(this.urlPattern) || [];
return realmName;
}
getClientSecret(ssoConfiguration) {
const bodies = at(ssoConfiguration, ['tokenRequest.body', 'refreshRequest.body']);
const clientSecrets = map$1(bodies, body => this.getClientSecretFromBody(body));
const clientSecret = this.getFirstDefined(clientSecrets);
return clientSecret ? decodeURIComponent(clientSecret) : '';
}
getClientSecretFromBody(body) {
const [, clientSecret] = (body || '').match(/client_secret=([^&]+)/) || [];
return clientSecret;
}
getFirstDefined(values) {
return head(reject(values, isUndefined));
}
getScopeId(ssoConfiguration) {
return get(ssoConfiguration, 'authorizationRequest.requestParams.scope', '');
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: KeyCloakConfigurationMapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: KeyCloakConfigurationMapper, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: KeyCloakConfigurationMapper, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}] });
class KeyCloakTemplateComponent extends TemplateComponent {
constructor(keyCloakConfigurationMapper) {
super(keyCloakConfigurationMapper);
this.keyCloakConfigurationMapper = keyCloakConfigurationMapper;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: KeyCloakTemplateComponent, deps: [{ token: KeyCloakConfigurationMapper }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: KeyCloakTemplateComponent, isStandalone: true, selector: "c8y-key-cloak-template", usesInheritance: true, ngImport: i0, template: "<div *ngIf=\"templateModel\">\n <c8y-basic-configuration [templateModel]=\"templateModel\"></c8y-basic-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Logout request' | translate\"\n [requestType]=\"'logoutRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-external-token-config [templateModel]=\"templateModel\"></c8y-external-token-config>\n <hr />\n <c8y-sso-access-mapping\n [templateModel]=\"templateModel\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-sso-access-mapping>\n <hr />\n <c8y-sso-user-data-mapping [templateModel]=\"templateModel\"></c8y-sso-user-data-mapping>\n <c8y-user-id-configuration\n [userIdConfig]=\"templateModel.userIdConfig\"\n ></c8y-user-id-configuration>\n</div>\n", dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: BasicConfigurationComponent, selector: "c8y-basic-configuration", inputs: ["templateModel"] }, { kind: "component", type: RequestConfigurationComponent, selector: "c8y-request-configuration", inputs: ["templateModel", "requestName", "requestType"] }, { kind: "component", type: ExternalTokenConfigComponent, selector: "c8y-external-token-config", inputs: ["templateModel"] }, { kind: "component", type: AccessMappingComponent, selector: "c8y-sso-access-mapping", inputs: ["apps", "groups", "inventoryRoles", "templateModel"] }, { kind: "component", type: UserDataMappingComponent, selector: "c8y-sso-user-data-mapping", inputs: ["templateModel"] }, { kind: "component", type: UserIdConfigurationComponent, selector: "c8y-user-id-configuration", inputs: ["userIdConfig", "withHeader"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: KeyCloakTemplateComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-key-cloak-template', viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], imports: [
NgIf,
BasicConfigurationComponent,
RequestConfigurationComponent,
ExternalTokenConfigComponent,
AccessMappingComponent,
UserDataMappingComponent,
UserIdConfigurationComponent,
C8yTranslatePipe
], template: "<div *ngIf=\"templateModel\">\n <c8y-basic-configuration [templateModel]=\"templateModel\"></c8y-basic-configuration>\n <hr />\n <c8y-request-configuration\n [templateModel]=\"templateModel\"\n [requestName]=\"'Logout request' | translate\"\n [requestType]=\"'logoutRequest'\"\n ></c8y-request-configuration>\n <hr />\n <c8y-external-token-config [templateModel]=\"templateModel\"></c8y-external-token-config>\n <hr />\n <c8y-sso-access-mapping\n [templateModel]=\"templateModel\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-sso-access-mapping>\n <hr />\n <c8y-sso-user-data-mapping [templateModel]=\"templateModel\"></c8y-sso-user-data-mapping>\n <c8y-user-id-configuration\n [userIdConfig]=\"templateModel.userIdConfig\"\n ></c8y-user-id-configuration>\n</div>\n" }]
}], ctorParameters: () => [{ type: KeyCloakConfigurationMapper }] });
class SsoConfigurationComponent {
constructor(ssoConfigurationService, applicationService, userGroupService, inventoryRoleService, alertService, modalService, authService, tenantUiService) {
this.ssoConfigurationService = ssoConfigurationService;
this.applicationService = applicationService;
this.userGroupService = userGroupService;
this.inventoryRoleService = inventoryRoleService;
this.alertService = alertService;
this.modalService = modalService;
this.authService = authService;
this.tenantUiService = tenantUiService;
this.templateType = TemplateType;
this.templateTypeConfig = templateTypeConfig;
this.reloading$ = new BehaviorSubject(false);
this.reload = new EventEmitter();
this.saveSubject = new Subject();
this.data$ = this.reload.pipe(tap(() => this.reloading$.next(true)), switchMap(() => forkJoin({
ssoConfiguration: this.ssoConfigurationService.getSsoConfiguration$(),
apps: this.getApplications(),
groups: this.getGroups(),
inventoryRoles: this.getInventoryRoles()
})), tap(() => this.reloading$.next(false)), shareReplay(1));
}
ngOnInit() {
this.dataSubscription = this.data$.subscribe(({ ssoConfiguration, apps, groups, inventoryRoles }) => {
this.apps = apps;
this.groups = groups;
this.inventoryRoles = inventoryRoles;
this.ssoConfiguration = ssoConfiguration;
});
this.loadSsoConfiguration();
}
ngOnDestroy() {
this.dataSubscription.unsubscribe();
}
loadSsoConfiguration() {
this.reload.next();
this.ssoConfigurationForm.form.markAsPristine();
}
async save(ssoConfiguration) {
try {
await this.warnAboutForceUsersLogOut();
const logoutRequired = this.tenantUiService.getCurrentUserLoginMode() !== TenantLoginOptionType.BASIC;
if (logoutRequired) {
await this.modalService.confirmLogout();
}
await this.ssoConfigurationService.save(ssoConfiguration);
if (logoutRequired) {
await this.authService.logout(true);
}
else {
this.loadSsoConfiguration();
this.alertService.success(gettext('Configuration saved.'));
}
}
catch (ex) {
if (ex) {
this.alertService.addServerFailure(ex);
}
else {
this.loadSsoConfiguration();
}
}
}
getApplications() {
return this.applicationService.listByTenant(null, { pageSize: 100 }).then(res => res.data, error => this.alertService.addServerFailure(error));
}
getGroups() {
return this.userGroupService.list({ pageSize: 100 }).then(res => res.data, error => this.alertService.addServerFailure(error));
}
getInventoryRoles() {
return this.inventoryRoleService.list({ pageSize: 100 }).then(res => res.data, error => this.alertService.addServerFailure(error));
}
async warnAboutForceUsersLogOut() {
const modalLabels = { ok: gettext('Update and log out users'), cancel: gettext('Cancel') };
const modalBody = gettext('Updating SSO configuration will log out all users logged with "OAI-Secure" or "Single sign-on redirect". Do you want to proceed?');
return await this.modalService.confirm(gettext('Force users to log out'), modalBody, Status.WARNING, modalLabels);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationComponent, deps: [{ token: SsoConfigurationService }, { token: i1$1.ApplicationService }, { token: i1$1.UserGroupService }, { token: i1$1.InventoryRoleService }, { token: i2.AlertService }, { token: i2.ModalService }, { token: i2.SimplifiedAuthService }, { token: i2.TenantUiService }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.15", type: SsoConfigurationComponent, isStandalone: true, selector: "c8y-sso-configuration", viewQueries: [{ propertyName: "ssoConfigurationForm", first: true, predicate: ["ssoConfigurationForm"], descendants: true }], ngImport: i0, template: "<c8y-title>{{ 'Single sign-on' | translate }}</c8y-title>\n<c8y-breadcrumb>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Settings' | translate\"\n ></c8y-breadcrumb-item>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Single sign-on' | translate\"\n ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n <button\n class=\"btn btn-link\"\n title=\"{{ 'Reload' | translate }}\"\n type=\"button\"\n (click)=\"loadSsoConfiguration()\"\n >\n <i\n c8yIcon=\"refresh\"\n [ngClass]=\"{ 'icon-spin': reloading$ | async }\"\n ></i>\n {{ 'Reload' | translate }}\n </button>\n</c8y-action-bar-item>\n\n<c8y-action-bar-item\n [placement]=\"'left'\"\n itemClass=\"navbar-form hidden-xs\"\n>\n <div\n class=\"form-group d-flex m-b-0\"\n title=\"{{ 'Template' | translate }}\"\n >\n <label\n class=\"control-label\"\n for=\"template\"\n >\n {{ 'Template' | translate }}\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n id=\"template\"\n name=\"template\"\n *ngIf=\"ssoConfiguration\"\n [(ngModel)]=\"ssoConfiguration.template\"\n >\n <option\n *ngFor=\"let templateType of templateTypeConfig | keyvalue\"\n [ngValue]=\"templateType.key\"\n >\n {{ templateType.value.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </div>\n</c8y-action-bar-item>\n\n<div class=\"row\">\n <div class=\"col-lg-12 col-lg-max\">\n <form\n class=\"card card--fullpage\"\n #ssoConfigurationForm=\"ngForm\"\n novalidate\n >\n <div class=\"card-header separator\">\n <div class=\"card-title\">\n {{ 'Single sign-on' | translate }}\n </div>\n </div>\n\n <div class=\"inner-scroll\">\n <div\n class=\"card-block p-0\"\n *ngIf=\"ssoConfiguration\"\n >\n <c8y-custom-template\n *ngIf=\"ssoConfiguration.template === templateType.CUSTOM\"\n [ssoConfiguration]=\"ssoConfiguration\"\n [ssoConfigurationChangeTrigger]=\"saveSubject.asObservable()\"\n (ssoConfigurationChange)=\"save($event)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-custom-template>\n\n <c8y-aad-template\n *ngIf=\"ssoConfiguration.template === templateType.AZURE\"\n [ssoConfiguration]=\"ssoConfiguration\"\n [ssoConfigurationChangeTrigger]=\"saveSubject.asObservable()\"\n (ssoConfigurationChange)=\"save($event)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-aad-template>\n\n <c8y-key-cloak-template\n *ngIf=\"ssoConfiguration.template === templateType.KEYCLOAK\"\n [ssoConfiguration]=\"ssoConfiguration\"\n [ssoConfigurationChangeTrigger]=\"saveSubject.asObservable()\"\n (ssoConfigurationChange)=\"save($event)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-key-cloak-template>\n </div>\n </div>\n <div class=\"card-footer separator\">\n <button\n class=\"btn btn-primary\"\n title=\"{{ 'Save' | translate }}\"\n type=\"submit\"\n (click)=\"saveSubject.next()\"\n [disabled]=\"!ssoConfigurationForm.form.valid || ssoConfigurationForm.form.pristine\"\n >\n {{ 'Save' | translate }}\n </button>\n </div>\n </form>\n </div>\n</div>\n", dependencies: [{ kind: "component", type: TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "component", type: BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "component", type: ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: CustomTemplateComponent, selector: "c8y-custom-template" }, { kind: "component", type: AadTemplateComponent, selector: "c8y-aad-template" }, { kind: "component", type: KeyCloakTemplateComponent, selector: "c8y-key-cloak-template" }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationComponent, decorators: [{
type: Component,
args: [{ selector: 'c8y-sso-configuration', imports: [
TitleComponent,
BreadcrumbComponent,
BreadcrumbItemComponent,
ActionBarItemComponent,
IconDirective,
NgClass,
NgIf,
FormsModule,
NgFor,
CustomTemplateComponent,
AadTemplateComponent,
KeyCloakTemplateComponent,
C8yTranslatePipe,
AsyncPipe,
KeyValuePipe
], template: "<c8y-title>{{ 'Single sign-on' | translate }}</c8y-title>\n<c8y-breadcrumb>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Settings' | translate\"\n ></c8y-breadcrumb-item>\n <c8y-breadcrumb-item\n [icon]=\"'cog'\"\n [label]=\"'Single sign-on' | translate\"\n ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n <button\n class=\"btn btn-link\"\n title=\"{{ 'Reload' | translate }}\"\n type=\"button\"\n (click)=\"loadSsoConfiguration()\"\n >\n <i\n c8yIcon=\"refresh\"\n [ngClass]=\"{ 'icon-spin': reloading$ | async }\"\n ></i>\n {{ 'Reload' | translate }}\n </button>\n</c8y-action-bar-item>\n\n<c8y-action-bar-item\n [placement]=\"'left'\"\n itemClass=\"navbar-form hidden-xs\"\n>\n <div\n class=\"form-group d-flex m-b-0\"\n title=\"{{ 'Template' | translate }}\"\n >\n <label\n class=\"control-label\"\n for=\"template\"\n >\n {{ 'Template' | translate }}\n </label>\n <div class=\"c8y-select-wrapper\">\n <select\n class=\"form-control\"\n id=\"template\"\n name=\"template\"\n *ngIf=\"ssoConfiguration\"\n [(ngModel)]=\"ssoConfiguration.template\"\n >\n <option\n *ngFor=\"let templateType of templateTypeConfig | keyvalue\"\n [ngValue]=\"templateType.key\"\n >\n {{ templateType.value.label | translate }}\n </option>\n </select>\n <span></span>\n </div>\n </div>\n</c8y-action-bar-item>\n\n<div class=\"row\">\n <div class=\"col-lg-12 col-lg-max\">\n <form\n class=\"card card--fullpage\"\n #ssoConfigurationForm=\"ngForm\"\n novalidate\n >\n <div class=\"card-header separator\">\n <div class=\"card-title\">\n {{ 'Single sign-on' | translate }}\n </div>\n </div>\n\n <div class=\"inner-scroll\">\n <div\n class=\"card-block p-0\"\n *ngIf=\"ssoConfiguration\"\n >\n <c8y-custom-template\n *ngIf=\"ssoConfiguration.template === templateType.CUSTOM\"\n [ssoConfiguration]=\"ssoConfiguration\"\n [ssoConfigurationChangeTrigger]=\"saveSubject.asObservable()\"\n (ssoConfigurationChange)=\"save($event)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-custom-template>\n\n <c8y-aad-template\n *ngIf=\"ssoConfiguration.template === templateType.AZURE\"\n [ssoConfiguration]=\"ssoConfiguration\"\n [ssoConfigurationChangeTrigger]=\"saveSubject.asObservable()\"\n (ssoConfigurationChange)=\"save($event)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-aad-template>\n\n <c8y-key-cloak-template\n *ngIf=\"ssoConfiguration.template === templateType.KEYCLOAK\"\n [ssoConfiguration]=\"ssoConfiguration\"\n [ssoConfigurationChangeTrigger]=\"saveSubject.asObservable()\"\n (ssoConfigurationChange)=\"save($event)\"\n [apps]=\"apps\"\n [groups]=\"groups\"\n [inventoryRoles]=\"inventoryRoles\"\n ></c8y-key-cloak-template>\n </div>\n </div>\n <div class=\"card-footer separator\">\n <button\n class=\"btn btn-primary\"\n title=\"{{ 'Save' | translate }}\"\n type=\"submit\"\n (click)=\"saveSubject.next()\"\n [disabled]=\"!ssoConfigurationForm.form.valid || ssoConfigurationForm.form.pristine\"\n >\n {{ 'Save' | translate }}\n </button>\n </div>\n </form>\n </div>\n</div>\n" }]
}], ctorParameters: () => [{ type: SsoConfigurationService }, { type: i1$1.ApplicationService }, { type: i1$1.UserGroupService }, { type: i1$1.InventoryRoleService }, { type: i2.AlertService }, { type: i2.ModalService }, { type: i2.SimplifiedAuthService }, { type: i2.TenantUiService }], propDecorators: { ssoConfigurationForm: [{
type: ViewChild,
args: ['ssoConfigurationForm']
}] } });
class SsoConfigurationGuard {
constructor(ssoConfigurationService) {
this.ssoConfigurationService = ssoConfigurationService;
}
canActivate() {
return this.ssoConfigurationService.getSsoConfiguration$().pipe(mapTo(true), catchError(() => of(false)));
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationGuard, deps: [{ token: SsoConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationGuard }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationGuard, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: SsoConfigurationService }] });
class SsoConfigurationModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationModule, imports: [CoreModule,
TooltipModule,
PopoverModule, i1$4.CollapseModule, BsDatepickerModule,
AssetSelectorModule,
PaginatedListGroupComponent,
SsoConfigurationComponent,
CustomTemplateComponent,
KeyCloakTemplateComponent,
AadTemplateComponent,
BasicConfigurationComponent,
RequestConfigurationComponent,
UserIdConfigurationComponent,
UserDataMappingComponent,
AccessMappingComponent,
DynamicAccessMappingComponent,
SignatureConfigurationComponent,
LogoutConfigurationComponent,
ChildPredicatesComponent,
InventoryRolesMappingComponent,
InventoryRolesModalComponent,
ExternalTokenConfigComponent], exports: [SsoConfigurationComponent] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationModule, providers: [
SsoConfigurationGuard,
SsoConfigurationService,
AadConfigurationMapper,
CustomConfigurationMapper,
KeyCloakConfigurationMapper,
hookRoute({
path: 'auth-configuration/single_sign-on',
component: SsoConfigurationComponent,
canActivate: [AuthConfigurationGuard, SsoConfigurationGuard]
})
], imports: [CoreModule,
TooltipModule,
PopoverModule,
CollapseModule.forRoot(),
BsDatepickerModule,
AssetSelectorModule,
PaginatedListGroupComponent,
SsoConfigurationComponent,
CustomTemplateComponent,
KeyCloakTemplateComponent,
AadTemplateComponent,
BasicConfigurationComponent,
RequestConfigurationComponent,
UserIdConfigurationComponent,
UserDataMappingComponent,
AccessMappingComponent,
DynamicAccessMappingComponent,
SignatureConfigurationComponent,
LogoutConfigurationComponent,
ChildPredicatesComponent,
InventoryRolesMappingComponent,
InventoryRolesModalComponent,
ExternalTokenConfigComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: SsoConfigurationModule, decorators: [{
type: NgModule,
args: [{
imports: [
CoreModule,
TooltipModule,
PopoverModule,
CollapseModule.forRoot(),
BsDatepickerModule,
AssetSelectorModule,
PaginatedListGroupComponent,
SsoConfigurationComponent,
CustomTemplateComponent,
KeyCloakTemplateComponent,
AadTemplateComponent,
BasicConfigurationComponent,
RequestConfigurationComponent,
UserIdConfigurationComponent,
UserDataMappingComponent,
AccessMappingComponent,
DynamicAccessMappingComponent,
SignatureConfigurationComponent,
LogoutConfigurationComponent,
ChildPredicatesComponent,
InventoryRolesMappingComponent,
InventoryRolesModalComponent,
ExternalTokenConfigComponent
],
exports: [SsoConfigurationComponent],
providers: [
SsoConfigurationGuard,
SsoConfigurationService,
AadConfigurationMapper,
CustomConfigurationMapper,
KeyCloakConfigurationMapper,
hookRoute({
path: 'auth-configuration/single_sign-on',
component: SsoConfigurationComponent,
canActivate: [AuthConfigurationGuard, SsoConfigurationGuard]
})
]
}]
}] });
class AuthConfigurationTabsFactory {
constructor(router, ssoConfigurationService) {
this.router = router;
this.ssoConfigurationService = ssoConfigurationService;
}
get() {
if (!this.router.url.match(/auth-configuration/g)) {
return of([]);
}
const basicSettingsTab$ = of({
path: 'auth-configuration/basic_settings',
label: gettext('Basic settings'),
icon: 'unlock-alt',
priority: 1100,
orientation: 'horizontal'
});
const ssoTab$ = this.ssoConfigurationService.getSsoConfiguration$().pipe(mapTo({
path: 'auth-configuration/single_sign-on',
label: gettext('Single sign-on'),
icon: 'sign-in',
priority: 1050,
orientation: 'horizontal'
}), catchError(() => EMPTY));
return merge([basicSettingsTab$, ssoTab$]).pipe(mergeAll(), toArray());
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationTabsFactory, deps: [{ token: i1$5.Router }, { token: SsoConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationTabsFactory }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationTabsFactory, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i1$5.Router }, { type: SsoConfigurationService }] });
class AuthConfigurationNavigationFactory {
constructor(permissions) {
this.permissions = permissions;
this.navs = [];
}
async get() {
const userHasPermission = this.permissions.hasAnyRole([
Permissions.ROLE_TENANT_ADMIN,
Permissions.ROLE_TENANT_MANAGEMENT_ADMIN
]);
if (this.navs.length === 0 && userHasPermission) {
this.navs.push(new NavigatorNode({
label: gettext('Authentication'),
icon: 'c8y-shield',
path: '/auth-configuration',
parent: gettext('Settings'),
routerLinkExact: false,
priority: 2000
}));
}
return this.navs;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationNavigationFactory, deps: [{ token: i2.Permissions }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationNavigationFactory }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationNavigationFactory, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: i2.Permissions }] });
const MESSAGES_AUTH_CONFIGURATION = {
'^The tenant option: configuration/tenant.login.ignore-case cannot be enabled : Username or alias is duplicated when case sensitivity is ignored.$': {
gettext: gettext('Could not enable the "Ignore case when logging in" feature. Duplicate usernames or aliases were detected when ignoring case sensitivity. Resolve conflicting names and try again.')
},
"^The tenant option: configuration/tenant.login.ignore-case cannot be managed : Feature 'Ignore case on username or alias login' is not available.$": {
gettext: gettext('The feature "Ignore case when logging in" is not available.')
},
"^The tenant option: configuration/tenant.login.ignore-case cannot be managed : Only a tenant administrator can change the state of the 'Ignore case on username or alias login' feature.$": {
gettext: gettext('Only a tenant administrator can configure the "Ignore case when logging in" option.')
}
};
class AuthConfigurationModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationModule, imports: [BasicSettingsModule, SsoConfigurationModule] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationModule, providers: [
AuthConfigurationGuard,
hookTab(AuthConfigurationTabsFactory),
hookNavigator(AuthConfigurationNavigationFactory),
hookPatternMessages(MESSAGES_AUTH_CONFIGURATION),
hookRoute({
path: 'auth-configuration',
redirectTo: 'auth-configuration/basic_settings',
pathMatch: 'full'
})
], imports: [BasicSettingsModule, SsoConfigurationModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AuthConfigurationModule, decorators: [{
type: NgModule,
args: [{
imports: [BasicSettingsModule, SsoConfigurationModule],
providers: [
AuthConfigurationGuard,
hookTab(AuthConfigurationTabsFactory),
hookNavigator(AuthConfigurationNavigationFactory),
hookPatternMessages(MESSAGES_AUTH_CONFIGURATION),
hookRoute({
path: 'auth-configuration',
redirectTo: 'auth-configuration/basic_settings',
pathMatch: 'full'
})
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { AuthConfigurationModule, AuthConfigurationTabsFactory };
//# sourceMappingURL=c8y-ngx-components-auth-configuration.mjs.map