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 74339feec7..0000000000 --- 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 d54203b862..350472e7a4 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs @@ -146,7 +146,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()); @@ -184,7 +183,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 6ec5215fbc..bd7e2c5e5e 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 f68f5b1408..1a97db84bc 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 16fa82a4ae..9595443013 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 acbcddc76e..54722cac08 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 61939de6f6..991c6f5861 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 12d0ef7748..e33a8caac5 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 14c0a2518d..5f04145cef 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 755a98d92a..21ebbad784 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 e94941414e..3f0e4bc8bf 100644 --- a/terraform/aks/app.tf +++ b/terraform/aks/app.tf @@ -59,7 +59,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 a406920244..b06af55c8a 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 4c87ad9526..b10c018d79 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 85ec90013f..8f2d8a9182 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 b5139c3a09..646d9138d8 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 340cecfad2..26b1d390c1 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 }