From c758fbd87600759e7f95670947f27edbe1b45729 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Sat, 22 Feb 2025 07:30:29 -0500 Subject: [PATCH] Updates --- .../Components/ForceLogin.razor | 8 +++++ .../Components/Layout/NavMenu.razor | 32 +++++++++---------- ...alAccountOnly.razor => LocalAccount.razor} | 2 +- .../Components/Routes.razor | 6 +++- 9.0/BlazorWebAppWinAuthServer/Program.cs | 4 +++ 5 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 9.0/BlazorWebAppWinAuthServer/Components/ForceLogin.razor rename 9.0/BlazorWebAppWinAuthServer/Components/Pages/{LocalAccountOnly.razor => LocalAccount.razor} (88%) diff --git a/9.0/BlazorWebAppWinAuthServer/Components/ForceLogin.razor b/9.0/BlazorWebAppWinAuthServer/Components/ForceLogin.razor new file mode 100644 index 000000000..8878fd6e1 --- /dev/null +++ b/9.0/BlazorWebAppWinAuthServer/Components/ForceLogin.razor @@ -0,0 +1,8 @@ +@inject NavigationManager Navigation + +@code { + protected override void OnInitialized() + { + Navigation.Refresh(forceReload: true); + } +} diff --git a/9.0/BlazorWebAppWinAuthServer/Components/Layout/NavMenu.razor b/9.0/BlazorWebAppWinAuthServer/Components/Layout/NavMenu.razor index 858f71954..f80df8da7 100644 --- a/9.0/BlazorWebAppWinAuthServer/Components/Layout/NavMenu.razor +++ b/9.0/BlazorWebAppWinAuthServer/Components/Layout/NavMenu.razor @@ -20,25 +20,23 @@ - - + - + - - + diff --git a/9.0/BlazorWebAppWinAuthServer/Components/Pages/LocalAccountOnly.razor b/9.0/BlazorWebAppWinAuthServer/Components/Pages/LocalAccount.razor similarity index 88% rename from 9.0/BlazorWebAppWinAuthServer/Components/Pages/LocalAccountOnly.razor rename to 9.0/BlazorWebAppWinAuthServer/Components/Pages/LocalAccount.razor index b37f5e258..561b9a89f 100644 --- a/9.0/BlazorWebAppWinAuthServer/Components/Pages/LocalAccountOnly.razor +++ b/9.0/BlazorWebAppWinAuthServer/Components/Pages/LocalAccount.razor @@ -1,4 +1,4 @@ -@page "/local-account-only" +@page "/local-account" @using Microsoft.AspNetCore.Authorization @attribute [Authorize("LocalAccount")] diff --git a/9.0/BlazorWebAppWinAuthServer/Components/Routes.razor b/9.0/BlazorWebAppWinAuthServer/Components/Routes.razor index 5b113a71b..6fb96a568 100644 --- a/9.0/BlazorWebAppWinAuthServer/Components/Routes.razor +++ b/9.0/BlazorWebAppWinAuthServer/Components/Routes.razor @@ -1,6 +1,10 @@ - + + + + + diff --git a/9.0/BlazorWebAppWinAuthServer/Program.cs b/9.0/BlazorWebAppWinAuthServer/Program.cs index 4bda028d7..7bc071ef4 100644 --- a/9.0/BlazorWebAppWinAuthServer/Program.cs +++ b/9.0/BlazorWebAppWinAuthServer/Program.cs @@ -7,10 +7,14 @@ builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme) .AddNegotiate(); +// To require authentication for all users for the +// entire app, use the following code. +/* builder.Services.AddAuthorization(options => { options.FallbackPolicy = options.DefaultPolicy; }); +*/ builder.Services.AddCascadingAuthenticationState();