Merge branch 'hotfix/1.9.9' into feature/SUPPORT-8643_error_code

# Conflicts:
#	frontend/src/ts/modules/security/guard/auth.guard.ts
This commit is contained in:
Eduard Tihomirov 2025-02-26 10:23:32 +03:00
commit 89ff7b8747
169 changed files with 1561 additions and 375 deletions

View file

@ -1748,9 +1748,9 @@
}
},
"@webbpm/base-package": {
"version": "3.187.2",
"resolved": "https://repo.micord.ru/repository/npm-all/@webbpm/base-package/-/base-package-3.187.2.tgz",
"integrity": "sha512-qDW+Yjm/gyTIM/4N7uQasQR1zk2tGGAF6rJFpSUSb1A7PYreXPqSAShzWJJJ1YZ9CCz2dAXSQzm6JjUJKu2VUg==",
"version": "3.187.3",
"resolved": "https://repo.micord.ru/repository/npm-all/@webbpm/base-package/-/base-package-3.187.3.tgz",
"integrity": "sha512-uhESrMdBnxeWXX5LNENvzzq0k0t4jHcuD1JmRAF0WIFfKqhZNMsmd0xxf2CYMUSJrWESyjX2wiqpKFhDHd0+/A==",
"requires": {
"tslib": "^1.9.0"
}

View file

@ -26,7 +26,7 @@
"@angular/platform-browser-dynamic": "7.2.15",
"@angular/router": "7.2.15",
"@ng-bootstrap/ng-bootstrap": "4.2.2-micord.1",
"@webbpm/base-package": "3.187.2",
"@webbpm/base-package": "3.187.3",
"ag-grid-angular": "29.0.0-micord.4",
"ag-grid-community": "29.0.0-micord.4",
"angular-calendar": "0.28.28",

View file

@ -4,7 +4,7 @@
<parent>
<groupId>ru.micord.ervu.lkrp</groupId>
<artifactId>fl</artifactId>
<version>1.9.8-SNAPSHOT</version>
<version>1.9.9-SNAPSHOT</version>
</parent>
<groupId>ru.micord.ervu.lkrp.fl</groupId>

View file

@ -17,5 +17,6 @@
"password_pattern_error": "Пароль должен содержать заглавные или прописные буквы и как минимум 1 цифру",
"show.client.errors": false,
"available_task.single_fetch": true,
"cert_check_url": "https://lkrp-dev2.micord.ru"
"cert_check_url": "https://lkrp-dev2.micord.ru",
"unknown.error.msg": "Система временно недоступна. Пожалуйста, повторите попытку позже."
}

View file

@ -0,0 +1,42 @@
import {AnalyticalScope, Behavior, Control, NotNull} from "@webbpm/base-package";
import {ElementRef} from "@angular/core";
import {AuditService} from "./service/AuditService";
import {LinkEventTypeEnum} from "./component/enum/LinkEventTypeEnum";
@AnalyticalScope(Control)
export class LinkClickHandler extends Behavior {
@NotNull()
public eventType: LinkEventTypeEnum;
private control: Control;
private auditService: AuditService;
private el: ElementRef;
initialize() {
this.control = this.getScript(Control);
this.el = this.control.getEl();
super.initialize();
}
bindEvents() {
super.bindEvents();
if (this.el) {
this.el.nativeElement.addEventListener('click',
(event: MouseEvent) => this.onClickFunction(event));
}
}
unbindEvents() {
super.unbindEvents()
if (this.el) {
this.el.nativeElement.removeEventListener('click',
(event: MouseEvent) => this.onClickFunction(event));
}
}
private onClickFunction(event: MouseEvent) {
const target = event.target as HTMLElement;
if (target.tagName === 'A') {
this.auditService.logActionAudit(this.eventType);
}
}
}

View file

