diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs index dbea87fc3..f485207fb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs @@ -8,6 +8,8 @@ public class AcademyConversionProject public int Id { get; set; } public int? Urn { get; set; } public int? FormAMatProjectId { get; set; } + public Guid? SchoolSharePointId { get; set; } + public Guid? ApplicationSharePointId { get; set; } public bool? IsFormAMat { get; set; } public DateTime CreatedOn { get; set; } public string SchoolName { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs new file mode 100644 index 000000000..07641d3bd --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs @@ -0,0 +1,8 @@ +namespace Dfe.PrepareConversions.Configuration +{ + public class SharePointOptions + { + public bool Enabled { get; set; } + public string Url { get; set; } + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs index 12b6524a3..ef6cbbaab 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs @@ -1,3 +1,4 @@ +using DocumentFormat.OpenXml.InkML; using System; using System.Collections.Generic; @@ -9,6 +10,9 @@ public static class Links private static string _transfersUrl; public static string TransfersUrl => _transfersUrl; + private static bool _isApplicationDocumentsEnabled; + public static bool IsApplicationDocumentsEnabled => _isApplicationDocumentsEnabled; + private static LinkItem AddLinkItem(string page, string backText = "Back") { LinkItem item = new() { Page = page, BackText = backText }; @@ -19,6 +23,10 @@ public static void InitializeTransfersUrl(string transfersUrl) { _transfersUrl = transfersUrl; } + + public static void InializeProjectDocumentsEnabled(bool isApplicationDocumentsEnabled) { + _isApplicationDocumentsEnabled = isApplicationDocumentsEnabled; + } public static LinkItem ByPage(string page) { return _links.Find(x => string.Equals(page, x.Page, StringComparison.InvariantCultureIgnoreCase)); @@ -64,6 +72,11 @@ public static class ProjectNotes public static readonly LinkItem NewNote = AddLinkItem(page: "/ProjectNotes/NewNote"); } + public static class ApplicationDocuments + { + public static readonly LinkItem Index = AddLinkItem(page: "/ApplicationDocuments/Index"); + } + public static class TaskList { public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/TaskList/Index"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml new file mode 100644 index 000000000..bd93de677 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml @@ -0,0 +1,24 @@ +@page "/application-documents/{id:int}" +@using Dfe.PrepareConversions.Data.Models +@model Dfe.PrepareConversions.Pages.ApplicationDocuments.IndexModel +@{ + ViewData["Title"] = "Application documents"; +} + +@section BeforeMain +{ + @Links.ProjectList.Index.BackText +} + + + +
+
+

+ Application level documents folder here +

+ School level documents folder here +

+
+ +
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml.cs new file mode 100644 index 000000000..d8d87d477 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml.cs @@ -0,0 +1,41 @@ +using AngleSharp.Io.Dom; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Dfe.PrepareConversions.ViewModels; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; + +namespace Dfe.PrepareConversions.Pages.ApplicationDocuments; + +public class IndexModel : BaseAcademyConversionProjectPageModel +{ + private readonly IConfiguration _configuration; + + public string ReturnPage { get; set; } + public string ReturnId { get; set; } + + public IndexModel(IAcademyConversionProjectRepository repository, IConfiguration configuration) : base(repository) + { + _configuration = configuration; + } + + [BindProperty] + public string ApplicationLevelDocumentsFolder { get; set; } + [BindProperty] + public string SchoolLevelDocumentsFolder { get; private set; } + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + var rootSharePointFolder = _configuration["Sharepoint:Url"]; + + ApplicationLevelDocumentsFolder = $"{rootSharePointFolder}sip_application/{Project.ApplicationReferenceNumber}_{Project.ApplicationSharePointId.Value.ToString("N").ToUpper()}"; + SchoolLevelDocumentsFolder = $"{rootSharePointFolder}sip_applyingschools/{Project.ApplicationReferenceNumber}_{Project.SchoolSharePointId.Value.ToString("N").ToUpper()}"; + + return Page(); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs index 78228c386..cc8b31d09 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs @@ -1,10 +1,12 @@ -using Dfe.PrepareConversions.Data; + +using Dfe.PrepareConversions.Data; using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Services; using Dfe.PrepareConversions.Models; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Configuration; using System.Security.Claims; using System.Threading.Tasks; @@ -46,6 +48,7 @@ protected async Task SetProject(int id) } Project = new ProjectViewModel(project.Body); + return Page(); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml index e918a7275..b642d2406 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml @@ -36,7 +36,13 @@ School application form - +
  • + + Application documents + +
  • + \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs index 985b10133..b73464602 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs @@ -4,6 +4,7 @@ using Dfe.PrepareConversions.Services; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Primitives; using System.Linq; using System.Net; @@ -14,14 +15,16 @@ namespace Dfe.PrepareConversions.Pages.TaskList; public class IndexModel : BaseAcademyConversionProjectPageModel { private readonly ErrorService _errorService; + private readonly IConfiguration _configuration; private readonly KeyStagePerformanceService _keyStagePerformanceService; public IndexModel(KeyStagePerformanceService keyStagePerformanceService, IAcademyConversionProjectRepository repository, - ErrorService errorService) : base(repository) + ErrorService errorService, IConfiguration configuration) : base(repository) { _keyStagePerformanceService = keyStagePerformanceService; _errorService = errorService; + _configuration = configuration; } public bool ShowGenerateHtbTemplateError { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs index fc3690b86..92ca63991 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs @@ -1,227 +1,233 @@ -using Dfe.Academisation.CorrelationIdMiddleware; -using Dfe.PrepareConversions.Authorization; -using Dfe.PrepareConversions.Configuration; -using Dfe.PrepareConversions.Data.Features; -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Services; -using Dfe.PrepareConversions.Data.Services.AzureAd; -using Dfe.PrepareConversions.Data.Services.Interfaces; -using Dfe.PrepareConversions.Models; -using Dfe.PrepareConversions.Routing; -using Dfe.PrepareConversions.Security; -using Dfe.PrepareConversions.Services; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.CookiePolicy; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Microsoft.FeatureManagement; -using Microsoft.Identity.Web; -using Microsoft.Identity.Web.UI; -using System; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Dfe.PrepareConversions; - -public class Startup -{ - private readonly TimeSpan _authenticationExpiration; - - public Startup(IConfiguration configuration) - { - Configuration = configuration; - - _authenticationExpiration = TimeSpan.FromMinutes(int.Parse(Configuration["AuthenticationExpirationInMinutes"] ?? "60")); - } - - private IConfiguration Configuration { get; } - - private IConfigurationSection GetConfigurationSectionFor() - { - string sectionName = typeof(T).Name.Replace("Options", string.Empty); - return Configuration.GetRequiredSection(sectionName); - } - - private T GetTypedConfigurationFor() - { - return GetConfigurationSectionFor().Get(); - } - - public void ConfigureServices(IServiceCollection services) - { - services.AddFeatureManagement(); - services.AddApplicationInsightsTelemetry(); - services.AddHealthChecks(); - services - .AddRazorPages(options => - { - options.Conventions.AuthorizeFolder("/"); - options.Conventions.AllowAnonymousToPage("/public/maintenance"); - options.Conventions.AllowAnonymousToPage("/public/accessibility"); - }) - .AddViewOptions(options => - { - options.HtmlHelperOptions.ClientValidationEnabled = false; - }).AddMvcOptions(options => - { - options.MaxModelValidationErrors = 50; - options.Filters.Add(new MaintenancePageFilter(Configuration)); - }); - - services.AddControllersWithViews() - .AddMicrosoftIdentityUI(); - - services.AddScoped(sp => sp.GetService()?.HttpContext?.Session); - services.AddSession(options => - { - options.IdleTimeout = _authenticationExpiration; - options.Cookie.Name = ".ManageAnAcademyConversion.Session"; - options.Cookie.IsEssential = true; - options.Cookie.HttpOnly = true; - - if (string.IsNullOrWhiteSpace(Configuration["CI"])) - options.Cookie.SecurePolicy = CookieSecurePolicy.Always; - }); - services.AddHttpContextAccessor(); - - services.AddAuthorization(options => { options.DefaultPolicy = SetupAuthorizationPolicyBuilder().Build(); }); - - services.AddMicrosoftIdentityWebAppAuthentication(Configuration); - services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, - options => - { - options.AccessDeniedPath = "/access-denied"; - options.Cookie.Name = ".ManageAnAcademyConversion.Login"; - options.Cookie.HttpOnly = true; - options.Cookie.IsEssential = true; - options.ExpireTimeSpan = _authenticationExpiration; - options.SlidingExpiration = true; - - if (string.IsNullOrEmpty(Configuration["CI"])) - options.Cookie.SecurePolicy = CookieSecurePolicy.Always; - }); - - services.AddScoped(); - services.AddSingleton(); - - services.AddHttpClient(DfeHttpClientFactory.TramsClientName, (sp, client) => - { - TramsApiOptions tramsApiOptions = GetTypedConfigurationFor(); - client.BaseAddress = new Uri(tramsApiOptions.Endpoint); - client.DefaultRequestHeaders.Add("ApiKey", tramsApiOptions.ApiKey); - - }); - - services.AddHttpClient(DfeHttpClientFactory.AcademisationClientName, (sp, client) => - { - AcademisationApiOptions apiOptions = GetTypedConfigurationFor(); - client.BaseAddress = new Uri(apiOptions.BaseUrl); - client.DefaultRequestHeaders.Add("x-api-key", apiOptions.ApiKey); - }); - - services.Configure(GetConfigurationSectionFor()); - services.Configure(GetConfigurationSectionFor()); - - services.AddScoped(); - services.AddScoped(); - services.Decorate(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.Decorate(); - services.AddScoped(); - services.AddSingleton(); - services.AddSingleton(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - // Initialize the TransfersUrl - var serviceLinkOptions = Configuration.GetSection("ServiceLink").Get(); - Links.InitializeTransfersUrl(serviceLinkOptions.TransfersUrl); - - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Errors"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - app.UseSecurityHeaders( - SecurityHeadersDefinitions.GetHeaderPolicyCollection(env.IsDevelopment()) - .AddXssProtectionDisabled() - ); - - app.UseCookiePolicy(new CookiePolicyOptions { Secure = CookieSecurePolicy.Always, HttpOnly = HttpOnlyPolicy.Always }); - - app.UseStatusCodePagesWithReExecute("/Errors", "?statusCode={0}"); - - app.UseHttpsRedirection(); - app.UseHealthChecks("/health"); - - //For Azure AD redirect uri to remain https - ForwardedHeadersOptions forwardOptions = new() { ForwardedHeaders = ForwardedHeaders.All, RequireHeaderSymmetry = false }; - forwardOptions.KnownNetworks.Clear(); - forwardOptions.KnownProxies.Clear(); - app.UseForwardedHeaders(forwardOptions); - - app.UseStaticFiles(); - app.UseRouting(); - app.UseSentryTracing(); - app.UseSession(); - app.UseAuthentication(); - app.UseAuthorization(); - app.UseMiddleware(); - - app.UseEndpoints(endpoints => - { - endpoints.MapGet("/", context => - { - context.Response.Redirect("project-list", false); - return Task.CompletedTask; - }); - endpoints.MapRazorPages(); - endpoints.MapControllerRoute("default", "{controller}/{action}/"); - }); - } - - /// - /// Builds Authorization policy - /// Ensure authenticated user and restrict roles if they are provided in configuration - /// - /// AuthorizationPolicyBuilder - private AuthorizationPolicyBuilder SetupAuthorizationPolicyBuilder() - { - AuthorizationPolicyBuilder policyBuilder = new(); - policyBuilder.RequireAuthenticatedUser(); - - string allowedRoles = Configuration.GetSection("AzureAd")["AllowedRoles"]; - if (string.IsNullOrWhiteSpace(allowedRoles) is false) - { - policyBuilder.RequireClaim(ClaimTypes.Role, allowedRoles.Split(',')); - } - - return policyBuilder; - } -} +using Dfe.Academisation.CorrelationIdMiddleware; +using Dfe.PrepareConversions.Authorization; +using Dfe.PrepareConversions.Configuration; +using Dfe.PrepareConversions.Data.Features; +using Dfe.PrepareConversions.Data.Models; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Data.Services.AzureAd; +using Dfe.PrepareConversions.Data.Services.Interfaces; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Routing; +using Dfe.PrepareConversions.Security; +using Dfe.PrepareConversions.Services; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.CookiePolicy; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Microsoft.FeatureManagement; +using Microsoft.Identity.Web; +using Microsoft.Identity.Web.UI; +using System; +using System.Security.Claims; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions; + +public class Startup +{ + private readonly TimeSpan _authenticationExpiration; + + public Startup(IConfiguration configuration) + { + Configuration = configuration; + + _authenticationExpiration = TimeSpan.FromMinutes(int.Parse(Configuration["AuthenticationExpirationInMinutes"] ?? "60")); + } + + private IConfiguration Configuration { get; } + + private IConfigurationSection GetConfigurationSectionFor() + { + string sectionName = typeof(T).Name.Replace("Options", string.Empty); + return Configuration.GetRequiredSection(sectionName); + } + + private T GetTypedConfigurationFor() + { + return GetConfigurationSectionFor().Get(); + } + + public void ConfigureServices(IServiceCollection services) + { + services.AddFeatureManagement(); + services.AddApplicationInsightsTelemetry(); + services.AddHealthChecks(); + services + .AddRazorPages(options => + { + options.Conventions.AuthorizeFolder("/"); + options.Conventions.AllowAnonymousToPage("/public/maintenance"); + options.Conventions.AllowAnonymousToPage("/public/accessibility"); + }) + .AddViewOptions(options => + { + options.HtmlHelperOptions.ClientValidationEnabled = false; + }).AddMvcOptions(options => + { + options.MaxModelValidationErrors = 50; + options.Filters.Add(new MaintenancePageFilter(Configuration)); + }); + + services.AddControllersWithViews() + .AddMicrosoftIdentityUI(); + + services.AddScoped(sp => sp.GetService()?.HttpContext?.Session); + services.AddSession(options => + { + options.IdleTimeout = _authenticationExpiration; + options.Cookie.Name = ".ManageAnAcademyConversion.Session"; + options.Cookie.IsEssential = true; + options.Cookie.HttpOnly = true; + + if (string.IsNullOrWhiteSpace(Configuration["CI"])) + options.Cookie.SecurePolicy = CookieSecurePolicy.Always; + }); + services.AddHttpContextAccessor(); + + services.AddAuthorization(options => { options.DefaultPolicy = SetupAuthorizationPolicyBuilder().Build(); }); + + services.AddMicrosoftIdentityWebAppAuthentication(Configuration); + services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, + options => + { + options.AccessDeniedPath = "/access-denied"; + options.Cookie.Name = ".ManageAnAcademyConversion.Login"; + options.Cookie.HttpOnly = true; + options.Cookie.IsEssential = true; + options.ExpireTimeSpan = _authenticationExpiration; + options.SlidingExpiration = true; + + if (string.IsNullOrEmpty(Configuration["CI"])) + options.Cookie.SecurePolicy = CookieSecurePolicy.Always; + }); + + services.AddScoped(); + services.AddSingleton(); + + services.AddHttpClient(DfeHttpClientFactory.TramsClientName, (sp, client) => + { + TramsApiOptions tramsApiOptions = GetTypedConfigurationFor(); + client.BaseAddress = new Uri(tramsApiOptions.Endpoint); + client.DefaultRequestHeaders.Add("ApiKey", tramsApiOptions.ApiKey); + + }); + + services.AddHttpClient(DfeHttpClientFactory.AcademisationClientName, (sp, client) => + { + AcademisationApiOptions apiOptions = GetTypedConfigurationFor(); + client.BaseAddress = new Uri(apiOptions.BaseUrl); + client.DefaultRequestHeaders.Add("x-api-key", apiOptions.ApiKey); + }); + + services.Configure(GetConfigurationSectionFor()); + services.Configure(GetConfigurationSectionFor()); + + services.AddScoped(); + services.AddScoped(); + services.Decorate(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.Decorate(); + services.AddScoped(); + services.AddSingleton(); + services.AddSingleton(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + + services.Configure(Configuration.GetSection("Sharepoint")); + var sharepointOptions = Configuration.GetSection("Sharepoint").Get(); + + Links.InializeProjectDocumentsEnabled(sharepointOptions.Enabled); + + // Initialize the TransfersUrl + var serviceLinkOptions = Configuration.GetSection("ServiceLink").Get(); + Links.InitializeTransfersUrl(serviceLinkOptions.TransfersUrl); + + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Errors"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); + } + + app.UseSecurityHeaders( + SecurityHeadersDefinitions.GetHeaderPolicyCollection(env.IsDevelopment()) + .AddXssProtectionDisabled() + ); + + app.UseCookiePolicy(new CookiePolicyOptions { Secure = CookieSecurePolicy.Always, HttpOnly = HttpOnlyPolicy.Always }); + + app.UseStatusCodePagesWithReExecute("/Errors", "?statusCode={0}"); + + app.UseHttpsRedirection(); + app.UseHealthChecks("/health"); + + //For Azure AD redirect uri to remain https + ForwardedHeadersOptions forwardOptions = new() { ForwardedHeaders = ForwardedHeaders.All, RequireHeaderSymmetry = false }; + forwardOptions.KnownNetworks.Clear(); + forwardOptions.KnownProxies.Clear(); + app.UseForwardedHeaders(forwardOptions); + + app.UseStaticFiles(); + app.UseRouting(); + app.UseSentryTracing(); + app.UseSession(); + app.UseAuthentication(); + app.UseAuthorization(); + app.UseMiddleware(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGet("/", context => + { + context.Response.Redirect("project-list", false); + return Task.CompletedTask; + }); + endpoints.MapRazorPages(); + endpoints.MapControllerRoute("default", "{controller}/{action}/"); + }); + } + + /// + /// Builds Authorization policy + /// Ensure authenticated user and restrict roles if they are provided in configuration + /// + /// AuthorizationPolicyBuilder + private AuthorizationPolicyBuilder SetupAuthorizationPolicyBuilder() + { + AuthorizationPolicyBuilder policyBuilder = new(); + policyBuilder.RequireAuthenticatedUser(); + + string allowedRoles = Configuration.GetSection("AzureAd")["AllowedRoles"]; + if (string.IsNullOrWhiteSpace(allowedRoles) is false) + { + policyBuilder.RequireClaim(ClaimTypes.Role, allowedRoles.Split(',')); + } + + return policyBuilder; + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs new file mode 100644 index 000000000..6877a43c8 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace Dfe.PrepareConversions.ViewModels; + +public class FilesViewModel +{ + + public List FileNames { get; set; } + public string FilePrefixSection { get; set; } + public string SectionName { get; set; } + public string Urn { get; set; } + public string DownloadUrl { get; set; } + public Guid EntityId { get; set; } + public string ApplicationReference { get; set; } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs index 6a14b791a..e585ac59b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs @@ -12,6 +12,8 @@ public ProjectViewModel(AcademyConversionProject project) { Id = project.Id.ToString(); FormAMatProjectId = project.FormAMatProjectId; + ApplicationSharePointId = project.ApplicationSharePointId; + SchoolSharePointId = project.SchoolSharePointId; IsFormAMat = project.IsFormAMat.HasValue && project.IsFormAMat.Value; ProjectStatus = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Value; ProjectStatusColour = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Colour; @@ -130,6 +132,8 @@ public ProjectViewModel(AcademyConversionProject project) public string Id { get; } public int? FormAMatProjectId { get; } + public Guid? SchoolSharePointId { get; } + public Guid? ApplicationSharePointId { get; } public string ProjectStatus { get; } public string ProjectStatusColour { get; } public string ApplicationReferenceNumber { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json index e04e67a56..06c67f4bf 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json @@ -49,5 +49,9 @@ "ShowDirectedAcademyOrders": true }, "notificationBannerMessage": "", - "MaintenanceMode": false + "MaintenanceMode": false, + "Sharepoint": { + "Enabled": false, + "Url": "" + } }