diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Filters/SupportsReadOnlyMode.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Filters/SupportsReadOnlyMode.cs deleted file mode 100644 index 74339feec..000000000 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Filters/SupportsReadOnlyMode.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.ApplicationModels; -using Microsoft.AspNetCore.Mvc.Filters; - -namespace TeachingRecordSystem.Api.Infrastructure.Filters; - -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] -public class SupportsReadOnlyModeAttribute : Attribute, IActionModelConvention, IControllerModelConvention -{ - public void Apply(ActionModel action) - { - action.Properties.Add(typeof(SupportsReadOnlyModeMarker), SupportsReadOnlyModeMarker.Instance); - } - - public void Apply(ControllerModel controller) - { - controller.Properties.Add(typeof(SupportsReadOnlyModeMarker), SupportsReadOnlyModeMarker.Instance); - } -} - -public class SupportsReadOnlyModeMarker -{ - private SupportsReadOnlyModeMarker() { } - - public static SupportsReadOnlyModeMarker Instance { get; } = new(); -} - -public class ReadOnlyModeFilterFactory : IFilterFactory, IOrderedFilter -{ - public bool IsReusable => true; - - public int Order => int.MinValue; - - public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) - { - return serviceProvider.GetRequiredService(); - } -} - -public class ReadOnlyModeFilter : IActionFilter -{ - private readonly IConfiguration _configuration; - - public ReadOnlyModeFilter(IConfiguration configuration) - { - _configuration = configuration; - } - - public void OnActionExecuted(ActionExecutedContext context) - { - } - - public void OnActionExecuting(ActionExecutingContext context) - { - if (_configuration.GetValue("ReadOnlyMode")) - { - var supportsReadOnlyModeMarker = context.ActionDescriptor.GetProperty(); - - if (supportsReadOnlyModeMarker is null) - { - context.Result = new StatusCodeResult(StatusCodes.Status503ServiceUnavailable); - } - } - } -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs index 6306a9743..1d44d49f5 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs @@ -141,7 +141,6 @@ public static void Main(string[] args) options.Filters.Add(new CrmServiceProtectionFaultExceptionFilter()); options.Filters.Add(new DefaultErrorExceptionFilter(statusCode: StatusCodes.Status400BadRequest)); options.Filters.Add(new ValidationExceptionFilter()); - options.Filters.Add(new ReadOnlyModeFilterFactory()); options.Conventions.Add(new ApiVersionConvention()); options.Conventions.Add(new AuthorizationPolicyConvention()); @@ -179,7 +178,6 @@ public static void Main(string[] args) services.AddSingleton(); services.AddSingleton(); services.AddMemoryCache(); - services.AddSingleton(); services.AddHttpClient("EvidenceFiles", client => { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V1/Controllers/TeachersController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V1/Controllers/TeachersController.cs index 6ec5215fb..bd7e2c5e5 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V1/Controllers/TeachersController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V1/Controllers/TeachersController.cs @@ -1,7 +1,6 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using NSwag.Annotations; -using TeachingRecordSystem.Api.Infrastructure.Filters; using TeachingRecordSystem.Api.Infrastructure.Logging; using TeachingRecordSystem.Api.V1.Requests; using TeachingRecordSystem.Api.V1.Responses; @@ -10,7 +9,6 @@ namespace TeachingRecordSystem.Api.V1.Controllers; [ApiController] [Route("teachers")] -[SupportsReadOnlyMode] public class TeachersController : ControllerBase { private readonly IMediator _mediator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/IttProvidersController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/IttProvidersController.cs index f68f5b140..1a97db84b 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/IttProvidersController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/IttProvidersController.cs @@ -1,7 +1,6 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using NSwag.Annotations; -using TeachingRecordSystem.Api.Infrastructure.Filters; using TeachingRecordSystem.Api.V2.Requests; using TeachingRecordSystem.Api.V2.Responses; @@ -9,7 +8,6 @@ namespace TeachingRecordSystem.Api.V2.Controllers; [ApiController] [Route("itt-providers")] -[SupportsReadOnlyMode] public class IttProvidersController : ControllerBase { private readonly IMediator _mediator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/NpqQualificationsController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/NpqQualificationsController.cs index 16fa82a4a..959544301 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/NpqQualificationsController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/NpqQualificationsController.cs @@ -8,7 +8,6 @@ namespace TeachingRecordSystem.Api.V2.Controllers; [ApiController] [Route("npq-qualifications")] -[SupportsReadOnlyMode] public class NpqQualificationsController : ControllerBase { private readonly IMediator _mediator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/TeachersController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/TeachersController.cs index acbcddc76..54722cac0 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/TeachersController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/TeachersController.cs @@ -25,7 +25,6 @@ public TeachersController(IMediator mediator) summary: "Find teachers", description: "Returns teachers matching the specified criteria")] [ProducesResponseType(typeof(FindTeachersResponse), StatusCodes.Status200OK)] - [SupportsReadOnlyMode] public async Task FindTeachers(FindTeachersRequest request) { var response = await _mediator.Send(request); @@ -38,7 +37,6 @@ public async Task FindTeachers(FindTeachersRequest request) summary: "Get teacher", description: "Gets an individual teacher by their TRN")] [ProducesResponseType(typeof(GetTeacherResponse), StatusCodes.Status200OK)] - [SupportsReadOnlyMode] public async Task GetTeacher([FromRoute] GetTeacherRequest request) { var response = await _mediator.Send(request); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/UnlockTeacherController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/UnlockTeacherController.cs index 61939de6f..991c6f586 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/UnlockTeacherController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V2/Controllers/UnlockTeacherController.cs @@ -1,7 +1,6 @@ using MediatR; using Microsoft.AspNetCore.Mvc; using NSwag.Annotations; -using TeachingRecordSystem.Api.Infrastructure.Filters; using TeachingRecordSystem.Api.V2.Requests; using TeachingRecordSystem.Api.V2.Responses; @@ -9,7 +8,6 @@ namespace TeachingRecordSystem.Api.V2.Controllers; [ApiController] [Route("unlock-teacher")] -[SupportsReadOnlyMode] public class UnlockTeacherController : ControllerBase { private readonly IMediator _mediator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/CertificatesController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/CertificatesController.cs index 12d0ef774..e33a8caac 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/CertificatesController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/CertificatesController.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using NSwag.Annotations; -using TeachingRecordSystem.Api.Infrastructure.Filters; using TeachingRecordSystem.Api.Infrastructure.Security; using TeachingRecordSystem.Api.V3.Requests; @@ -13,7 +12,6 @@ namespace TeachingRecordSystem.Api.V3.Controllers; [ApiController] [Route("certificates")] [Authorize(AuthorizationPolicies.IdentityUserWithTrn)] -[SupportsReadOnlyMode] public class CertificatesController : Controller { private readonly IMediator _mediator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeacherController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeacherController.cs index 14c0a2518..5f04145ce 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeacherController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeacherController.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using NSwag.Annotations; -using TeachingRecordSystem.Api.Infrastructure.Filters; using TeachingRecordSystem.Api.Infrastructure.ModelBinding; using TeachingRecordSystem.Api.Infrastructure.Security; using TeachingRecordSystem.Api.V3.Requests; @@ -14,7 +13,6 @@ namespace TeachingRecordSystem.Api.V3.Controllers; [ApiController] [Route("teacher")] -[SupportsReadOnlyMode] public class TeacherController : Controller { private readonly IMediator _mediator; diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeachersController.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeachersController.cs index 755a98d92..21ebbad78 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeachersController.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Controllers/TeachersController.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using NSwag.Annotations; -using TeachingRecordSystem.Api.Infrastructure.Filters; using TeachingRecordSystem.Api.Infrastructure.ModelBinding; using TeachingRecordSystem.Api.Infrastructure.Security; using TeachingRecordSystem.Api.V3.Requests; @@ -14,7 +13,6 @@ namespace TeachingRecordSystem.Api.V3.Controllers; [ApiController] [Route("teachers")] [Authorize(AuthorizationPolicies.ApiKey)] -[SupportsReadOnlyMode] public class TeachersController : ControllerBase { private readonly IMediator _mediator; diff --git a/terraform/aks/app.tf b/terraform/aks/app.tf index 3256e12b8..2f47438ce 100644 --- a/terraform/aks/app.tf +++ b/terraform/aks/app.tf @@ -58,7 +58,6 @@ module "api_application_configuration" { DistributedLockContainerName = azurerm_storage_container.locks.name DqtReporting__RunService = var.run_dqt_reporting_service RecurringJobs__Enabled = var.run_recurring_jobs - ReadOnlyMode = var.readonly_mode DataProtectionKeysContainerName = azurerm_storage_container.keys.name } diff --git a/terraform/aks/variables.tf b/terraform/aks/variables.tf index a40692024..b06af55c8 100644 --- a/terraform/aks/variables.tf +++ b/terraform/aks/variables.tf @@ -75,9 +75,6 @@ variable "run_recurring_jobs" { type = bool } -variable "readonly_mode" { - type = bool -} variable "api_replicas" { type = number default = 1 diff --git a/terraform/aks/workspace_variables/dev.tfvars.json b/terraform/aks/workspace_variables/dev.tfvars.json index 4c87ad952..b10c018d7 100644 --- a/terraform/aks/workspace_variables/dev.tfvars.json +++ b/terraform/aks/workspace_variables/dev.tfvars.json @@ -6,6 +6,5 @@ "enable_monitoring": false, "deploy_dqt_reporting_server": true, "run_dqt_reporting_service": true, - "run_recurring_jobs": false, - "readonly_mode": true + "run_recurring_jobs": false } diff --git a/terraform/aks/workspace_variables/pre-production.tfvars.json b/terraform/aks/workspace_variables/pre-production.tfvars.json index 85ec90013..8f2d8a918 100644 --- a/terraform/aks/workspace_variables/pre-production.tfvars.json +++ b/terraform/aks/workspace_variables/pre-production.tfvars.json @@ -6,6 +6,5 @@ "enable_monitoring": false, "deploy_dqt_reporting_server": false, "run_dqt_reporting_service": true, - "run_recurring_jobs": true, - "readonly_mode": false + "run_recurring_jobs": true } diff --git a/terraform/aks/workspace_variables/production.tfvars.json b/terraform/aks/workspace_variables/production.tfvars.json index b5139c3a0..646d9138d 100644 --- a/terraform/aks/workspace_variables/production.tfvars.json +++ b/terraform/aks/workspace_variables/production.tfvars.json @@ -7,7 +7,6 @@ "deploy_dqt_reporting_server": false, "run_dqt_reporting_service": true, "run_recurring_jobs": true, - "readonly_mode": false, "api_replicas": 2, "ui_replicas": 2, "postgres_flexible_server_sku": "GP_Standard_D2ds_v4", diff --git a/terraform/aks/workspace_variables/test.tfvars.json b/terraform/aks/workspace_variables/test.tfvars.json index 340cecfad..26b1d390c 100644 --- a/terraform/aks/workspace_variables/test.tfvars.json +++ b/terraform/aks/workspace_variables/test.tfvars.json @@ -6,6 +6,5 @@ "enable_monitoring": false, "deploy_dqt_reporting_server": true, "run_dqt_reporting_service": true, - "run_recurring_jobs": false, - "readonly_mode": false + "run_recurring_jobs": false }