@ -29,8 +29,12 @@ export class ExtractLoadService extends Behavior {
this.errorEvent.subscribe(() => console.log("error event occurred", this.errorEvent));
this.onClickFunction = () => {
console.log("click event occurred");
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
this.httpClient.get('extract/' + this.formatRegistry, {
responseType: 'blob',
headers: {
"Client-Time-Zone": timeZone,
},
observe: 'response'
}).toPromise()
.then((response) => {

View file

@ -0,0 +1,5 @@
export enum LinkEventTypeEnum {
NAVIGATION_TO_SOURCE = "Переход на другие источники",
DOWNLOAD_TEMPLATE = "Скачивание шаблона",
DOWNLOAD_EXAMPLE = "Скачивание примера заполнения формы"
}

View file

@ -0,0 +1,43 @@
import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Router} from "@angular/router";
@Injectable({
providedIn: 'root'
})
export class AuditService {
constructor(private httpClient: HttpClient, private router: Router) {
}
public logActionAudit(eventType: string, fileName?: string): void {
const currentRoute = this.router.url;
const sourceUrl = window.location.href;
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const data: AuditAction = {
eventType: eventType,
sourceUrl: sourceUrl,
route: currentRoute,
fileName: fileName
};
this.httpClient.post("audit/action", data, {
headers: {
"Client-Time-Zone": timeZone,
}
}).toPromise();
}
}
export interface AuditAction {
eventType: string;
sourceUrl: string;
route: string;
fileName?: string;
}
export class AuditConstants {
public static readonly OPEN_PAGE_EVENT = "Открытие страницы";
}

View file

@ -24,6 +24,7 @@ import {LogOutComponent} from "./component/logout.component";
import {LoadForm} from "../../ervu/component/container/LoadForm";
import {InMemoryStaticGrid} from "../../ervu/component/grid/InMemoryStaticGrid";
import {AuthenticationService} from "../security/authentication.service";
import {AuditService} from "../../ervu/service/AuditService";
import {HomeLandingComponent} from "./component/home-landing.component";
registerLocaleData(localeRu);
@ -64,7 +65,7 @@ export function checkAuthentication(authService: AuthenticationService): () => P
DIRECTIVES
],
providers: [
AuthenticationService,
AuthenticationService, AuditService,
{
provide: APP_INITIALIZER,
useFactory: checkAuthentication,

View file

@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {CookieService} from "ngx-cookie";
import {AppConfigService} from "@webbpm/base-package";
import {map, tap} from "rxjs/operators";
@Injectable({providedIn: 'root'})
export class AuthenticationService {
@ -22,4 +23,13 @@ export class AuthenticationService {
public isAuthenticated(): boolean {
return this.cookieService.get('webbpm.ervu-lkrp-fl') != null;
}
public redirectToEsia() {
return this.http.get<string>("esia/url").pipe(
tap(url => {
window.open(url, "_self");
}),
map(() => true)
);
}
}

View file

@ -32,7 +32,7 @@ export abstract class AuthGuard implements CanActivate {
}
if (error) {
let errorMessage =
'Произошла неизвестная ошибка. Обратитесь к системному администратору';
this.messageService.getUnknowErrorMessage();
let errorCode = this.extractCode(errorDescription);
if (errorCode) {
errorMessage = EsiaErrorDetail.getDescription(errorCode);
@ -57,15 +57,10 @@ export abstract class AuthGuard implements CanActivate {
return false;
}
else {
return this.httpClient.get<string>("esia/url")
.toPromise()
.then(url => {
window.open(url, "_self");
return true;
}).catch((reason)=> {
console.error(reason);
return false;
});
return this.authenticationService.redirectToEsia().toPromise().catch((reason) => {
console.error(reason);
return false;
});
}
}).catch((reason) => {
console.error(reason);

View file

@ -8,6 +8,7 @@ import {
Router
} from "@angular/router";
import {ProgressIndicationService} from "@webbpm/base-package";
import {AuditConstants, AuditService} from "../../../ervu/service/AuditService";
@Component({
moduleId: module.id,
@ -21,7 +22,8 @@ export class WebbpmComponent {
constructor(private router: Router,
private progressIndicationService: ProgressIndicationService,
private cd: ChangeDetectorRef) {
private cd: ChangeDetectorRef,
private auditService: AuditService) {
router.events.subscribe((event: Event) => {
if (event instanceof NavigationStart) {
progressIndicationService.showProgressBar();
@ -29,9 +31,15 @@ export class WebbpmComponent {
this.cd.markForCheck();
}
else if (event instanceof NavigationEnd
|| event instanceof NavigationError
|| event instanceof NavigationCancel) {
|| event instanceof NavigationError
|| event instanceof NavigationCancel) {
progressIndicationService.hideProgressBar();
if (event instanceof NavigationEnd
&& event.url != '/home'
&& event.url != '/access-denied') {
this.auditService.logActionAudit(AuditConstants.OPEN_PAGE_EVENT);
}
}
})
}

View file

@ -1,14 +1,14 @@
import {HTTP_INTERCEPTORS} from "@angular/common/http";
import {
FormDirtyInterceptor,
HttpSecurityErrorInterceptor,
HttpSecurityInterceptor
} from "@webbpm/base-package";
import {AbsoluteUrlCsrfInterceptor} from "./absolute-url-csrf.interceptor";
import {ErvuHttpSecurityErrorInterceptor} from "./ervu-http-security-error-interceptor";
export const DEFAULT_HTTP_INTERCEPTOR_PROVIDERS = [
{provide: HTTP_INTERCEPTORS, useClass: HttpSecurityInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: HttpSecurityErrorInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: ErvuHttpSecurityErrorInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: FormDirtyInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: AbsoluteUrlCsrfInterceptor, multi: true}
];

View file

@ -2,10 +2,11 @@ import {HTTP_INTERCEPTORS} from "@angular/common/http";
import {FormDirtyInterceptor, HttpSecurityInterceptor} from "@webbpm/base-package";
import {DevHttpSecurityErrorInterceptor} from "./http-security-error-interceptor.dev";
import {AbsoluteUrlCsrfInterceptor} from "./absolute-url-csrf.interceptor";
import {ErvuHttpSecurityErrorInterceptor} from "./ervu-http-security-error-interceptor";
export const DEFAULT_HTTP_INTERCEPTOR_PROVIDERS = [
{provide: HTTP_INTERCEPTORS, useClass: HttpSecurityInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: DevHttpSecurityErrorInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: ErvuHttpSecurityErrorInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: FormDirtyInterceptor, multi: true},
{provide: HTTP_INTERCEPTORS, useClass: AbsoluteUrlCsrfInterceptor, multi: true},
];

View file

@ -0,0 +1,43 @@
import {
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest, HttpResponse
} from "@angular/common/http";
import {
HttpSecurityErrorInterceptor,
MessagesService,
UserService
} from "@webbpm/base-package";
import {Injectable} from "@angular/core";
import {Router} from "@angular/router";
import {from, Observable} from "rxjs";
import {catchError, map} from "rxjs/operators";
import {AuthenticationService} from "../../security/authentication.service";
@Injectable()
export class ErvuHttpSecurityErrorInterceptor extends HttpSecurityErrorInterceptor
implements HttpInterceptor {
private authService: AuthenticationService;
constructor(router: Router, messagesService: MessagesService, userService: UserService,
authService: AuthenticationService) {
super(router, messagesService, userService);
this.authService = authService;
}
protected processAuthError(req: HttpRequest<any>, next: HttpHandler,
error: any): Observable<HttpEvent<any>> {
if (this.authService.isAuthenticated()) {
return super.processAuthError(req, next, error);
}
else {
return from(this.authService.redirectToEsia()).pipe(
map(() => new HttpResponse<any>()),
catchError((err) => {
throw err;
})
);
}
}
}

View file

@ -1,19 +1,20 @@
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from "@angular/common/http";
import {HttpSecurityErrorInterceptor, MessagesService, UserService} from "@webbpm/base-package";
import {MessagesService, UserService} from "@webbpm/base-package";
import {Injectable} from "@angular/core";
import {Router} from "@angular/router";
import {EMPTY, Observable} from "rxjs";
import {catchError} from "rxjs/operators";
import {ErvuHttpSecurityErrorInterceptor} from "./ervu-http-security-error-interceptor";
import {AuthenticationService} from "../../security/authentication.service";
@Injectable()
export class DevHttpSecurityErrorInterceptor extends HttpSecurityErrorInterceptor
export class DevHttpSecurityErrorInterceptor extends ErvuHttpSecurityErrorInterceptor
implements HttpInterceptor {
private router: Router;
constructor(router: Router, messagesService: MessagesService, userService: UserService) {
super(router, messagesService, userService);
this.router = router;
constructor(router: Router, messagesService: MessagesService, userService: UserService,
authService: AuthenticationService) {
super(router, messagesService, userService, authService);
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {