diff --git a/backend/src/main/java/ru/micord/ervu/controller/ErvuDataController.java b/backend/src/main/java/ru/micord/ervu/controller/ErvuDataController.java index 4881cc0..d45293c 100644 --- a/backend/src/main/java/ru/micord/ervu/controller/ErvuDataController.java +++ b/backend/src/main/java/ru/micord/ervu/controller/ErvuDataController.java @@ -4,15 +4,15 @@ import com.google.protobuf.InvalidProtocolBufferException; import org.apache.kafka.common.utils.Bytes; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; import ru.micord.ervu.converter.SummonsResponseDataConverter; import ru.micord.ervu.dto.SubpoenaRequestDto; import ru.micord.ervu.dto.SubpoenaResponseDto; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import proto.ervu.rp.summons.SummonsResponseData; import ru.micord.ervu.kafka.service.ReplyingKafkaService; -import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService; +import ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil; /** * @author gulnaz @@ -20,7 +20,6 @@ import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService; @RestController public class ErvuDataController { - private final JwtTokenService jwtTokenService; private final ReplyingKafkaService replyingKafkaService; private final SummonsResponseDataConverter converter; @@ -30,20 +29,23 @@ public class ErvuDataController { private String recruitReplyTopic; public ErvuDataController( - JwtTokenService jwtTokenService, @Qualifier("recruit") ReplyingKafkaService replyingKafkaService, SummonsResponseDataConverter converter) { - this.jwtTokenService = jwtTokenService; this.replyingKafkaService = replyingKafkaService; this.converter = converter; } - @PostMapping( - value = "/get-data", + @GetMapping( + value = "/recruit", produces = MediaType.APPLICATION_JSON_VALUE ) public SubpoenaResponseDto getData() { - SubpoenaRequestDto subpoenaRequestDto = new SubpoenaRequestDto(jwtTokenService.getErvuId()); + String ervuId = SecurityUtil.getErvuId(); + + if (ervuId == null) { + return new SubpoenaResponseDto.Builder().build(); + } + SubpoenaRequestDto subpoenaRequestDto = new SubpoenaRequestDto(ervuId); byte[] reply = replyingKafkaService.sendMessageAndGetReply(recruitRequestTopic, recruitReplyTopic, subpoenaRequestDto).get(); diff --git a/backend/src/main/java/ru/micord/ervu/controller/ExtractController.java b/backend/src/main/java/ru/micord/ervu/controller/ExtractController.java index 1f14e44..f749eb6 100644 --- a/backend/src/main/java/ru/micord/ervu/controller/ExtractController.java +++ b/backend/src/main/java/ru/micord/ervu/controller/ExtractController.java @@ -18,7 +18,7 @@ import rtl.pgs.ervu.proto.ExtractRegistry; import rtl.pgs.ervu.proto.ResponseData; import ru.micord.ervu.dto.ExtractRequestDto; import ru.micord.ervu.kafka.service.ReplyingKafkaService; -import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService; +import ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil; /** * @author gulnaz @@ -26,7 +26,6 @@ import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService; @RestController public class ExtractController { - private final JwtTokenService jwtTokenService; private final ReplyingKafkaService replyingKafkaService; @Value("${ervu.kafka.registry.extract.request.topic}") @@ -34,15 +33,18 @@ public class ExtractController { @Value("${ervu.kafka.registry.extract.reply.topic}") private String registryExtractReplyTopic; - public ExtractController(JwtTokenService jwtTokenService, - ReplyingKafkaService replyingKafkaService) { - this.jwtTokenService = jwtTokenService; + public ExtractController(ReplyingKafkaService replyingKafkaService) { this.replyingKafkaService = replyingKafkaService; } @GetMapping(value = "/extract/{formatRegistry}") public ResponseEntity getExtract(@PathVariable String formatRegistry) { - ExtractRequestDto request = new ExtractRequestDto(jwtTokenService.getErvuId(), formatRegistry); + String ervuId = SecurityUtil.getErvuId(); + + if (ervuId == null) { + return ResponseEntity.noContent().build(); + } + ExtractRequestDto request = new ExtractRequestDto(ervuId, formatRegistry); byte[] reply = replyingKafkaService.sendMessageAndGetReply(registryExtractRequestTopic, registryExtractReplyTopic, request).get(); diff --git a/backend/src/main/java/ru/micord/ervu/security/esia/service/EsiaAuthService.java b/backend/src/main/java/ru/micord/ervu/security/esia/service/EsiaAuthService.java index 302eef4..be5878e 100644 --- a/backend/src/main/java/ru/micord/ervu/security/esia/service/EsiaAuthService.java +++ b/backend/src/main/java/ru/micord/ervu/security/esia/service/EsiaAuthService.java @@ -11,7 +11,6 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.Base64; import java.util.LinkedHashMap; import java.util.Map; import java.util.UUID; @@ -26,6 +25,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.context.SecurityContext; import ru.micord.ervu.kafka.model.Document; +import ru.micord.ervu.kafka.model.ErrorData; import ru.micord.ervu.kafka.model.Person; import ru.micord.ervu.kafka.model.Response; import ru.micord.ervu.kafka.service.ReplyingKafkaService; @@ -50,6 +50,7 @@ import ru.micord.ervu.security.webbpm.jwt.model.Token; */ @Service public class EsiaAuthService { + @Autowired private ObjectMapper objectMapper; @@ -220,12 +221,6 @@ public class EsiaAuthService { SecurityContextHolder.setContext(context); Cookie authMarkerCookie = securityHelper.createAuthMarkerCookie("true", expiry); response.addCookie(authMarkerCookie); - if (ervuIdResponse.getErrorData() != null) { - return new ResponseEntity<>( - "Доступ запрещен. " + ervuIdResponse.getErrorData().getName(), - HttpStatus.FORBIDDEN - ); - } return ResponseEntity.ok("Authentication successful"); } catch (Exception e) { diff --git a/backend/src/main/java/ru/micord/ervu/security/webbpm/jwt/util/SecurityUtil.java b/backend/src/main/java/ru/micord/ervu/security/webbpm/jwt/util/SecurityUtil.java index 730cca9..69019f1 100644 --- a/backend/src/main/java/ru/micord/ervu/security/webbpm/jwt/util/SecurityUtil.java +++ b/backend/src/main/java/ru/micord/ervu/security/webbpm/jwt/util/SecurityUtil.java @@ -2,12 +2,15 @@ package ru.micord.ervu.security.webbpm.jwt.util; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Optional; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.util.WebUtils; +import ru.micord.ervu.security.webbpm.jwt.JwtAuthentication; import static org.springframework.web.context.request.RequestAttributes.REFERENCE_REQUEST; @@ -42,4 +45,14 @@ public final class SecurityUtil { Cookie cookie = WebUtils.getCookie(httpRequest, AUTH_TOKEN); return cookie != null ? cookie.getValue() : null; } + + public static String getErvuId() { + return Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication()) + .map(a -> ((JwtAuthentication) a).getUserAccountId()) + .map(userAccountId -> { + String ervuId = userAccountId.split(":")[1]; + return "null".equals(ervuId) ? null : ervuId; + }) + .orElse(null); + } } diff --git a/frontend/src/ts/modules/app/service/ervu-data.service.ts b/frontend/src/ts/modules/app/service/ervu-data.service.ts index 810d4be..f0c210f 100644 --- a/frontend/src/ts/modules/app/service/ervu-data.service.ts +++ b/frontend/src/ts/modules/app/service/ervu-data.service.ts @@ -11,8 +11,7 @@ export class ErvuDataService { } public getData(): any { - this.httpClient - .post("get-data", null, + this.httpClient.get("recruit", { headers: { "Content-type": "application/json" diff --git a/resources/src/main/resources/business-model/LK RP FL/screen-form-fl.page b/resources/src/main/resources/business-model/LK RP FL/screen-form-fl.page index d0c901d..284a0cb 100644 --- a/resources/src/main/resources/business-model/LK RP FL/screen-form-fl.page +++ b/resources/src/main/resources/business-model/LK RP FL/screen-form-fl.page @@ -233,7 +233,6 @@ 74ed6920-6d22-4349-a08e-a28ccc88f7df LoadForm - hidden true - false false @@ -430,6 +429,58 @@ "firstRestrictionName" + + + + + + ba24d307-0b91-4299-ba82-9d0b52384ff2 + 8ef93ac5-46d8-456e-950f-2d2949d21a53 + personName + false + false + + + + collectible + + false + + + + visible + + false + + + + + + + + + false + + + +PersonData +esia + + true + + + +SubpoenaFieldLoadComponent +ru.micord.ervu.component.field + + true + true + + + fieldId + + "personName" + @@ -754,6 +805,7 @@ 54755bcb-801b-450d-aa2e-046e2a405538 VB - 1.1.1.1 (на ? дату нет сформированных повесток) сценарий true + false false @@ -1801,7 +1853,7 @@ formatRegistry - "1" + "2" @@ -1956,6 +2008,7 @@ 26f019a0-e782-4632-a5f7-e69e7232542f HB заголовок - 1.1.2.1 true + false false @@ -2890,7 +2943,6 @@ 6c08c71d-52eb-4a94-b4e1-475c315f253f LoadForm true - false false @@ -4938,7 +4990,7 @@ formatRegistry - "2" + "1" @@ -5999,6 +6051,7 @@ dbe60a18-ce7a-4423-9e5e-816edb7b0b4f VB - 1.2 true + false false @@ -6973,6 +7026,312 @@ + + + + + + + + + 98594cec-0a9b-4cef-af09-e1b71cb2ad9e + 315c5087-825a-4ade-99d9-7dbe09f87226 + AC - для ненайденного пользователя в ерву + false + false + + + + elseActions + + + + + + eventRefs + + + + + + behavior + + {"objectId":"8ef93ac5-46d8-456e-950f-2d2949d21a53","packageName":"component","className":"Text","type":"TS"} + + + + propertyName + + "valueChangeEvent" + + + + + + + + + ifCondition + + + + conditions + + + + + + _isGroupSelected + + false + + + + one + + + + conditionFirstPart + + + + objectValue + + + + behavior + +{"objectId":"8ef93ac5-46d8-456e-950f-2d2949d21a53","packageName":"component","className":"Text","type":"TS"} + + + + method + +"getValue" + + + + + + + + + + conditionSecondPart + + + + staticValue + + + string + + + "null" + + + + + + + operation + + "IS_EMPTY" + + + + + + + + + + + + logicalOperation + + null + + + + + + + thenActions + + + + + + behavior + + {"objectId":"cfb60860-1b04-4eb5-9ccf-1e6436c27b09","packageName":"component.button","className":"Button","type":"TS"} + + + + method + + "setVisible" + + + + value + + + + staticValue + + +boolean + + + false + + + + + + + + + + + + + behavior + + {"objectId":"dd701bad-b22d-40c9-b00b-b92f070890db","packageName":"ervu.component.textwithdialoglinks","className":"TextWithDialogLinks","type":"TS"} + + + + method + + "setVisible" + + + + value + + + + staticValue + + +boolean + + + false + + + + + + + + + + + + + behavior + + {"objectId":"d68b5c38-9ed6-4596-9b0c-dd1dc542c5ef","packageName":"component.button","className":"Button","type":"TS"} + + + + method + + "setVisible" + + + + value + + + + staticValue + + +boolean + + + false + + + + + + + + + + + + + behavior + + {"objectId":"fea5aebc-c206-48bc-a613-ab31813fd639","packageName":"component.container","className":"HBox","type":"TS"} + + + + method + + "setVisible" + + + + value + + + + staticValue + + +boolean + + + false + + + + + + + + + + + + + behavior + + {"objectId":"d5fa2655-8dd8-4004-9dec-217a41e5b9ed","packageName":"component","className":"Text","type":"TS"} + + + + method + + "setVisible" + + + + value + + + + staticValue + + +boolean + + + false + + + + + + @@ -6993,6 +7352,7 @@ f88a6360-1760-436e-9459-6af705752f54 Диалоговые окна (информационные) true + false false