зеркало из https://github.com/Azure/Sia-Root.git
Changed namespaces in Sia.Shared to remove Gateway references. Changed
shared handlers to reduce duplication of boilerplate.
This commit is contained in:
Родитель
9069f320e2
Коммит
2a8dfd5bf2
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace Sia.Gateway.Authentication
|
||||
namespace Sia.Shared.Authentication
|
||||
{
|
||||
public class AzureActiveDirectoryAuthenticationInfo
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.IdentityModel.Clients.ActiveDirectory;
|
||||
|
||||
namespace Sia.Gateway.Authentication
|
||||
namespace Sia.Shared.Authentication
|
||||
{
|
||||
/// <summary>
|
||||
/// From https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect-aspnetcore/blob/master/WebApp-WebAPI-OpenIdConnect-DotNet/Utils/NaiveSessionCache.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;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Sia.Gateway.Authentication
|
||||
namespace Sia.Shared.Authentication
|
||||
{
|
||||
public class AuthenticatedUserContext
|
||||
{
|
||||
|
|
|
@ -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<T> : IRequest<T>
|
||||
{
|
||||
protected AuthenticatedRequest(AuthenticatedUserContext userContext)
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
|
||||
public AuthenticatedUserContext UserContext { get; private set; }
|
||||
}
|
||||
|
||||
public abstract class AuthenticatedRequest : IRequest
|
||||
{
|
||||
protected AuthenticatedRequest(AuthenticatedUserContext userContext)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sia.Playbook.Requests
|
||||
{
|
||||
public abstract class DatabaseOperationHandler<TContext, TRequest, TResult> : IAsyncRequestHandler<TRequest, TResult>
|
||||
where TRequest : IRequest<TResult>
|
||||
where TContext : DbContext
|
||||
{
|
||||
protected readonly TContext _context;
|
||||
|
||||
protected DatabaseOperationHandler(TContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public abstract Task<TResult> Handle(TRequest message);
|
||||
}
|
||||
|
||||
public abstract class DatabaseOperationHandler<TContext, TRequest> : IAsyncRequestHandler<TRequest>
|
||||
where TRequest : IRequest
|
||||
where TContext : DbContext
|
||||
{
|
||||
protected readonly TContext _context;
|
||||
|
||||
protected DatabaseOperationHandler(TContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public abstract Task Handle(TRequest message);
|
||||
}
|
||||
}
|
|
@ -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()]
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче