diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..c1f20a1 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,9 @@ +# Saxonite + +## Sarand - Wawam collaboration + +### Graphics + +#### Animated gifs + +* https://icons8.com/preloaders/ diff --git a/Saxonite.sln b/Saxonite.sln index df0a64b..64d1dac 100644 --- a/Saxonite.sln +++ b/Saxonite.sln @@ -26,8 +26,11 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SaxoniteCoreUnitTests", "SaxoniteCoreUnitTests\SaxoniteCoreUnitTests.csproj", "{CA680625-E334-4F76-881B-1327A2F9FE86}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution files", "Solution files", "{BD66A338-2D41-4B64-86B0-670F4F42A489}" + ProjectSection(SolutionItems) = preProject + ReadMe.md = ReadMe.md + EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaxoniteCoreUnitTestsOnline", "SaxoniteCoreUnitTestsOnline\SaxoniteCoreUnitTestsOnline.csproj", "{303BA8E9-1B95-41AD-9F51-32037A22C908}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SaxoniteCoreUnitTestsOnline", "SaxoniteCoreUnitTestsOnline\SaxoniteCoreUnitTestsOnline.csproj", "{303BA8E9-1B95-41AD-9F51-32037A22C908}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/SaxoniteCoreWeb/Base/App/SaxStartup.cs b/SaxoniteCoreWeb/Base/App/SaxStartup.cs index 5513ab7..22f7361 100644 --- a/SaxoniteCoreWeb/Base/App/SaxStartup.cs +++ b/SaxoniteCoreWeb/Base/App/SaxStartup.cs @@ -59,6 +59,15 @@ namespace Saxonite.Net.Core.Web.Base.App } protected void ConfigureServices(ConfigureServicesConfig config) { + // Authentication service. + // Required to handle 'Forbidden' responses etc. + config.services + .AddAuthentication(options => { + options.DefaultAuthenticateScheme = "forbidScheme"; + options.DefaultForbidScheme = "forbidScheme"; + options.AddScheme("forbidScheme", "Handle Forbidden"); + }); + // Added to support memory caching of sessions. config.services.AddMemoryCache(); //config.services.AddDistributedMemoryCache(); - for multiple web servers. diff --git a/SaxoniteCoreWeb/Base/App/SaxyAuthenticationHandler.cs b/SaxoniteCoreWeb/Base/App/SaxyAuthenticationHandler.cs new file mode 100644 index 0000000..58d58ff --- /dev/null +++ b/SaxoniteCoreWeb/Base/App/SaxyAuthenticationHandler.cs @@ -0,0 +1,6 @@ +namespace Saxonite.Net.Core.Web.Base.App +{ + internal class SaxyAuthenticationHandler + { + } +} \ No newline at end of file diff --git a/SaxoniteCoreWeb/Base/Middleware/SaxAuthenticationHandler.cs b/SaxoniteCoreWeb/Base/Middleware/SaxAuthenticationHandler.cs new file mode 100644 index 0000000..e3fbae9 --- /dev/null +++ b/SaxoniteCoreWeb/Base/Middleware/SaxAuthenticationHandler.cs @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; + +namespace Saxonite.Net.Core.Web.Base.Middleware +{ + //======================================================================= + // Authentication handler required to allow actions to issue Forbid() responses. + // Ref. https://stackoverflow.com/questions/54578426/why-do-i-need-to-set-a-defaultforbidscheme/54587054#54587054 + //======================================================================= + public class SaxAuthenticationHandler : AuthenticationHandler + { + //------------------------------------------------------------------- + // Data members. + + //------------------------------------------------------------------- + public SaxAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : + base(options, logger, encoder, clock) + { + } + + //------------------------------------------------------------------- + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) + { + Context.Response.StatusCode = (int)HttpStatusCode.Forbidden; + return base.HandleForbiddenAsync(properties); + } + + //------------------------------------------------------------------- + protected override async Task HandleAuthenticateAsync() + { + Context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; + return AuthenticateResult.NoResult(); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs b/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs index be4b6ac..e30bfaa 100644 --- a/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs +++ b/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs @@ -44,7 +44,7 @@ namespace Saxonite.Net.Core.Web.Admin.Models public String UserFirstName { get; set; } public String UserLastName { get; set; } public String UserRoleCodeDelim = ","; - public List UserRoleCodes { get; set; } + public new List UserRoleCodes { get; set; } public List GetUserRoleCodes() { List codes = new List(); diff --git a/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml b/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml index b5895d5..5d6bc01 100644 --- a/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml @@ -55,7 +55,7 @@ @* Scripts *@