Add feature to open receiver envelope URLs

Introduce a new feature allowing users to open URLs for receiver envelopes directly from the sender page. This includes:

- Injecting `EnvelopeReceiverService` in `SenderPage.razor`.
- Adding a UI button to open receiver envelope URLs.
- Implementing `OpenReceiverEnvelopeUrlAsync` for URL handling.
- Extending `EnvelopeReceiverService` with methods for URL retrieval and feature check.
- Updating `EnvelopeReceiverController` with new endpoints for URL access.
- Introducing `SenderFeatureAccessOptions` for managing feature access.
- Configuring feature access in `Program.cs` and `appsettings.json`.
- Restricting feature usage to specified email addresses.
This commit is contained in:
2026-10-27 11:37:25 +01:00
parent 5df38754cb
commit 28d0b6f81c
6 changed files with 150 additions and 24 deletions

View File

@@ -15,6 +15,8 @@ using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
using EnvelopeGenerator.Server.Extensions;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands.CreateEnvelopeReceiver;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Server.Options;
namespace EnvelopeGenerator.Server.Controllers;
@@ -36,11 +38,12 @@ public class EnvelopeReceiverController : ControllerBase
private readonly IEnvelopeReceiverExecutor _erExecutor;
private readonly IDocumentExecutor _documentExecutor;
private readonly string _cnnStr;
private readonly IOptionsMonitor<SenderFeatureAccessOptions> _senderFeatureAccessOptions;
/// <summary>
/// Konstruktor für den EnvelopeReceiverController.
/// </summary>
public EnvelopeReceiverController(ILogger<EnvelopeReceiverController> logger, IMediator mediator, IMapper mapper, IEnvelopeExecutor envelopeExecutor, IEnvelopeReceiverExecutor erExecutor, IDocumentExecutor documentExecutor, IOptions<ConnectionString> csOpt)
public EnvelopeReceiverController(ILogger<EnvelopeReceiverController> logger, IMediator mediator, IMapper mapper, IEnvelopeExecutor envelopeExecutor, IEnvelopeReceiverExecutor erExecutor, IDocumentExecutor documentExecutor, IOptions<ConnectionString> csOpt, IOptionsMonitor<SenderFeatureAccessOptions> senderFeatureAccessOptions)
{
_logger = logger;
_mediator = mediator;
@@ -49,6 +52,7 @@ public class EnvelopeReceiverController : ControllerBase
_erExecutor = erExecutor;
_documentExecutor = documentExecutor;
_cnnStr = csOpt.Value.Value;
_senderFeatureAccessOptions = senderFeatureAccessOptions;
}
/// <summary>
@@ -112,6 +116,39 @@ public class EnvelopeReceiverController : ControllerBase
return name is null ? NotFound() : Ok(name);
}
[Authorize(AuthenticationSchemes = AuthScheme.Sender)]
[HttpGet("receiver-envelope-url")]
public IActionResult GetReceiverEnvelopeUrl([FromQuery] string envelopeUuid, [FromQuery] string receiverSignature)
{
if (!CanUseReceiverEnvelopeUrlFeature())
return Forbid();
if (string.IsNullOrWhiteSpace(envelopeUuid) || string.IsNullOrWhiteSpace(receiverSignature))
return BadRequest("Envelope uuid and receiver signature are required.");
var envelopeKey = (envelopeUuid, receiverSignature).ToEnvelopeKey();
var absoluteUrl = $"{Request.Scheme}://{Request.Host}/envelope/{Uri.EscapeDataString(envelopeKey)}";
return Ok(new { url = absoluteUrl });
}
[Authorize(AuthenticationSchemes = AuthScheme.Sender)]
[HttpGet("receiver-envelope-url/enabled")]
public IActionResult GetReceiverEnvelopeUrlFeatureEnabled()
{
return Ok(new { enabled = CanUseReceiverEnvelopeUrlFeature() });
}
private bool CanUseReceiverEnvelopeUrlFeature()
{
var senderEmail = User.GetEmail();
if (string.IsNullOrWhiteSpace(senderEmail))
return false;
var allowedEmails = _senderFeatureAccessOptions.CurrentValue.AllowedReceiverEnvelopeUrlEmails;
return allowedEmails.Any(email => string.Equals(email?.Trim(), senderEmail, StringComparison.OrdinalIgnoreCase));
}
/// <summary>
/// Returns recent receiver suggestions for the authenticated sender.
/// </summary>

View File

@@ -0,0 +1,8 @@
namespace EnvelopeGenerator.Server.Options;
public sealed class SenderFeatureAccessOptions
{
public const string SectionName = "SenderFeatureAccess";
public List<string> AllowedReceiverEnvelopeUrlEmails { get; set; } = [];
}

View File

@@ -298,6 +298,7 @@ try
// Cache options
builder.Services.Configure<CacheOptions>(config.GetSection(CacheOptions.SectionName));
builder.Services.Configure<SenderFeatureAccessOptions>(config.GetSection(SenderFeatureAccessOptions.SectionName));
// Distributed Cache - SQL Server
builder.Services.AddDistributedSqlServerCache(options =>

View File

@@ -212,6 +212,9 @@
"TableName": "TBDD_CACHE"
}
},
"SenderFeatureAccess": {
"AllowedReceiverEnvelopeUrlEmails": ["h.tek@digitaldata.works"]
},
"MainPageTitle": null,
"AnnotationParams": {
"Background": {