diff --git a/EnvelopeGenerator.Application/Common/Interfaces/IRequestContext.cs b/EnvelopeGenerator.Application/Common/Interfaces/IRequestContext.cs new file mode 100644 index 00000000..e95559b6 --- /dev/null +++ b/EnvelopeGenerator.Application/Common/Interfaces/IRequestContext.cs @@ -0,0 +1,12 @@ +namespace EnvelopeGenerator.Application.Common.Interfaces; + +/// +/// +/// +public interface IRequestContext +{ + /// + /// + /// + string? Origin { get; } +} \ No newline at end of file diff --git a/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Program.cs b/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Program.cs index 577136b1..3698a76b 100644 --- a/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Program.cs +++ b/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Program.cs @@ -8,6 +8,7 @@ using DigitalData.Core.Application; using DigitalData.EmailProfilerDispatcher; using DigitalData.UserManager.DependencyInjection; using EnvelopeGenerator.Application; +using EnvelopeGenerator.Application.Common.Interfaces; using EnvelopeGenerator.Application.Common.Interfaces.Doc; using EnvelopeGenerator.Domain.Constants; using EnvelopeGenerator.Infrastructure; @@ -19,6 +20,7 @@ using EnvelopeGenerator.Server.Client.Services; using EnvelopeGenerator.Server.Components; using EnvelopeGenerator.Server.Models; using EnvelopeGenerator.Server.Options; +using EnvelopeGenerator.Server.Services; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Localization; @@ -392,6 +394,8 @@ try builder.Services.Configure( builder.Configuration.GetSection("PdfViewerOptions")); + builder.Services.AddScoped(); + var app = builder.Build(); deferredProvider.Factory = () => app.Services; diff --git a/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Services/RequestContext.cs b/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Services/RequestContext.cs new file mode 100644 index 00000000..b679db80 --- /dev/null +++ b/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Services/RequestContext.cs @@ -0,0 +1,18 @@ +using EnvelopeGenerator.Application.Common.Interfaces; + +namespace EnvelopeGenerator.Server.Services; + +/// +/// +/// +/// +public sealed class RequestContext( + IHttpContextAccessor HttpContextAccessor) : IRequestContext +{ + /// + /// + /// + public string? Origin => + HttpContextAccessor.HttpContext? + .Request.Headers.Origin.ToString(); +}