Compare commits
27 Commits
eceaf066d7
...
feat/user-
| Author | SHA1 | Date | |
|---|---|---|---|
| f60bb79920 | |||
| d113d4fcdd | |||
| 59963d7d4c | |||
| 5843e9efa8 | |||
| 5c4dec8e7c | |||
| 90a0751d09 | |||
| d2793f476a | |||
| a6140cab92 | |||
|
|
6ade388cd7 | ||
|
|
23e73aae19 | ||
|
|
23d73e0671 | ||
|
|
72b1c58b72 | ||
|
|
4173c3d96a | ||
|
|
97a20fdb8f | ||
|
|
4da1bc7617 | ||
|
|
78a58568fc | ||
|
|
9844cd16e8 | ||
|
|
896eee35bd | ||
|
|
8a8f77c4d5 | ||
|
|
08e3cdddb0 | ||
|
|
e1bd477753 | ||
|
|
174338af5d | ||
|
|
e3be4f5e6f | ||
|
|
cbd3accf72 | ||
|
|
d108978b63 | ||
|
|
6a536e950d | ||
|
|
0efb035d12 |
@@ -1,16 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.1.0</Version>
|
||||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
<AssemblyVersion>1.1.0</AssemblyVersion>
|
||||||
<FileVersion>1.0.0</FileVersion>
|
<FileVersion>1.1.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Ocelot" Version="22.0.1" />
|
<PackageReference Include="NLog" Version="5.4.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.4.0" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.4.0" />
|
||||||
|
<PackageReference Include="Ocelot" Version="23.4.3" />
|
||||||
|
<PackageReference Include="Ocelot.Cache.CacheManager" Version="23.4.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
61
Program.cs
61
Program.cs
@@ -1,26 +1,49 @@
|
|||||||
|
using NLog;
|
||||||
|
using NLog.Web;
|
||||||
using Ocelot.DependencyInjection;
|
using Ocelot.DependencyInjection;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
using Ocelot.Cache.CacheManager;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
|
logger.Info("Logging initialized.");
|
||||||
|
|
||||||
// Make sure to add the Ocelot configuration file
|
try
|
||||||
builder.Configuration.AddJsonFile("ocelot.json");
|
|
||||||
|
|
||||||
// Add Ocelot services
|
|
||||||
builder.Services.AddOcelot();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseRouting();
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
// Use Ocelot middleware in an appropriate way
|
|
||||||
app.UseEndpoints(endpoints =>
|
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
});
|
|
||||||
|
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||||
|
|
||||||
app.UseOcelot().Wait();
|
if (!builder.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
builder.Logging.ClearProviders();
|
||||||
|
builder.Host.UseNLog();
|
||||||
|
}
|
||||||
|
|
||||||
app.Run();
|
// Make sure to add the Ocelot configuration file
|
||||||
|
var suffix = builder.Environment.IsDevelopment() ? ".Development" : "";
|
||||||
|
builder.Configuration.AddJsonFile($"ocelot{suffix}.json");
|
||||||
|
|
||||||
|
// Add Ocelot services
|
||||||
|
builder.Services
|
||||||
|
.AddOcelot()
|
||||||
|
.AddCacheManager(x => x.WithDictionaryHandle());
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
// Use Ocelot middleware in an appropriate way
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.UseOcelot().Wait();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex, "Stopped program because of exception.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger/index.html",
|
||||||
"applicationUrl": "https://localhost:7052;http://localhost:5028",
|
"applicationUrl": "https://localhost:7052;http://localhost:5028",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
|||||||
@@ -5,5 +5,48 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"NLog": {
|
||||||
|
"throwConfigExceptions": true,
|
||||||
|
"variables": {
|
||||||
|
"logDirectory": "E:\\LogFiles\\Digital Data\\UserManager.Gateway",
|
||||||
|
"logFileNamePrefix": "${shortdate}-UserManager.Gateway"
|
||||||
|
},
|
||||||
|
"targets": {
|
||||||
|
"infoLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"errorLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"criticalLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Trace, Debug, Info, Warn, Error and *Fatal*
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"minLevel": "Info",
|
||||||
|
"maxLevel": "Warn",
|
||||||
|
"writeTo": "infoLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Error",
|
||||||
|
"writeTo": "errorLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Fatal",
|
||||||
|
"writeTo": "criticalLogs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
172
ocelot.Development.json
Normal file
172
ocelot.Development.json
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
{
|
||||||
|
"Routes": [
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/swagger/auth/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "172.24.12.39",
|
||||||
|
"Port": 9090
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/swagger/auth/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/user-manager?cookie=true",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "172.24.12.39",
|
||||||
|
"Port": 9090
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/login",
|
||||||
|
"UpstreamhttpsMethod": [ "Post" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/check",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/check",
|
||||||
|
"UpstreamhttpsMethod": [ "Get" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/logout",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/logout",
|
||||||
|
"UpstreamhttpsMethod": [ "Post" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route1}/{route2}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route1}/{route2}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route1}/{route2}/{route3}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route1}/{route2}/{route3}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 4200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 4200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/{route1}/{route2}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 4200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/{route1}/{route2}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"GlobalConfiguration": {
|
||||||
|
}
|
||||||
|
}
|
||||||
161
ocelot.json
161
ocelot.json
@@ -1,7 +1,21 @@
|
|||||||
{
|
{
|
||||||
"Routes": [
|
"Routes": [
|
||||||
{
|
{
|
||||||
"DownstreamPathTemplate": "/swagger/index.html",
|
"DownstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/swagger/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/swagger/auth/{route}",
|
||||||
"DownstreamScheme": "https",
|
"DownstreamScheme": "https",
|
||||||
"DownstreamHostAndPorts": [
|
"DownstreamHostAndPorts": [
|
||||||
{
|
{
|
||||||
@@ -9,11 +23,150 @@
|
|||||||
"Port": 7192
|
"Port": 7192
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"UpstreamPathTemplate": "/auth-swagger",
|
"UpstreamPathTemplate": "/swagger/auth/{route}",
|
||||||
"UpstreamHttpMethod": [ "Get" ]
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/user-manager?cookie=true",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7192
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/login",
|
||||||
|
"UpstreamhttpsMethod": [ "Post" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/check",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/check",
|
||||||
|
"UpstreamhttpsMethod": [ "Get" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/Auth/logout",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/Auth/logout",
|
||||||
|
"UpstreamhttpsMethod": [ "Post" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route1}/{route2}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route1}/{route2}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/api/{route1}/{route2}/{route3}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 7103
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/api/{route1}/{route2}/{route3}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 4200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/{route}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 4200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/{route}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/{route1}/{route2}",
|
||||||
|
"DownstreamScheme": "http",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "localhost",
|
||||||
|
"Port": 4200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/{route1}/{route2}",
|
||||||
|
"UpstreamhttpsMethod": [
|
||||||
|
"Get",
|
||||||
|
"Post",
|
||||||
|
"Put",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"GlobalConfiguration": {
|
"GlobalConfiguration": {
|
||||||
"BaseUrl": "https://localhost:7052"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user