Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SecurityService.DataTransferObjects.Requests;
using Duende.IdentityModel;
using SecurityService.DataTransferObjects.Requests;
using SimpleResults;

namespace SecurityService.BusinessLogic.RequestHandlers{
Expand All @@ -10,7 +11,6 @@ namespace SecurityService.BusinessLogic.RequestHandlers{
using Duende.IdentityServer.EntityFramework.DbContexts;
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Models;
using IdentityModel;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Requests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Duende.IdentityModel;
using SecurityService.DataTransferObjects.Requests;
using SimpleResults;

Expand All @@ -13,7 +14,6 @@ namespace SecurityService.BusinessLogic.RequestHandlers
using Duende.IdentityServer.EntityFramework.Entities;
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Models;
using IdentityModel;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Requests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Shared.Results;
using Duende.IdentityModel;
using Shared.Results;

namespace SecurityService.BusinessLogic.RequestHandlers{
using System;
Expand All @@ -9,25 +10,19 @@ namespace SecurityService.BusinessLogic.RequestHandlers{
using System.Text.Encodings.Web;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using DataTransferObjects.Responses;
using Duende.IdentityServer;
using Duende.IdentityServer.EntityFramework.DbContexts;
using Duende.IdentityServer.EntityFramework.Entities;
using Exceptions;
using IdentityModel;
using MediatR;
using MessagingService.Client;
using MessagingService.DataTransferObjects;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Requests;
using SecurityService.Models;
using Shared.Exceptions;
using Shared.General;
using Shared.Logger;
using SimpleResults;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using UserDetails = Models.UserDetails;

public class UserRequestHandler : IRequestHandler<SecurityServiceCommands.CreateUserCommand, Result>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<PackageReference Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.2.3" />
<PackageReference Include="Duende.IdentityServer.Storage" Version="7.2.3" />
<PackageReference Include="MediatR" Version="12.5.0" />
<PackageReference Include="MessagingService.Client" Version="2025.3.1" />
<PackageReference Include="MessagingService.Client" Version="2025.7.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="9.0.5" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared.Results" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
<PackageReference Include="Shared.Results" Version="2025.7.9" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions SecurityService.Client/SecurityService.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2025.6.1" />
<PackageReference Include="Shared.Results" Version="2025.6.1" />
<PackageReference Include="ClientProxyBase" Version="2025.7.9" />
<PackageReference Include="Shared.Results" Version="2025.7.9" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SecurityService.Database/SecurityService.Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
</ItemGroup>
<ItemGroup>
<Folder Include="DbContexts\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using System.Collections.Generic;
using DataTransferObjects;
using Reqnroll;
using static IdentityModel.OidcConstants;
using static System.Formats.Asn1.AsnWriter;

public static class ReqnrollExtensions{
public static List<CreateApiScopeRequest> ToCreateApiScopeRequests(this DataTableRows tableRows){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!--<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="1.0.1" />
<PackageReference Include="Reqnroll.xUnit" Version="1.0.1" />-->
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.7.9" />
<!--<PackageReference Include="Shouldly" Version="4.2.1" />-->
<!--<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="Reqnroll.NUnit" Version="2.4.1" />

<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.7.9" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<PackageReference Include="Selenium.Support" Version="4.33.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.33.0" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.7.9" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion SecurityService.UnitTests/RequestHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace SecurityService.UnitTests {
using Microsoft.Extensions.Options;
using Moq;
using SecurityService.Database.DbContexts;
using static IdentityModel.ClaimComparer;

//public class TestRoleValidator : IRoleValidator<IdentityRole>{
// public async Task<IdentityResult> ValidateAsync(RoleManager<IdentityRole> manager, IdentityRole role){
Expand Down
2 changes: 1 addition & 1 deletion SecurityService.UnitTests/SecurityService.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="MockQueryable.Moq" Version="7.0.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Services;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Duende.IdentityModel;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Validation;
using IdentityModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// See LICENSE in the project root for license information.


using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using System.Text;
using System.Text.Json;
using Duende.IdentityModel;

namespace IdentityServerHost.Pages.Diagnostics;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Duende.IdentityServer;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Services;
using IdentityModel;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Security.Claims;
using Duende.IdentityModel;

namespace IdentityServerHost.Pages.ExternalLogin;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
Expand All @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="Shared" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion SecurityService/Bootstrapper/MiscRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace SecurityService.Bootstrapper
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using BusinessLogic;
using ClientProxyBase;
using Factories;
using Lamar;
using MessagingService.Client;
Expand All @@ -24,13 +25,15 @@ public class MiscRegistry : ServiceRegistry
/// </summary>
public MiscRegistry()
{
this.AddHttpContextAccessor();

this.AddSingleton<IModelFactory, ModelFactory>();

if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest")) {
this.AddSingleton<IMessagingServiceClient, TestMessagingServiceClient>();
}
else {
this.AddSingleton<IMessagingServiceClient, MessagingServiceClient>();
this.RegisterHttpClient<IMessagingServiceClient, MessagingServiceClient>();
}

this.AddSingleton<Func<String, String>>(container => serviceName => { return ConfigurationReader.GetBaseServerUri(serviceName).OriginalString; });
Expand Down
2 changes: 1 addition & 1 deletion SecurityService/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Duende.IdentityModel;

namespace SecurityService
{
Expand All @@ -11,7 +12,6 @@ namespace SecurityService
using Duende.IdentityServer;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Test;
using IdentityModel;

[ExcludeFromCodeCoverage]
public static class Config
Expand Down
43 changes: 33 additions & 10 deletions SecurityService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using System;
using NLog.Extensions.Logging;
using Shared.Logger;
using Shared.Middleware;

namespace SecurityService
{
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using Lamar.Microsoft.DependencyInjection;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Https;
Expand All @@ -26,6 +22,14 @@ namespace SecurityService
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using NLog;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;

[ExcludeFromCodeCoverage]
public class Program
Expand All @@ -36,11 +40,30 @@ public static IHostBuilder CreateHostBuilder(String[] args)
FileInfo fi = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName).AddJsonFile("hosting.json", optional:false)
.AddJsonFile("hosting.development.json", optional:true).AddEnvironmentVariables().Build();


String contentRoot = Directory.GetCurrentDirectory();
String nlogConfigPath = Path.Combine(contentRoot, "nlog.config");

LogManager.Setup(b =>
{
b.SetupLogFactory(setup =>
{
setup.AddCallSiteHiddenAssembly(typeof(NlogLogger).Assembly);
setup.AddCallSiteHiddenAssembly(typeof(Shared.Logger.Logger).Assembly);
setup.AddCallSiteHiddenAssembly(typeof(TenantMiddleware).Assembly);
});
b.LoadConfigurationFromFile(nlogConfigPath);
});

IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args);
hostBuilder.UseWindowsService();
hostBuilder = hostBuilder.UseLamar();
hostBuilder = hostBuilder.ConfigureWebHostDefaults(webBuilder =>
hostBuilder.UseLamar();
hostBuilder.ConfigureLogging(logging => {
logging.AddConsole();
logging.AddNLog();

});
hostBuilder.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureServices(services =>
Expand Down
8 changes: 4 additions & 4 deletions SecurityService/SecurityService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="9.0.0" />
Expand All @@ -32,10 +32,10 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />

<PackageReference Include="ClientProxyBase" Version="2025.7.9" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />

<PackageReference Include="Shared.Results.Web" Version="2025.6.1" />
<PackageReference Include="Shared" Version="2025.7.9" />
<PackageReference Include="Shared.Results.Web" Version="2025.7.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="8.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.3" />
Expand Down
21 changes: 6 additions & 15 deletions SecurityService/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
namespace SecurityService
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Bootstrapper;
using Database.DbContexts;
using Duende.IdentityServer.EntityFramework.DbContexts;
Expand All @@ -21,6 +18,10 @@
using Shared.Extensions;
using Shared.General;
using Shared.Logger;
using Shared.Middleware;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using ILogger = Microsoft.Extensions.Logging.ILogger;

[ExcludeFromCodeCoverage]
Expand Down Expand Up @@ -89,26 +90,16 @@ public void Configure(IApplicationBuilder app,
IWebHostEnvironment env,
ILoggerFactory loggerFactory)
{
String nlogConfigFilename = "nlog.config";
if (env.IsDevelopment())
{
var developmentNlogConfigFilename = "nlog.development.config";
if (File.Exists(Path.Combine(env.ContentRootPath, developmentNlogConfigFilename)))
{
nlogConfigFilename = developmentNlogConfigFilename;
}

app.UseDeveloperExceptionPage();
}

loggerFactory.ConfigureNLog(Path.Combine(Startup.WebHostEnvironment.ContentRootPath, nlogConfigFilename));
loggerFactory.AddNLog();


ILogger logger = loggerFactory.CreateLogger("Security Service");

Logger.Initialise(logger);
Startup.Configuration.LogConfiguration(Logger.LogWarning);

app.UseMiddleware<TenantMiddleware>();
app.AddRequestLogging();
app.AddResponseLogging();
app.AddExceptionHandler();
Expand Down
Loading
Loading