From 74f543dba93dc9a8863039aa3d2d5e3bd2bf28c9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 30 Aug 2022 22:45:47 +0000 Subject: [PATCH] --- Startup.cs | 38 ++++++++++++++++++++--- wwwroot/js/templates/app.shell.handlebars | 8 ++--- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Startup.cs b/Startup.cs index f9ddd91..7c9ff31 100644 --- a/Startup.cs +++ b/Startup.cs @@ -9,9 +9,9 @@ using rockfishCore.Util; using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; - - - +using Microsoft.Extensions.FileProviders; +using System.IO; +using Microsoft.AspNetCore.Authorization; namespace rockfishCore { @@ -63,7 +63,12 @@ namespace rockfishCore }); - + services.AddAuthorization(options => + { + options.FallbackPolicy = new AuthorizationPolicyBuilder() + .RequireAuthenticatedUser() + .Build(); + }); } @@ -75,7 +80,13 @@ namespace rockfishCore app.UseDeveloperExceptionPage(); } + + app.UseDefaultFiles(); + + + + app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = context => @@ -87,15 +98,32 @@ namespace rockfishCore } } }); + + + + app.UseAuthentication(); //Check schema RfSchema.CheckAndUpdate(dbContext); - // app.UseHttpsRedirection(); + // app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); + + //Rockfish docs so they are authenticated and not availble to anyone + //https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-5.0#static-file-authorization + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider( + Path.Combine(env.ContentRootPath, "rfdocs")) + , + RequestPath = "/docs", + RedirectToAppendTrailingSlash=true + }); + + app.UseEndpoints(endpoints => { endpoints.MapControllers(); diff --git a/wwwroot/js/templates/app.shell.handlebars b/wwwroot/js/templates/app.shell.handlebars index 8b35757..6cfe2f5 100644 --- a/wwwroot/js/templates/app.shell.handlebars +++ b/wwwroot/js/templates/app.shell.handlebars @@ -63,12 +63,8 @@ -