-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11cb8e7
commit 5435591
Showing
51 changed files
with
4,209 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nuar.Configuration | ||
{ | ||
public class Auth | ||
{ | ||
public bool Enabled { get; set; } | ||
public bool Global { get; set; } | ||
public IDictionary<string, Policy> Policies { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nuar.Configuration | ||
{ | ||
public class Http | ||
{ | ||
public int Retries { get; set; } | ||
public bool Exponential { get; set; } | ||
public double Interval { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nuar.Configuration | ||
{ | ||
public class LoadBalancer | ||
{ | ||
public bool Enabled { get; set; } | ||
public string Url { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class Module | ||
{ | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public string Version { get; set; } | ||
public bool? Enabled { get; set; } | ||
public IEnumerable<Route> Routes { get; set; } | ||
public IDictionary<string, Service> Services { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class OnError | ||
{ | ||
public int Code { get; set; } = 200; | ||
public object Data { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class OnSuccess | ||
{ | ||
public int Code { get; set; } = 200; | ||
public object Data { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class Policy | ||
{ | ||
public IDictionary<string, string> Claims { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class ResourceId | ||
{ | ||
public bool Generate { get; set; } | ||
public string Property { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class Route | ||
{ | ||
public ResourceId ResourceId { get; set; } | ||
public string Upstream { get; set; } | ||
public string Method { get; set; } | ||
public IEnumerable<string> Methods { get; set; } | ||
public bool MatchAll { get; set; } | ||
public string Use { get; set; } | ||
public string Downstream { get; set; } | ||
public string DownstreamMethod { get; set; } | ||
public bool? PassQueryString { get; set; } | ||
public string ReturnValue { get; set; } | ||
public string Payload { get; set; } | ||
public string Schema { get; set; } | ||
public bool? Auth { get; set; } | ||
public IDictionary<string, string> RequestHeaders { get; set; } | ||
public IDictionary<string, string> ResponseHeaders { get; set; } | ||
public bool? ForwardRequestHeaders { get; set; } | ||
public bool? ForwardResponseHeaders { get; set; } | ||
public bool? ForwardStatusCode { get; set; } | ||
public bool? GenerateRequestId { get; set; } | ||
public bool? GenerateTraceId { get; set; } | ||
public OnError OnError { get; set; } | ||
public OnSuccess OnSuccess { get; set; } | ||
public IDictionary<string, string> Claims { get; set; } | ||
public IEnumerable<string> Policies { get; set; } | ||
public IEnumerable<string> Bind { get; set; } | ||
public IEnumerable<string> Transform { get; set; } | ||
public IDictionary<string, string> Config { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nuar.Configuration | ||
{ | ||
public class Service | ||
{ | ||
public string LocalUrl { get; set; } | ||
public string Url { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Nuar | ||
{ | ||
public class Error | ||
{ | ||
public string Code { get; set; } | ||
public string Property { get; set; } | ||
public string Message { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using System.Dynamic; | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using Route = Nuar.Configuration.Route; | ||
|
||
namespace Nuar | ||
{ | ||
public class ExecutionData | ||
{ | ||
public string RequestId { get; set; } | ||
public string ResourceId { get; set; } | ||
public string TraceId { get; set; } | ||
public string UserId { get; set; } | ||
public string ContentType { get; set; } | ||
public string Downstream { get; set; } | ||
public bool HasPayload { get; set; } | ||
public IDictionary<string, string> Claims { get; set; } | ||
public Route Route { get; set; } | ||
public HttpContext Context { get; set; } | ||
public RouteData Data { get; set; } | ||
public ExpandoObject Payload { get; set; } | ||
public IEnumerable<Error> ValidationErrors { get; set; } = Enumerable.Empty<Error>(); | ||
public bool IsPayloadValid => ValidationErrors is null || !ValidationErrors.Any(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IAuthenticationManager | ||
{ | ||
Task<bool> TryAuthenticateAsync(HttpRequest request, RouteConfig routeConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Security.Claims; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IAuthorizationManager | ||
{ | ||
bool IsAuthorized(ClaimsPrincipal user, RouteConfig routeConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
|
||
namespace Nuar | ||
{ | ||
internal interface IDownstreamBuilder | ||
{ | ||
string GetDownstream(RouteConfig routeConfig, HttpRequest request, RouteData data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nuar | ||
{ | ||
public interface IEnabledExtension | ||
{ | ||
IExtension Extension { get; } | ||
IExtensionOptions Options { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IExtension | ||
{ | ||
string Name { get; } | ||
string Description { get; } | ||
string Version { get; } | ||
void Add(IServiceCollection services, IOptionsProvider optionsProvider); | ||
void Use(IApplicationBuilder app, IOptionsProvider optionsProvider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IExtensionOptions | ||
{ | ||
int? Order { get; set; } | ||
bool? Enabled { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Nuar | ||
{ | ||
internal interface IExtensionProvider | ||
{ | ||
IEnumerable<IEnabledExtension> GetAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using NuarRoute = Nuar.Configuration.Route; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IHandler | ||
{ | ||
string GetInfo(NuarRoute route); | ||
Task HandleAsync(HttpContext context, RouteConfig config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Nuar | ||
{ | ||
public interface IOptions | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nuar | ||
{ | ||
public interface IOptionsProvider | ||
{ | ||
T Get<T>(string name = null) where T : class, IOptions, new(); | ||
T GetForExtension<T>(string name) where T : class, IOptions, new(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IPayloadBuilder | ||
{ | ||
Task<string> BuildRawAsync(HttpRequest request); | ||
Task<T> BuildJsonAsync<T>(HttpRequest request) where T : class, new(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nuar | ||
{ | ||
internal interface IPayloadManager | ||
{ | ||
string GetKey(string method, string upstream); | ||
IDictionary<string, PayloadSchema> Payloads { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using NuarRoute = Nuar.Configuration.Route; | ||
|
||
namespace Nuar | ||
{ | ||
internal interface IPayloadTransformer | ||
{ | ||
bool HasTransformations(string resourceId, NuarRoute route); | ||
PayloadSchema Transform(string payload, string resourceId, NuarRoute route, HttpRequest request, RouteData data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Nuar | ||
{ | ||
public interface IPayloadValidator | ||
{ | ||
Task<bool> TryValidate(ExecutionData executionData, HttpResponse httpResponce); | ||
Task<IEnumerable<Error>> GetValidationErrorsAsync(PayloadSchema payloadSchema); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nuar | ||
{ | ||
internal interface IPolicyManager | ||
{ | ||
IDictionary<string, string> GetClaims(string policy); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Nuar | ||
{ | ||
internal interface IRequestExecutionValidator | ||
{ | ||
Task<bool> TryExecuteAsync(HttpContext httpContext, RouteConfig routeConfig); | ||
} | ||
} |
Oops, something went wrong.