Skip to content

Commit

Permalink
Implemented TokenValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
Light4Code committed Oct 12, 2024
1 parent b4a1556 commit 94a01e8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
7 changes: 7 additions & 0 deletions AyBorg.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion Shared
5 changes: 4 additions & 1 deletion src/Agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using System.IdentityModel.Tokens.Jwt;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

string serviceUniqueName = builder.Configuration.GetValue("AyBorg:Service:UniqueName", "AyBorg.Agent")!;
bool isOpenTelemetryEnabled = builder.Configuration.GetValue("OpenTelemetry:Enabled", false)!;
bool isElasticApmEnabled = builder.Configuration.GetValue("ElasticApm:Enabled", false)!;

builder.Services.Configure<SecurityConfiguration>(builder.Configuration.GetSection("Security"));

// Add services to the container.
string? databaseProvider = builder.Configuration.GetValue("DatabaseProvider", "SqlLite");

Expand Down Expand Up @@ -102,7 +105,7 @@
builder.Services.AddSingleton<IDeviceManager, DeviceManager>();
builder.Services.AddSingleton<IResultStorageProvider, ResultStorageProvider>();

builder.Services.AddTransient<IJwtConsumer, JwtConsumer>();
builder.Services.AddScoped<ITokenValidator<JwtSecurityToken>, JwtValidator>();
// Repositories
builder.Services.AddTransient<IProjectRepository, ProjectRepository>();
builder.Services.AddTransient<IDeviceRepository, DeviceRepository>();
Expand Down
9 changes: 6 additions & 3 deletions src/Agent/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
},
"Plugins": {
"Folder": "./plugins"
},
"Jwt": {
"SecretKey": "_MyAtLeas40CharacterAyBorgSecretKey_"
}
},
"Security": {
"PrimarySharedKey": {
"Enabled": true,
"KeyValue": "12345678901234567890123456789012"
}
},
"DatabaseProvider": "SqlLite",
Expand Down
5 changes: 4 additions & 1 deletion src/Gateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using System.IdentityModel.Tokens.Jwt;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

string serviceUniqueName = builder.Configuration.GetValue("AyBorg:Service:UniqueName", "AyBorg.Gateway")!;
bool isOpenTelemetryEnabled = builder.Configuration.GetValue("OpenTelemetry:Enabled", false)!;
bool isElasticApmEnabled = builder.Configuration.GetValue("ElasticApm:Enabled", false)!;

builder.Services.Configure<SecurityConfiguration>(builder.Configuration.GetSection("Security"));

// Add services to the container.
string? databaseProvider = builder.Configuration.GetValue("DatabaseProvider", "SqlLite");

Expand Down Expand Up @@ -85,7 +88,7 @@
builder.Services.AddSingleton<IGrpcChannelService, GrpcChannelService>();
builder.Services.AddSingleton<IKeeperService, KeeperService>();

builder.Services.AddScoped<IJwtConsumer, JwtConsumer>();
builder.Services.AddScoped<ITokenValidator<JwtSecurityToken>, JwtValidator>();

WebApplication app = builder.Build();

Expand Down
9 changes: 6 additions & 3 deletions src/Gateway/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
"Audit": {
"Required": false
}
},
"Jwt": {
"SecretKey": "_MyAtLeas40CharacterAyBorgSecretKey_"
}
},
"Security": {
"PrimarySharedKey": {
"Enabled": true,
"KeyValue": "12345678901234567890123456789012"
}
},
"DatabaseProvider": "SqlLite",
Expand Down
2 changes: 2 additions & 0 deletions src/Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
bool isOpenTelemetryEnabled = builder.Configuration.GetValue("OpenTelemetry:Enabled", false)!;
bool isElasticApmEnabled = builder.Configuration.GetValue("ElasticApm:Enabled", false)!;

builder.Services.Configure<SecurityConfiguration>(builder.Configuration.GetSection("Security"));

// Add services to the container.
string? databaseProvider = builder.Configuration.GetValue("DatabaseProvider", "SqlLite");

Expand Down
9 changes: 6 additions & 3 deletions src/Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
},
"Gateway": {
"URL": "http://localhost:6000"
},
"Jwt": {
"SecretKey": "_MyAtLeas40CharacterAyBorgSecretKey_"
}
},
"Security": {
"PrimarySharedKey": {
"Enabled": true,
"KeyValue": "12345678901234567890123456789012"
}
},
"DatabaseProvider": "SqlLite",
Expand Down

0 comments on commit 94a01e8

Please sign in to comment.