├── Blazor8Auth
├── wwwroot
│ ├── favicon.png
│ ├── app.css
│ └── bootstrap
│ │ └── bootstrap.min.css
├── Components
│ ├── Pages
│ │ ├── Home.razor
│ │ ├── MustBeLoggedIn.razor
│ │ ├── MustBeAdmin.razor
│ │ ├── Counter.razor
│ │ ├── Logout.razor
│ │ ├── Auth.razor
│ │ ├── Error.razor
│ │ ├── Login.razor
│ │ ├── Weather.razor
│ │ └── Login.razor.cs
│ ├── _Imports.razor
│ ├── Routes.razor
│ ├── App.razor
│ └── Layout
│ │ ├── CheckAuthorization.razor
│ │ ├── MainLayout.razor
│ │ ├── MainLayout.razor.css
│ │ ├── NavMenu.razor
│ │ └── NavMenu.razor.css
├── Entities
│ ├── SignInModel.cs
│ └── ServiceResponse.cs
├── Services
│ ├── IAuthDataService.cs
│ ├── ICustomSessionService.cs
│ ├── IAuthService.cs
│ ├── CustomAuthStateProvider.cs
│ ├── CustomSessionService.cs
│ ├── AuthDataService.cs
│ └── AuthService.cs
├── appsettings.Development.json
├── appsettings.json
├── Blazor8Auth.csproj
├── Properties
│ └── launchSettings.json
└── Program.cs
├── LICENSE
├── Blazor8Auth.sln
├── README.md
└── .gitignore
/Blazor8Auth/wwwroot/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GregFinzer/Blazor8Auth/HEAD/Blazor8Auth/wwwroot/favicon.png
--------------------------------------------------------------------------------
/Blazor8Auth/Components/Pages/Home.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @using Blazor8Auth.Services
3 |
4 |
Current count: @currentCount
9 | 10 | 11 | 12 | @code { 13 | private int currentCount = 0; 14 | 15 | private void IncrementCount() 16 | { 17 | currentCount++; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Blazor8Auth/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using Blazor8Auth 10 | @using Blazor8Auth.Components 11 | @using Blazor8Auth.Components.Layout 12 | -------------------------------------------------------------------------------- /Blazor8Auth/Entities/ServiceResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor8Auth.Entities 2 | { 3 | public class ServiceResponseUser Logged In: @context.User.Identity.Name
11 |Role: @context.User.Claims.First(o => o.Type == ClaimTypes.Role).Value
12 |Not logged in
15 |Welcome, Admin! You have access to this because you are an administrator.
23 |You do not have the Admin Role.
26 |
12 | Request ID: @RequestId
13 |
18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |
20 |21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |
26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /Blazor8Auth/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @using Blazor8Auth.Services 2 | @inherits LayoutComponentBase 3 | 4 |Login as admin@acme.com with any password to login with Admin role.
8 |Login as super@acme.com with any password to login with Super role.
9 | 10 |This component demonstrates showing data.
9 | 10 | @if (forecasts == null) 11 | { 12 |Loading...
13 | } 14 | else 15 | { 16 || Date | 20 |Temp. (C) | 21 |Temp. (F) | 22 |Summary | 23 |
|---|---|---|---|
| @forecast.Date.ToShortDateString() | 30 |@forecast.TemperatureC | 31 |@forecast.TemperatureF | 32 |@forecast.Summary | 33 |