diff --git a/Domain/Sia.Shared/Authentication/AAD/AzureActiveDirectoryAuthenticationInfo.cs b/Domain/Sia.Shared/Authentication/AAD/AzureActiveDirectoryAuthenticationInfo.cs index 7e5b4d0..496ab15 100644 --- a/Domain/Sia.Shared/Authentication/AAD/AzureActiveDirectoryAuthenticationInfo.cs +++ b/Domain/Sia.Shared/Authentication/AAD/AzureActiveDirectoryAuthenticationInfo.cs @@ -1,6 +1,6 @@ using System; -namespace Sia.Gateway.Authentication +namespace Sia.Shared.Authentication { public class AzureActiveDirectoryAuthenticationInfo { diff --git a/Domain/Sia.Shared/Authentication/AAD/NaiveSessionCache.cs b/Domain/Sia.Shared/Authentication/AAD/NaiveSessionCache.cs index ca3ef62..ab5ee66 100644 --- a/Domain/Sia.Shared/Authentication/AAD/NaiveSessionCache.cs +++ b/Domain/Sia.Shared/Authentication/AAD/NaiveSessionCache.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Clients.ActiveDirectory; -namespace Sia.Gateway.Authentication +namespace Sia.Shared.Authentication { /// /// From https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect-aspnetcore/blob/master/WebApp-WebAPI-OpenIdConnect-DotNet/Utils/NaiveSessionCache.cs diff --git a/Domain/Sia.Shared/Authentication/Http/HttpClientExtensions.cs b/Domain/Sia.Shared/Authentication/Http/HttpClientExtensions.cs index f3cffa9..f3d858d 100644 --- a/Domain/Sia.Shared/Authentication/Http/HttpClientExtensions.cs +++ b/Domain/Sia.Shared/Authentication/Http/HttpClientExtensions.cs @@ -1,5 +1,5 @@ using Microsoft.IdentityModel.Clients.ActiveDirectory; -using Sia.Gateway.Authentication; +using Sia.Shared.Authentication; using System.Net.Http.Headers; using System.Threading.Tasks; diff --git a/Domain/Sia.Shared/Authentication/Identity/AuthenticatedUserContext.cs b/Domain/Sia.Shared/Authentication/Identity/AuthenticatedUserContext.cs index 61aabd9..a1c79c3 100644 --- a/Domain/Sia.Shared/Authentication/Identity/AuthenticatedUserContext.cs +++ b/Domain/Sia.Shared/Authentication/Identity/AuthenticatedUserContext.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Http; using System.Security.Claims; -namespace Sia.Gateway.Authentication +namespace Sia.Shared.Authentication { public class AuthenticatedUserContext { diff --git a/Domain/Sia.Shared/Extensions/Mediatr/AuthenticatedRequest.cs b/Domain/Sia.Shared/Extensions/Mediatr/AuthenticatedRequest.cs index 6ba76a2..1168ab8 100644 --- a/Domain/Sia.Shared/Extensions/Mediatr/AuthenticatedRequest.cs +++ b/Domain/Sia.Shared/Extensions/Mediatr/AuthenticatedRequest.cs @@ -1,8 +1,19 @@ -using Sia.Gateway.Authentication; +using MediatR; +using Sia.Shared.Authentication; -namespace Sia.Gateway.Requests +namespace Sia.Shared.Requests { - public abstract class AuthenticatedRequest + public abstract class AuthenticatedRequest : IRequest + { + protected AuthenticatedRequest(AuthenticatedUserContext userContext) + { + UserContext = userContext; + } + + public AuthenticatedUserContext UserContext { get; private set; } + } + + public abstract class AuthenticatedRequest : IRequest { protected AuthenticatedRequest(AuthenticatedUserContext userContext) { diff --git a/Domain/Sia.Shared/Extensions/Mediatr/DatabaseOperationHandler.cs b/Domain/Sia.Shared/Extensions/Mediatr/DatabaseOperationHandler.cs new file mode 100644 index 0000000..b0ba961 --- /dev/null +++ b/Domain/Sia.Shared/Extensions/Mediatr/DatabaseOperationHandler.cs @@ -0,0 +1,34 @@ +using MediatR; +using Microsoft.EntityFrameworkCore; +using System.Threading.Tasks; + +namespace Sia.Playbook.Requests +{ + public abstract class DatabaseOperationHandler : IAsyncRequestHandler + where TRequest : IRequest + where TContext : DbContext + { + protected readonly TContext _context; + + protected DatabaseOperationHandler(TContext context) + { + _context = context; + } + + public abstract Task Handle(TRequest message); + } + + public abstract class DatabaseOperationHandler : IAsyncRequestHandler + where TRequest : IRequest + where TContext : DbContext + { + protected readonly TContext _context; + + protected DatabaseOperationHandler(TContext context) + { + _context = context; + } + + public abstract Task Handle(TRequest message); + } +} diff --git a/Domain/Sia.Shared/MVC/BaseController.cs b/Domain/Sia.Shared/MVC/BaseController.cs index 8de3736..a3a589d 100644 --- a/Domain/Sia.Shared/MVC/BaseController.cs +++ b/Domain/Sia.Shared/MVC/BaseController.cs @@ -1,10 +1,10 @@ using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Sia.Gateway.Authentication; +using Sia.Shared.Authentication; using Sia.Shared.Validation.Filters; -namespace Sia.Gateway.Controllers +namespace Sia.Shared.Controllers { [Return400BadRequestWhenModelStateInvalid] [Authorize()] diff --git a/Domain/Sia.Shared/MVC/Middleware/ExceptionHandler.cs b/Domain/Sia.Shared/MVC/Middleware/ExceptionHandler.cs index 7017fe0..7f9343c 100644 --- a/Domain/Sia.Shared/MVC/Middleware/ExceptionHandler.cs +++ b/Domain/Sia.Shared/MVC/Middleware/ExceptionHandler.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using Sia.Shared.Exceptions; using System.Threading.Tasks; -namespace Sia.Gateway.Middleware +namespace Sia.Shared.Middleware { public class ExceptionHandler {