From 5f3fc01100ce7474653e77e31ecbdd51c7e89a80 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 8 Dec 2025 13:30:47 +0000 Subject: [PATCH 1/2] upgraded to net 10 --- .github/workflows/buildwindowsimage.yml | 5 - .github/workflows/createrelease.yml | 175 ++++-------------- .github/workflows/pullrequest.yml | 18 +- .github/workflows/pushtomaster.yml | 5 - .../SecurityService.BusinessLogic.csproj | 26 +-- .../SecurityService.Client.csproj | 6 +- ...SecurityService.DataTransferObjects.csproj | 2 +- .../SecurityService.Database.csproj | 24 +-- ...yService.IntegrationTesting.Helpers.csproj | 22 +-- .../SecurityService.IntegrationTests.csproj | 22 +-- .../SecurityService.Models.csproj | 2 +- ...vice.OpenIdConnect.IntegrationTests.csproj | 20 +- ...SecurityService.SqlServerMigrations.csproj | 14 +- .../RequestHandlerTests.cs | 9 +- .../SecurityService.UnitTests.csproj | 20 +- .../Pages/Diagnostics/ViewModel.cs | 3 +- .../SecurityService.UserInterface.csproj | 10 +- .../Bootstrapper/MiddlewareRegistry.cs | 5 +- .../{Controllers => Common}/Extensions.cs | 2 +- .../SecurityHeadersAttribute.cs | 2 +- .../Common/SwaggerDefaultValues.cs | 7 +- .../Controllers/ApiResourceController.cs | 125 ------------- .../Controllers/ApiScopeController.cs | 112 ----------- .../Controllers/ClientController.cs | 158 ---------------- .../Controllers/DeveloperController.cs | 67 ------- .../Controllers/IdentityResourceController.cs | 143 -------------- SecurityService/Controllers/RoleController.cs | 126 ------------- SecurityService/Controllers/UserController.cs | 147 --------------- SecurityService/Dockerfile | 4 +- SecurityService/DockerfileWindows | 2 +- SecurityService/SecurityService.csproj | 52 +++--- .../SecurityServiceTestUI.csproj | 8 +- 32 files changed, 163 insertions(+), 1180 deletions(-) rename SecurityService/{Controllers => Common}/Extensions.cs (94%) rename SecurityService/{Controllers => Common}/SecurityHeadersAttribute.cs (98%) delete mode 100644 SecurityService/Controllers/ApiResourceController.cs delete mode 100644 SecurityService/Controllers/ApiScopeController.cs delete mode 100644 SecurityService/Controllers/ClientController.cs delete mode 100644 SecurityService/Controllers/DeveloperController.cs delete mode 100644 SecurityService/Controllers/IdentityResourceController.cs delete mode 100644 SecurityService/Controllers/RoleController.cs delete mode 100644 SecurityService/Controllers/UserController.cs diff --git a/.github/workflows/buildwindowsimage.yml b/.github/workflows/buildwindowsimage.yml index 99e70ec8..13816f66 100644 --- a/.github/workflows/buildwindowsimage.yml +++ b/.github/workflows/buildwindowsimage.yml @@ -15,11 +15,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Get the version id: get_version uses: battila7/get-version-action@v2 diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 4444c567..e4551643 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -5,7 +5,7 @@ on: types: [published] jobs: - buildlinux: + build: name: "Release" env: ASPNETCORE_ENVIRONMENT: "Production" @@ -14,11 +14,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - name: Get the version id: get_version @@ -51,7 +46,7 @@ jobs: - name: Publish API if: ${{ github.event.release.prerelease == false }} - run: dotnet publish "SecurityService\SecurityService.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained + run: dotnet publish "SecurityService\SecurityService.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained - name: Build Release Package run: | @@ -59,7 +54,7 @@ jobs: zip -r ../securityservice.zip ./* - name: Upload the artifact - uses: actions/upload-artifact@v4.4.0 + uses: actions/upload-artifact@v4 with: name: securityservice path: securityservice.zip @@ -73,8 +68,8 @@ jobs: dotnet nuget push Nugets/SecurityService.IntegrationTesting.Helpers.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate deploystaging: - runs-on: [stagingserver, linux] - needs: buildlinux + runs-on: [stagingserver, windows] + needs: build environment: staging name: "Deploy to Staging" @@ -85,75 +80,30 @@ jobs: name: securityservice path: /tmp/securityservice # Download to a temporary directory - - name: Remove existing service (if applicable) + - name: Remove existing Windows service run: | - SERVICE_NAME="securityservice" - if systemctl is-active --quiet "$SERVICE_NAME"; then - echo "Stopping existing service..." - sudo systemctl stop "$SERVICE_NAME" - fi - if systemctl is-enabled --quiet "$SERVICE_NAME"; then - echo "Disabling existing service..." - sudo systemctl disable "$SERVICE_NAME" - fi - if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then - echo "Removing existing service unit file..." - sudo rm "/etc/systemd/system/${SERVICE_NAME}.service" - sudo systemctl daemon-reload - fi - + $serviceName = "Transaction Processing - Security Service" + # Check if the service exists + if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { + Stop-Service -Name $serviceName + sc.exe delete $serviceName + } + - name: Unzip the files run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice - sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice - - # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server - # This assumes it's not already there. If your base image already has it, you can skip this. - - name: Install .NET Runtime - run: | - # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0) - # and if you need the SDK or just the runtime. - # This uses Microsoft's package repository for the latest versions. - wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt update - sudo apt install -y aspnetcore-runtime-9.0 - - - name: Install and Start as a Linux service + Expand-Archive -Path securityservice.zip -DestinationPath "C:\txnproc\transactionprocessing\securityservice" -Force + + - name: Install as a Windows service run: | - SERVICE_NAME="securityservice" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice" - DLL_NAME="SecurityService.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Security Service" - - # Create a systemd service file - echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service - echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - # IMPORTANT: Use 'dotnet' to run your DLL - echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user - echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group - echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - - # Reload systemd, enable, and start the service - sudo systemctl daemon-reload - sudo systemctl enable "$SERVICE_NAME" - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification + $serviceName = "Transaction Processing - Security Service" + $servicePath = "C:\txnproc\transactionprocessing\securityservice\SecurityService.exe" + + New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic + Start-Service -Name $serviceName deployproduction: - runs-on: [productionserver, linux] - needs: [buildlinux, deploystaging] + runs-on: [productionserver, windows] + needs: [build, deploystaging] environment: production name: "Deploy to Production" @@ -164,70 +114,23 @@ jobs: name: securityservice path: /tmp/securityservice # Download to a temporary directory - - name: Remove existing service (if applicable) + - name: Remove existing Windows service run: | - SERVICE_NAME="securityservice" - if systemctl is-active --quiet "$SERVICE_NAME"; then - echo "Stopping existing service..." - sudo systemctl stop "$SERVICE_NAME" - fi - if systemctl is-enabled --quiet "$SERVICE_NAME"; then - echo "Disabling existing service..." - sudo systemctl disable "$SERVICE_NAME" - fi - if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then - echo "Removing existing service unit file..." - sudo rm "/etc/systemd/system/${SERVICE_NAME}.service" - sudo systemctl daemon-reload - fi - + $serviceName = "Transaction Processing - Security Service" + # Check if the service exists + if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { + Stop-Service -Name $serviceName + sc.exe delete $serviceName + } + - name: Unzip the files run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice - sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice - - # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server - # This assumes it's not already there. If your base image already has it, you can skip this. - - name: Install .NET Runtime - run: | - # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0) - # and if you need the SDK or just the runtime. - # This uses Microsoft's package repository for the latest versions. - wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt update - sudo apt install -y aspnetcore-runtime-9.0 - - - name: Install and Start as a Linux service + Expand-Archive -Path securityservice.zip -DestinationPath "C:\txnproc\transactionprocessing\securityservice" -Force + + - name: Install as a Windows service run: | - SERVICE_NAME="securityservice" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice" - DLL_NAME="SecurityService.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Security Service" - - # Create a systemd service file - echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service - echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - # IMPORTANT: Use 'dotnet' to run your DLL - echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user - echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group - echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - - # Reload systemd, enable, and start the service - sudo systemctl daemon-reload - sudo systemctl enable "$SERVICE_NAME" - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification + $serviceName = "Transaction Processing - Security Service" + $servicePath = "C:\txnproc\transactionprocessing\securityservice\SecurityService.exe" + + New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic + Start-Service -Name $serviceName diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 317d6521..80e9b4a7 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -16,11 +16,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Trust Root Certificate run: | certPath="$GITHUB_WORKSPACE/Certificates/aspnetapp-root-cert.pfx" @@ -58,7 +53,7 @@ jobs: run: | dotnet test "SecurityService.IntegrationTests\SecurityService.IntegrationTests.csproj" --filter Category=PRTest - - uses: actions/upload-artifact@v4.4.0 + - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: nonuilogs @@ -92,11 +87,6 @@ jobs: openssl pkcs12 -in "$certPath" -out temp.pem -nodes -password "pass:$password" sudo cp temp.pem /usr/local/share/ca-certificates/aspnetapp-web-api.crt sudo update-ca-certificates - - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - name: Restore Nuget Packages run: dotnet restore SecurityService.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} @@ -115,7 +105,7 @@ jobs: run: | dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest - - uses: actions/upload-artifact@v4.4.0 + - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: firefoxlogs @@ -172,7 +162,7 @@ jobs: # run: | # dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest - # - uses: actions/upload-artifact@v4.4.0 + # - uses: actions/upload-artifact@v4 # if: ${{ failure() }} # with: # name: chromelogs @@ -231,7 +221,7 @@ jobs: # run: | # dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest - # - uses: actions/upload-artifact@v4.4.0 + # - uses: actions/upload-artifact@v4 # if: ${{ failure() }} # with: # name: edgelogs diff --git a/.github/workflows/pushtomaster.yml b/.github/workflows/pushtomaster.yml index e92f5770..241f575d 100644 --- a/.github/workflows/pushtomaster.yml +++ b/.github/workflows/pushtomaster.yml @@ -19,11 +19,6 @@ jobs: with: fetch-depth: 0 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Restore Nuget Packages run: dotnet restore SecurityService.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj b/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj index e6056438..80637599 100644 --- a/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj +++ b/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj @@ -1,23 +1,23 @@  - net9.0 + net10.0 - - - - - - + + + + + + - - - - - - + + + + + + diff --git a/SecurityService.Client/SecurityService.Client.csproj b/SecurityService.Client/SecurityService.Client.csproj index 616d3295..3bd0ab2e 100644 --- a/SecurityService.Client/SecurityService.Client.csproj +++ b/SecurityService.Client/SecurityService.Client.csproj @@ -1,13 +1,13 @@  - net9.0 + net10.0 $(TargetsForTfmSpecificBuildOutput);IncludeP2PAssets - - + + diff --git a/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj b/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj index a9dc8c21..c6533110 100644 --- a/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj +++ b/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 diff --git a/SecurityService.Database/SecurityService.Database.csproj b/SecurityService.Database/SecurityService.Database.csproj index e81711df..b4e0fd85 100644 --- a/SecurityService.Database/SecurityService.Database.csproj +++ b/SecurityService.Database/SecurityService.Database.csproj @@ -1,28 +1,28 @@  - net9.0 + net10.0 None - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj b/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj index c8afba4c..5e0ea818 100644 --- a/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj +++ b/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj @@ -1,30 +1,14 @@  - net9.0 + net10.0 enable enable - - - - - - - - + + diff --git a/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj b/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj index 0b63003e..2f88487f 100644 --- a/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj +++ b/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj @@ -1,32 +1,32 @@  - net9.0 + net10.0 false - + - + - + - + - + - + - - + + - + - + all diff --git a/SecurityService.Models/SecurityService.Models.csproj b/SecurityService.Models/SecurityService.Models.csproj index 2d908e79..4a974a71 100644 --- a/SecurityService.Models/SecurityService.Models.csproj +++ b/SecurityService.Models/SecurityService.Models.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 diff --git a/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj b/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj index 06b60b74..4fa57552 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj +++ b/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 false @@ -10,21 +10,21 @@ - + - + - + - + - - + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SecurityService.SqlServerMigrations/SecurityService.SqlServerMigrations.csproj b/SecurityService.SqlServerMigrations/SecurityService.SqlServerMigrations.csproj index ea0417c3..62c1e09c 100644 --- a/SecurityService.SqlServerMigrations/SecurityService.SqlServerMigrations.csproj +++ b/SecurityService.SqlServerMigrations/SecurityService.SqlServerMigrations.csproj @@ -1,16 +1,16 @@  - net9.0 + net10.0 None - - - - - - + + + + + + diff --git a/SecurityService.UnitTests/RequestHandlerTests.cs b/SecurityService.UnitTests/RequestHandlerTests.cs index 2a940f6d..221f24c2 100644 --- a/SecurityService.UnitTests/RequestHandlerTests.cs +++ b/SecurityService.UnitTests/RequestHandlerTests.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; namespace SecurityService.UnitTests { using BusinessLogic; @@ -11,16 +9,11 @@ namespace SecurityService.UnitTests { using Duende.IdentityServer.EntityFramework.DbContexts; using Duende.IdentityServer.EntityFramework.Options; using Duende.IdentityServer.Services; - using Lamar; using MessagingService.Client; - using Microsoft.AspNetCore.Authentication; - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; - using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Moq; @@ -134,7 +127,7 @@ private void SetupServiceProvider() tokenProvider.Setup(tp => tp.ValidateAsync(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny())).ReturnsAsync(true); - this.ServiceProvider.Setup(sp => sp.GetService(It.IsAny())).Returns(tokenProvider.Object); + this.ServiceProvider.Setup(sp => sp.GetService(typeof(IUserTwoFactorTokenProvider))).Returns(tokenProvider.Object); } private IdentityServerTools SetupIdentityServerTools() diff --git a/SecurityService.UnitTests/SecurityService.UnitTests.csproj b/SecurityService.UnitTests/SecurityService.UnitTests.csproj index 38a0b67a..6701e146 100644 --- a/SecurityService.UnitTests/SecurityService.UnitTests.csproj +++ b/SecurityService.UnitTests/SecurityService.UnitTests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 Full false @@ -11,15 +11,15 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - + + + + + + + + + diff --git a/SecurityService.UserInterface/Pages/Diagnostics/ViewModel.cs b/SecurityService.UserInterface/Pages/Diagnostics/ViewModel.cs index 7ef99703..c4d7ee04 100644 --- a/SecurityService.UserInterface/Pages/Diagnostics/ViewModel.cs +++ b/SecurityService.UserInterface/Pages/Diagnostics/ViewModel.cs @@ -2,6 +2,7 @@ // See LICENSE in the project root for license information. +using System.Buffers.Text; using Microsoft.AspNetCore.Authentication; using System.Text; using System.Text.Json; @@ -20,7 +21,7 @@ public ViewModel(AuthenticateResult result) if (result.Properties.Items.ContainsKey("client_list")) { var encoded = result.Properties.Items["client_list"]; - var bytes = Base64Url.Decode(encoded); + var bytes = Base64Url.DecodeFromChars(encoded); var value = Encoding.UTF8.GetString(bytes); Clients = JsonSerializer.Deserialize(value); diff --git a/SecurityService.UserInterface/SecurityService.UserInterface.csproj b/SecurityService.UserInterface/SecurityService.UserInterface.csproj index 8aceac95..5e280c98 100644 --- a/SecurityService.UserInterface/SecurityService.UserInterface.csproj +++ b/SecurityService.UserInterface/SecurityService.UserInterface.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable true @@ -13,10 +13,10 @@ - - - - + + + + diff --git a/SecurityService/Bootstrapper/MiddlewareRegistry.cs b/SecurityService/Bootstrapper/MiddlewareRegistry.cs index 0b417fdd..e231d140 100644 --- a/SecurityService/Bootstrapper/MiddlewareRegistry.cs +++ b/SecurityService/Bootstrapper/MiddlewareRegistry.cs @@ -1,4 +1,6 @@ -namespace SecurityService.Bootstrapper +using Microsoft.OpenApi; + +namespace SecurityService.Bootstrapper { using System; using System.Diagnostics.CodeAnalysis; @@ -12,7 +14,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Hosting; - using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Shared.Extensions; diff --git a/SecurityService/Controllers/Extensions.cs b/SecurityService/Common/Extensions.cs similarity index 94% rename from SecurityService/Controllers/Extensions.cs rename to SecurityService/Common/Extensions.cs index f82c55ec..e3759e73 100644 --- a/SecurityService/Controllers/Extensions.cs +++ b/SecurityService/Common/Extensions.cs @@ -1,4 +1,4 @@ -namespace SecurityService.Controllers +namespace SecurityService.Common { using System; using System.Diagnostics.CodeAnalysis; diff --git a/SecurityService/Controllers/SecurityHeadersAttribute.cs b/SecurityService/Common/SecurityHeadersAttribute.cs similarity index 98% rename from SecurityService/Controllers/SecurityHeadersAttribute.cs rename to SecurityService/Common/SecurityHeadersAttribute.cs index 25c0d3f9..19530031 100644 --- a/SecurityService/Controllers/SecurityHeadersAttribute.cs +++ b/SecurityService/Common/SecurityHeadersAttribute.cs @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -namespace SecurityService.Controllers +namespace SecurityService.Common { using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Mvc; diff --git a/SecurityService/Common/SwaggerDefaultValues.cs b/SecurityService/Common/SwaggerDefaultValues.cs index 68e7c6b1..42885d2a 100644 --- a/SecurityService/Common/SwaggerDefaultValues.cs +++ b/SecurityService/Common/SwaggerDefaultValues.cs @@ -1,11 +1,10 @@ -namespace SecurityService +using Microsoft.OpenApi; + +namespace SecurityService { using System.Diagnostics.CodeAnalysis; using System.Linq; - using Microsoft.AspNetCore.Mvc; - using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.ApiExplorer; - using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; [ExcludeFromCodeCoverage] diff --git a/SecurityService/Controllers/ApiResourceController.cs b/SecurityService/Controllers/ApiResourceController.cs deleted file mode 100644 index 64e03239..00000000 --- a/SecurityService/Controllers/ApiResourceController.cs +++ /dev/null @@ -1,125 +0,0 @@ -/*using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Shared.Results; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using Azure.Core; - using Common.Examples; - using DataTransferObjects; - using DataTransferObjects.Requests; - using DataTransferObjects.Responses; - using Duende.IdentityServer.Models; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using SecurityService.BusinessLogic; - using SecurityService.BusinessLogic.Requests; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateApiResourceRequest = DataTransferObjects.Requests.CreateApiResourceRequest; - - /// - /// - /// - /// - [Route(ApiResourceController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class ApiResourceController : ControllerBase - { - private readonly IMediator Mediator; - private readonly IModelFactory ModelFactory; - - public ApiResourceController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - /// - /// Creates the API resource. - /// - /// The create API resource request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateApiResourceResponse))] - [SwaggerResponseExample(201, typeof(CreateApiResourceResponseExample))] - public async Task CreateApiResource([FromBody] CreateApiResourceRequest createApiResourceRequest, - CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateApiResourceCommand command = new(createApiResourceRequest.Name, - createApiResourceRequest.DisplayName, - createApiResourceRequest.Description, - createApiResourceRequest.Secret, - createApiResourceRequest.Scopes, - createApiResourceRequest.UserClaims); - - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the API resource. - /// - /// Name of the API resource. - /// The cancellation token. - /// - [HttpGet] - [Route("{apiResourceName}")] - [SwaggerResponse(201, type: typeof(ApiResourceDetails))] - [SwaggerResponseExample(201, typeof(ApiResourceDetailsResponseExample))] - public async Task GetApiResource([FromRoute] String apiResourceName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetApiResourceQuery query = new(apiResourceName); - - Result result= await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - - } - - /// - /// Gets the API resources. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(201, typeof(ApiResourceDetailsListResponseExample))] - public async Task GetApiResources(CancellationToken cancellationToken) { - SecurityServiceQueries.GetApiResourcesQuery query = new SecurityServiceQueries.GetApiResourcesQuery(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "apiresources"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + ApiResourceController.ControllerName; - - #endregion - } -} -*/ \ No newline at end of file diff --git a/SecurityService/Controllers/ApiScopeController.cs b/SecurityService/Controllers/ApiScopeController.cs deleted file mode 100644 index 06307416..00000000 --- a/SecurityService/Controllers/ApiScopeController.cs +++ /dev/null @@ -1,112 +0,0 @@ -/*using MediatR; -using Microsoft.AspNetCore.Http; -using SecurityService.BusinessLogic.RequestHandlers; -using SecurityService.BusinessLogic.Requests; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using BusinessLogic; - using Common.Examples; - using DataTransferObjects.Requests; - using DataTransferObjects.Responses; - using Duende.IdentityServer.Models; - using Factories; - using Microsoft.AspNetCore.Mvc; - using Shared.Results; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - - /// - /// - /// - /// - [Route(ApiScopeController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class ApiScopeController : ControllerBase - { - private readonly IMediator Mediator; - private readonly IModelFactory ModelFactory; - - public ApiScopeController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateApiScopeResponse))] - [SwaggerResponseExample(201, typeof(CreateApiScopeResponseExample))] - public async Task CreateApiScope([FromBody] CreateApiScopeRequest createApiScopeRequest, - CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateApiScopeCommand command = new(createApiScopeRequest.Name, - createApiScopeRequest.DisplayName, - createApiScopeRequest.Description); - - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the API scope. - /// - /// Name of the API scope. - /// The cancellation token. - /// - [HttpGet] - [Route("{apiScopeName}")] - [SwaggerResponse(200, type: typeof(ApiScopeDetails))] - [SwaggerResponseExample(200, typeof(ApiScopeDetailsResponseExample))] - public async Task GetApiScope([FromRoute] String apiScopeName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetApiScopeQuery query = new(apiScopeName); - - var result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the api scopes. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(200, typeof(ApiScopeDetailsListResponseExample))] - public async Task GetApiScopes(CancellationToken cancellationToken) - { - SecurityServiceQueries.GetApiScopesQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "apiscopes"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + ApiScopeController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Controllers/ClientController.cs b/SecurityService/Controllers/ClientController.cs deleted file mode 100644 index f10199be..00000000 --- a/SecurityService/Controllers/ClientController.cs +++ /dev/null @@ -1,158 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects; - using DataTransferObjects.Responses; - using Duende.IdentityServer.EntityFramework.Entities; - using Duende.IdentityServer.Models; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Shared.Results; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateClientRequest = DataTransferObjects.Requests.CreateClientRequest; - - /// - /// - /// - /// - [Route(ClientController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class ClientController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - /// - /// The model factory - /// - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The manager. - /// The model factory. - public ClientController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the client. - /// - /// The create client request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateClientResponse))] - [SwaggerResponseExample(201, typeof(CreateClientResponseExample))] - public async Task CreateClient([FromBody] CreateClientRequest createClientRequest, CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateClientCommand command = new(createClientRequest.ClientId, - createClientRequest.Secret, - createClientRequest.ClientName, - createClientRequest.ClientDescription, - createClientRequest.AllowedScopes, - createClientRequest.AllowedGrantTypes, - createClientRequest.ClientUri, - createClientRequest.ClientRedirectUris, - createClientRequest.ClientPostLogoutRedirectUris, - createClientRequest.RequireConsent, - createClientRequest.AllowOfflineAccess); - - // Create the client - Result result = await this.Mediator.Send(command, cancellationToken); - - //if (result.IsFailed) - // return result.ToActionResultX(); - - //// return the result - //return this.Created($"{ClientController.ControllerRoute}/{createClientRequest.ClientId}", - // new CreateClientResponse - // { - // ClientId = createClientRequest.ClientId - // }); - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the client. - /// - /// The client identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("{clientId}")] - [SwaggerResponse(200, type: typeof(ClientDetails))] - [SwaggerResponseExample(200, typeof(ClientDetailsResponseExample))] - public async Task GetClient([FromRoute] String clientId, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetClientQuery query = new(clientId); - - Result result= await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the clients. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(200, typeof(ClientDetailsListResponseExample))] - public async Task GetClients(CancellationToken cancellationToken) - { - SecurityServiceQueries.GetClientsQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "clients"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + ClientController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Controllers/DeveloperController.cs b/SecurityService/Controllers/DeveloperController.cs deleted file mode 100644 index 24c2401e..00000000 --- a/SecurityService/Controllers/DeveloperController.cs +++ /dev/null @@ -1,67 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace SecurityService.Controllers -{ - using System; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Bootstrapper; - using BusinessLogic; - using MessagingService.Client; - using Microsoft.Extensions.Hosting; - - [Route(DeveloperController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class DeveloperController : ControllerBase - { - private readonly IMessagingServiceClient MessagingServiceClient; - - public DeveloperController(IMessagingServiceClient messagingServiceClient) { - this.MessagingServiceClient = messagingServiceClient; - } - - [HttpGet] - [Route("lastemail")] - public async Task GetLastEmailMessage(CancellationToken cancellationToken) { - if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest") && this.MessagingServiceClient.GetType() == typeof(TestMessagingServiceClient)) { - var lastEmailRequest = ((TestMessagingServiceClient)this.MessagingServiceClient).LastEmailRequest; - - return Ok(lastEmailRequest); - } - - return this.NotFound(); - } - - [HttpGet] - [Route("lastsms")] - public async Task GetLastSMSMessage(CancellationToken cancellationToken) - { - if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest") && this.MessagingServiceClient.GetType() == typeof(TestMessagingServiceClient)) - { - var lastSmsRequest = ((TestMessagingServiceClient)this.MessagingServiceClient).LastSMSRequest; - - return Ok(lastSmsRequest); - } - - return this.NotFound(); - } - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "developer"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + DeveloperController.ControllerName; - - #endregion - } -} -*/ \ No newline at end of file diff --git a/SecurityService/Controllers/IdentityResourceController.cs b/SecurityService/Controllers/IdentityResourceController.cs deleted file mode 100644 index 32f7c08f..00000000 --- a/SecurityService/Controllers/IdentityResourceController.cs +++ /dev/null @@ -1,143 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects.Responses; - using Duende.IdentityServer.Models; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Shared.Results; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateIdentityResourceRequest = DataTransferObjects.Requests.CreateIdentityResourceRequest; - - /// - /// - /// - /// - [Route(IdentityResourceController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class IdentityResourceController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - /// - /// The model factory - /// - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The manager. - /// The model factory. - public IdentityResourceController(IMediator mediator, - IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the identity resource. - /// - /// The create identity resource request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateIdentityResourceResponse))] - [SwaggerResponseExample(201, typeof(CreateIdentityResourceResponseExample))] - public async Task CreateIdentityResource([FromBody] CreateIdentityResourceRequest createIdentityResourceRequest, - CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateIdentityResourceCommand command = new(createIdentityResourceRequest.Name, - createIdentityResourceRequest.DisplayName, - createIdentityResourceRequest.Description, - createIdentityResourceRequest.Required, - createIdentityResourceRequest.Emphasize, - createIdentityResourceRequest.ShowInDiscoveryDocument, - createIdentityResourceRequest.Claims); - - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the identity resource. - /// - /// Name of the identity resource. - /// The cancellation token. - /// - [HttpGet] - [Route("{identityResourceName}")] - [SwaggerResponse(200, type: typeof(IdentityResourceDetails))] - [SwaggerResponseExample(200, typeof(IdentityResourceDetailsResponseExample))] - public async Task GetIdentityResource([FromRoute] String identityResourceName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetIdentityResourceQuery query = new(identityResourceName); - - Result result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the identity resources. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(200, typeof(IdentityResourceDetailsListResponseExample))] - public async Task GetIdentityResources(CancellationToken cancellationToken) { - SecurityServiceQueries.GetIdentityResourcesQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "identityresources"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + IdentityResourceController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Controllers/RoleController.cs b/SecurityService/Controllers/RoleController.cs deleted file mode 100644 index d7c5f377..00000000 --- a/SecurityService/Controllers/RoleController.cs +++ /dev/null @@ -1,126 +0,0 @@ -/*using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Shared.Results; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System.Threading; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects.Responses; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateRoleRequest = DataTransferObjects.Requests.CreateRoleRequest; - - [Route(RoleController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class RoleController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - public RoleController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the role. - /// - /// The create role request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateRoleResponse))] - [SwaggerResponseExample(statusCode: 201, typeof(CreateRoleResponseExample))] - public async Task CreateRole([FromBody] CreateRoleRequest createRoleRequest, CancellationToken cancellationToken) - { - Guid roleId = Guid.NewGuid(); - SecurityServiceCommands.CreateRoleCommand command = new(roleId, createRoleRequest.RoleName); - - Result result = await this.Mediator.Send(command, cancellationToken); - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the role. - /// - /// The role identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("{roleId}")] - [SwaggerResponse(200, type: typeof(RoleDetails))] - [SwaggerResponseExample(statusCode: 200, typeof(RoleDetailsResponseExample))] - public async Task GetRole([FromRoute] Guid roleId, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetRoleQuery query = new(roleId); - - Result result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the roles. - /// - /// The role identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(statusCode: 200, typeof(RoleDetailsListResponseExample))] - public async Task GetRoles(CancellationToken cancellationToken) - { - SecurityServiceQueries.GetRolesQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "roles"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + RoleController.ControllerName; - - #endregion - } -} -*/ \ No newline at end of file diff --git a/SecurityService/Controllers/UserController.cs b/SecurityService/Controllers/UserController.cs deleted file mode 100644 index 3b7c5149..00000000 --- a/SecurityService/Controllers/UserController.cs +++ /dev/null @@ -1,147 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Shared.Results; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects; - using DataTransferObjects.Responses; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateUserRequest = DataTransferObjects.CreateUserRequest; - - /// - /// - /// - /// - [Route(UserController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class UserController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The manager. - /// The model factory. - public UserController(IMediator mediator, IModelFactory modelFactory){ - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the user. - /// - /// The create user request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateUserResponse))] - [SwaggerResponseExample(statusCode: 201, typeof(CreateUserResponseExample))] - public async Task CreateUser([FromBody] CreateUserRequest createUserRequest, CancellationToken cancellationToken) - { - Guid userId = Guid.NewGuid(); - - SecurityServiceCommands.CreateUserCommand command =new(userId, - createUserRequest.GivenName, - createUserRequest.MiddleName, - createUserRequest.FamilyName, - createUserRequest.EmailAddress, - createUserRequest.Password, - createUserRequest.EmailAddress, - createUserRequest.PhoneNumber, - createUserRequest.Claims, - createUserRequest.Roles); - - // Create the user - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the user. - /// - /// The user identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("{userId}")] - [SwaggerResponse(200, type: typeof(UserDetails))] - [SwaggerResponseExample(statusCode: 200, typeof(UserDetailsResponseExample))] - public async Task GetUser([FromRoute] Guid userId, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetUserQuery query = new(userId); - - Result result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the users. - /// - /// Name of the user. - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(statusCode: 200, typeof(UserDetailsListResponseExample))] - - public async Task GetUsers([FromQuery] String userName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetUsersQuery query = new(userName); - - Result> result= await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "users"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + UserController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Dockerfile b/SecurityService/Dockerfile index 56da520b..c8693e0a 100644 --- a/SecurityService/Dockerfile +++ b/SecurityService/Dockerfile @@ -1,7 +1,7 @@ -FROM stuartferguson/txnprocbase:2025.8.1 AS base +FROM stuartferguson/txnprocbase AS base WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build # Set the ARG for your GitHub Secret ARG NUGET_TOKEN diff --git a/SecurityService/DockerfileWindows b/SecurityService/DockerfileWindows index 07cf9d47..e12fbf50 100644 --- a/SecurityService/DockerfileWindows +++ b/SecurityService/DockerfileWindows @@ -2,7 +2,7 @@ FROM stuartferguson/txnprocbasewindows AS base USER ContainerAdministrator WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0-windowsservercore-ltsc2022 AS build WORKDIR /src COPY ["Certificates/*.*", "Certificates/"] COPY ["SecurityService/NuGet.Config", "."] diff --git a/SecurityService/SecurityService.csproj b/SecurityService/SecurityService.csproj index 62aa01fe..e121605e 100644 --- a/SecurityService/SecurityService.csproj +++ b/SecurityService/SecurityService.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 5e9b93dd-258d-47d7-a6d3-42e86a745857 Linux @@ -10,39 +10,39 @@ - - - - - + + + + + - + - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/SecurityServiceTestUI/SecurityServiceTestUI.csproj b/SecurityServiceTestUI/SecurityServiceTestUI.csproj index 93f5b277..6a6afa55 100644 --- a/SecurityServiceTestUI/SecurityServiceTestUI.csproj +++ b/SecurityServiceTestUI/SecurityServiceTestUI.csproj @@ -1,17 +1,17 @@  - net9.0 + net10.0 c4d765c4-a186-4046-82dc-93e937d2eb6f Linux - - + + - + From 6f43f9d79b927a6df09fc176cb9cc496ebd8bc42 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 8 Dec 2025 13:46:24 +0000 Subject: [PATCH 2/2] oops --- SecurityServiceTestUI/Dockerfile | 4 ++-- SecurityServiceTestUI/DockerfileWindows | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SecurityServiceTestUI/Dockerfile b/SecurityServiceTestUI/Dockerfile index 5c8adbfb..df6d97b8 100644 --- a/SecurityServiceTestUI/Dockerfile +++ b/SecurityServiceTestUI/Dockerfile @@ -1,7 +1,7 @@ -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build # Set the ARG for your GitHub Secret ARG NUGET_TOKEN diff --git a/SecurityServiceTestUI/DockerfileWindows b/SecurityServiceTestUI/DockerfileWindows index 86071252..87f733d7 100644 --- a/SecurityServiceTestUI/DockerfileWindows +++ b/SecurityServiceTestUI/DockerfileWindows @@ -1,10 +1,10 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/aspnet:9.0-windowsservercore-ltsc2019 AS base +FROM mcr.microsoft.com/dotnet/aspnet:10.0-windowsservercore-ltsc2019 AS base USER ContainerAdministrator WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2019 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0-windowsservercore-ltsc2019 AS build WORKDIR /src COPY ["SecurityService/NuGet.Config", "."] COPY ["Certificates/*.*", "Certificates/"]