Compare commits
67 Commits
feat/recei
...
a59d4836d4
| Author | SHA1 | Date | |
|---|---|---|---|
| a59d4836d4 | |||
| f475cf4ea9 | |||
| d39018ca39 | |||
| b49482137f | |||
| bd40404d97 | |||
| 6f16921a79 | |||
| 1afc95f9c6 | |||
| 6aed820196 | |||
| e17c4d02f8 | |||
| 8187924a8c | |||
| 1bf530f7e7 | |||
| 9cadc8e901 | |||
| 1d4ad13532 | |||
| 03a8154b1c | |||
| 20b8acd3fc | |||
| a3afeb175f | |||
| 114555c843 | |||
| f294ef2fde | |||
| 02ad819da9 | |||
| 041d98ca78 | |||
| afea2fb5ea | |||
| beeb9e4e75 | |||
| 30d13b1ffb | |||
| 814df63306 | |||
| 830d1af44a | |||
| 94018d2a36 | |||
| cf5a724bf2 | |||
| 172f2e27d7 | |||
| d350e2ae48 | |||
| 2779452d72 | |||
| 5ebc6c6739 | |||
| 891593755e | |||
| b20260674e | |||
| 7e5ff6bcb2 | |||
| 6eed9b1e31 | |||
| d4b1a4921c | |||
| f078bafdde | |||
| 786a3e128d | |||
| ff3a146636 | |||
| 40b2cad598 | |||
| 5c675be0ed | |||
| 58164be640 | |||
| a639377195 | |||
| e3d6e87ee5 | |||
| 2795b91386 | |||
| ca248c3aa6 | |||
| 383634fca6 | |||
| 75097afa06 | |||
| 77975c0644 | |||
| 5707213edd | |||
| ad54ba9dc4 | |||
| 1f233153cf | |||
| 513ec007eb | |||
| 1305714da2 | |||
| 1e90cda393 | |||
| 5a5cbcb14d | |||
| a35f06070a | |||
| 2606066103 | |||
| 7495e062a9 | |||
| 293044bec3 | |||
| e0ff976d21 | |||
| bec45ab1f1 | |||
| fecd054a5c | |||
| 32b488c50f | |||
| 9cfdd16970 | |||
| 4da5848253 | |||
| 88da210ba2 |
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 264 KiB After Width: | Height: | Size: 264 KiB |
130
EnvelopeGenerator.API/Controllers/AnnotationController.cs
Normal file
130
EnvelopeGenerator.API/Controllers/AnnotationController.cs
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
|
using DigitalData.Core.Exceptions;
|
||||||
|
using EnvelopeGenerator.Application.Common.Extensions;
|
||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
|
using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
|
||||||
|
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||||
|
using EnvelopeGenerator.Application.Histories.Queries;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
using EnvelopeGenerator.GeneratorAPI.Extensions;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manages annotations and signature lifecycle for envelopes.
|
||||||
|
/// </summary>
|
||||||
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class AnnotationController : ControllerBase
|
||||||
|
{
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IEnvelopeHistoryService _historyService;
|
||||||
|
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
private readonly IEnvelopeReceiverService _envelopeReceiverService;
|
||||||
|
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
|
||||||
|
private readonly ILogger<AnnotationController> _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of <see cref="AnnotationController"/>.
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public AnnotationController(
|
||||||
|
ILogger<AnnotationController> logger,
|
||||||
|
IEnvelopeHistoryService envelopeHistoryService,
|
||||||
|
IEnvelopeReceiverService envelopeReceiverService,
|
||||||
|
IMediator mediator)
|
||||||
|
{
|
||||||
|
_historyService = envelopeHistoryService;
|
||||||
|
_envelopeReceiverService = envelopeReceiverService;
|
||||||
|
_mediator = mediator;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates or updates annotations for the authenticated envelope receiver.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="psPdfKitAnnotation">Annotation payload.</param>
|
||||||
|
/// <param name="cancel">Cancellation token.</param>
|
||||||
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
|
[HttpPost]
|
||||||
|
[Obsolete("This endpoint is for PSPDF Kit.")]
|
||||||
|
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation? psPdfKitAnnotation = null, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
var signature = User.GetAuthReceiverSignature();
|
||||||
|
var uuid = User.GetAuthEnvelopeUuid();
|
||||||
|
|
||||||
|
if (signature is null || uuid is null)
|
||||||
|
{
|
||||||
|
_logger.LogError("Authorization failed: authenticated user does not have a valid signature or envelope UUID.");
|
||||||
|
return Unauthorized("User authentication is incomplete. Missing required claims for processing this request.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var envelopeReceiver = await _mediator.ReadEnvelopeReceiverAsync(uuid, signature, cancel).ThrowIfNull(Exceptions.NotFound);
|
||||||
|
|
||||||
|
if (!envelopeReceiver.Envelope!.ReadOnly && psPdfKitAnnotation is null)
|
||||||
|
return BadRequest();
|
||||||
|
|
||||||
|
if (await _mediator.IsSignedAsync(uuid, signature, cancel))
|
||||||
|
return Problem(statusCode: StatusCodes.Status409Conflict);
|
||||||
|
else if (await _mediator.AnyHistoryAsync(uuid, new[] { EnvelopeStatus.EnvelopeRejected, EnvelopeStatus.DocumentRejected }, cancel))
|
||||||
|
return Problem(statusCode: StatusCodes.Status423Locked);
|
||||||
|
|
||||||
|
var docSignedNotification = await _mediator
|
||||||
|
.ReadEnvelopeReceiverAsync(uuid, signature, cancel)
|
||||||
|
.ToDocSignedNotification(psPdfKitAnnotation)
|
||||||
|
?? throw new NotFoundException("Envelope receiver is not found.");
|
||||||
|
|
||||||
|
await _mediator.PublishSafely(docSignedNotification, cancel);
|
||||||
|
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rejects the document for the current receiver.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reason">Optional rejection reason.</param>
|
||||||
|
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||||
|
[HttpPost("reject")]
|
||||||
|
[Obsolete("Use MediatR")]
|
||||||
|
public async Task<IActionResult> Reject([FromBody] string? reason = null)
|
||||||
|
{
|
||||||
|
var signature = User.GetAuthReceiverSignature();
|
||||||
|
var uuid = User.GetAuthEnvelopeUuid();
|
||||||
|
var mail = User.GetAuthReceiverMail();
|
||||||
|
if (uuid is null || signature is null || mail is null)
|
||||||
|
{
|
||||||
|
_logger.LogEnvelopeError(uuid: uuid, signature: signature,
|
||||||
|
message: @$"Unauthorized POST request in api\\envelope\\reject. One of claims, Envelope, signature or mail ({mail}) is null.");
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
var envRcvRes = await _envelopeReceiverService.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
|
||||||
|
|
||||||
|
if (envRcvRes.IsFailed)
|
||||||
|
{
|
||||||
|
_logger.LogNotice(envRcvRes.Notices);
|
||||||
|
return Unauthorized("you are not authorized");
|
||||||
|
}
|
||||||
|
|
||||||
|
var histRes = await _historyService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason);
|
||||||
|
if (histRes.IsSuccess)
|
||||||
|
{
|
||||||
|
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogEnvelopeError(uuid: uuid, signature: signature, message: "Unexpected error happened in api/envelope/reject");
|
||||||
|
_logger.LogNotice(histRes.Notices);
|
||||||
|
return StatusCode(500, histRes.Messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
EnvelopeGenerator.API/Controllers/ConfigController.cs
Normal file
29
EnvelopeGenerator.API/Controllers/ConfigController.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using EnvelopeGenerator.GeneratorAPI.Models.PsPdfKitAnnotation;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exposes configuration data required by the client applications.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Initializes a new instance of <see cref="ConfigController"/>.
|
||||||
|
/// </remarks>
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class ConfigController(IOptionsMonitor<AnnotationParams> annotationParamsOptions) : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly AnnotationParams _annotationParams = annotationParamsOptions.CurrentValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns annotation configuration that was previously rendered by MVC.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("Annotations")]
|
||||||
|
public IActionResult GetAnnotationParams()
|
||||||
|
{
|
||||||
|
return Ok(_annotationParams.AnnotationJSObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user