diff --git a/AyBorg.sln b/AyBorg.sln index db636de..103229a 100644 --- a/AyBorg.sln +++ b/AyBorg.sln @@ -97,6 +97,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Communication.MQTT", "Commu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AyBorg.Communication.MQTT", "Shared\Communication.MQTT\src\AyBorg.Communication.MQTT.csproj", "{F8F8CB98-B960-472D-AF9B-DA5C37C30EFF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AyBorg.Authorization", "Shared\Authorization\src\AyBorg.Authorization.csproj", "{936EFB62-1076-4654-AEF5-956B3994989F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -238,6 +240,10 @@ Global {F8F8CB98-B960-472D-AF9B-DA5C37C30EFF}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8F8CB98-B960-472D-AF9B-DA5C37C30EFF}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8F8CB98-B960-472D-AF9B-DA5C37C30EFF}.Release|Any CPU.Build.0 = Release|Any CPU + {936EFB62-1076-4654-AEF5-956B3994989F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {936EFB62-1076-4654-AEF5-956B3994989F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {936EFB62-1076-4654-AEF5-956B3994989F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {936EFB62-1076-4654-AEF5-956B3994989F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {4D56A2E5-D7E6-4339-9046-7A1D38872854} = {6DB9E022-557F-49B0-AC70-A77AFC191AE5} @@ -284,5 +290,6 @@ Global {CCFF5A54-DE5C-4648-9E40-20D4013CD00A} = {ED64F84D-368D-4145-A0E4-E6D9832A3DBF} {FA3B24A5-61DE-41D6-8AF5-6354873EB155} = {E28AD106-74C6-4539-974C-7048F159EFD7} {F8F8CB98-B960-472D-AF9B-DA5C37C30EFF} = {FA3B24A5-61DE-41D6-8AF5-6354873EB155} + {936EFB62-1076-4654-AEF5-956B3994989F} = {071E54C5-7218-4856-A837-8E96D705F445} EndGlobalSection EndGlobal diff --git a/Shared b/Shared index b93f7e2..a093540 160000 --- a/Shared +++ b/Shared @@ -1 +1 @@ -Subproject commit b93f7e267c981a24846f46cdc8b905031a41e7d9 +Subproject commit a0935409810b3860b1324da2808883cc649090fe diff --git a/src/Agent/Program.cs b/src/Agent/Program.cs index d423087..cbb226e 100644 --- a/src/Agent/Program.cs +++ b/src/Agent/Program.cs @@ -38,6 +38,7 @@ using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; +using System.IdentityModel.Tokens.Jwt; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); @@ -45,6 +46,8 @@ bool isOpenTelemetryEnabled = builder.Configuration.GetValue("OpenTelemetry:Enabled", false)!; bool isElasticApmEnabled = builder.Configuration.GetValue("ElasticApm:Enabled", false)!; +builder.Services.Configure(builder.Configuration.GetSection("Security")); + // Add services to the container. string? databaseProvider = builder.Configuration.GetValue("DatabaseProvider", "SqlLite"); @@ -102,7 +105,7 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddTransient(); +builder.Services.AddScoped, JwtValidator>(); // Repositories builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/src/Agent/appsettings.json b/src/Agent/appsettings.json index aa306cc..07fa5bc 100644 --- a/src/Agent/appsettings.json +++ b/src/Agent/appsettings.json @@ -25,9 +25,12 @@ }, "Plugins": { "Folder": "./plugins" - }, - "Jwt": { - "SecretKey": "_MyAtLeas40CharacterAyBorgSecretKey_" + } + }, + "Security": { + "PrimarySharedKey": { + "Enabled": true, + "KeyValue": "12345678901234567890123456789012" } }, "DatabaseProvider": "SqlLite", diff --git a/src/Gateway/Program.cs b/src/Gateway/Program.cs index 83df16f..68a72a9 100644 --- a/src/Gateway/Program.cs +++ b/src/Gateway/Program.cs @@ -32,6 +32,7 @@ using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; +using System.IdentityModel.Tokens.Jwt; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); @@ -39,6 +40,8 @@ bool isOpenTelemetryEnabled = builder.Configuration.GetValue("OpenTelemetry:Enabled", false)!; bool isElasticApmEnabled = builder.Configuration.GetValue("ElasticApm:Enabled", false)!; +builder.Services.Configure(builder.Configuration.GetSection("Security")); + // Add services to the container. string? databaseProvider = builder.Configuration.GetValue("DatabaseProvider", "SqlLite"); @@ -85,7 +88,7 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddScoped(); +builder.Services.AddScoped, JwtValidator>(); WebApplication app = builder.Build(); diff --git a/src/Gateway/appsettings.json b/src/Gateway/appsettings.json index 95be73b..fd7ecd4 100644 --- a/src/Gateway/appsettings.json +++ b/src/Gateway/appsettings.json @@ -15,9 +15,12 @@ "Audit": { "Required": false } - }, - "Jwt": { - "SecretKey": "_MyAtLeas40CharacterAyBorgSecretKey_" + } + }, + "Security": { + "PrimarySharedKey": { + "Enabled": true, + "KeyValue": "12345678901234567890123456789012" } }, "DatabaseProvider": "SqlLite", diff --git a/src/Web/Program.cs b/src/Web/Program.cs index d7e06a5..c8a312f 100644 --- a/src/Web/Program.cs +++ b/src/Web/Program.cs @@ -52,6 +52,8 @@ bool isOpenTelemetryEnabled = builder.Configuration.GetValue("OpenTelemetry:Enabled", false)!; bool isElasticApmEnabled = builder.Configuration.GetValue("ElasticApm:Enabled", false)!; +builder.Services.Configure(builder.Configuration.GetSection("Security")); + // Add services to the container. string? databaseProvider = builder.Configuration.GetValue("DatabaseProvider", "SqlLite"); diff --git a/src/Web/appsettings.json b/src/Web/appsettings.json index 697e179..b9b63eb 100644 --- a/src/Web/appsettings.json +++ b/src/Web/appsettings.json @@ -20,9 +20,12 @@ }, "Gateway": { "URL": "http://localhost:6000" - }, - "Jwt": { - "SecretKey": "_MyAtLeas40CharacterAyBorgSecretKey_" + } + }, + "Security": { + "PrimarySharedKey": { + "Enabled": true, + "KeyValue": "12345678901234567890123456789012" } }, "DatabaseProvider": "SqlLite",