Skip to content

Commit b824289

Browse files
authored
EFCore Samples (#38)
* EFCore Samples * Cleanup * More Cleanup * More Cleanup * EFCore Store Permission Fix & Finalized Samples
1 parent 64f5b4b commit b824289

117 files changed

Lines changed: 8919 additions & 26 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎UltimateAuth.slnx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
<Project Path="samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/CodeBeam.UltimateAuth.Sample.BlazorServer.csproj" />
1414
<Project Path="samples/blazor-standalone-wasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm.csproj" Id="27bd3c4d-65a9-4c70-a6c9-4178b1897730" />
1515
<Project Path="samples/CodeBeam.UltimateAuth.Sample.Seed/CodeBeam.UltimateAuth.Sample.Seed.csproj" Id="c79b227b-409e-439d-97df-8979a3dc1a60" />
16+
<Project Path="samples/int-wasm/CodeBeam.UAuth.Sample.IntWasm/CodeBeam.UAuth.Sample.IntWasm.Client/CodeBeam.UAuth.Sample.IntWasm.Client.csproj" Id="f17355ac-c53c-44e8-b372-a258493bf950" />
17+
<Project Path="samples/int-wasm/CodeBeam.UAuth.Sample.IntWasm/CodeBeam.UAuth.Sample.IntWasm/CodeBeam.UAuth.Sample.IntWasm.csproj" Id="65386675-4cf7-4745-b4d7-544b6404e0c3" />
18+
<Project Path="samples/resource-api/CodeBeam.UltimateAuth.Sample.ResourceApi.EfCore/CodeBeam.UltimateAuth.Sample.ResourceApi.EfCore.csproj" Id="ac247836-455a-4a71-9a52-73587c2393f3" />
1619
<Project Path="samples/resource-api/CodeBeam.UltimateAuth.Sample.ResourceApi/CodeBeam.UltimateAuth.Sample.ResourceApi.csproj" Id="3d877c9b-65eb-45be-b259-431b2d386736" />
20+
<Project Path="samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore/CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore.csproj" Id="a1fc0019-8a7c-4452-8e8c-4c2bdd549de0" />
1721
<Project Path="samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.csproj" Id="ae5368ee-10aa-4c75-9653-a7f481849834" />
1822
</Folder>
1923
<Folder Name="/Solution Items/">
@@ -35,6 +39,7 @@
3539
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.InMemory/CodeBeam.UltimateAuth.Authorization.InMemory.csproj" Id="a1e6d007-bdc0-4574-b549-ec863757edd3" />
3640
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Reference/CodeBeam.UltimateAuth.Authorization.Reference.csproj" Id="84b784d0-bb48-406a-a0d1-c600da667597" />
3741
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization/CodeBeam.UltimateAuth.Authorization.csproj" Id="28b1d647-fb0b-4cc3-8503-2680c4a9b28f" />
42+
<Project Path="src/client/CodeBeam.UltimateAuth.Client.AspNetCore/CodeBeam.UltimateAuth.Client.AspNetCore.csproj" Id="aa4e9064-759f-4756-b1ee-d84c73826105" />
3843
<Project Path="src/client/CodeBeam.UltimateAuth.Client.Blazor/CodeBeam.UltimateAuth.Client.Blazor.csproj" Id="eb60a3b7-ba9d-48c9-98ad-b28e879b23bf" />
3944
<Project Path="src/client/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj" Id="fa128a9b-613c-4762-993a-2886280d3051" />
4045
<Project Path="src/CodeBeam.UltimateAuth.Core/CodeBeam.UltimateAuth.Core.csproj" />
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@namespace CodeBeam.UltimateAuth.Sample
2+
@inherits ComponentBase
3+
4+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 240" width="@Size" height="@Size" style="@BuildStyle()" class="@Class">
5+
6+
@if (Variant == UAuthLogoVariant.Brand)
7+
{
8+
<path fill="@ShieldColor"
9+
d="M32.39,14.07H167.61c11.27,0,18,6.76,18,18V133.52c0,22.54-58.59,69.87-85.64,92.41-27-22.54-85.64-69.87-85.64-92.41V32.1C14.36,20.83,21.12,14.07,32.39,14.07Z" />
10+
11+
<path fill="@KeyColor" fill-rule="evenodd" d="@KeyPath" />
12+
}
13+
else
14+
{
15+
<path d="M32.39,14.07H167.61c11.27,0,18,6.76,18,18V133.52c0,22.54-58.59,69.87-85.64,92.41-27-22.54-85.64-69.87-85.64-92.41V32.1C14.36,20.83,21.12,14.07,32.39,14.07Z" />
16+
17+
<path fill-rule="evenodd" d="@KeyPath" />
18+
}
19+
</svg>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Microsoft.AspNetCore.Components;
2+
using Microsoft.AspNetCore.Components.Web;
3+
4+
namespace CodeBeam.UltimateAuth.Sample;
5+
6+
public partial class UAuthLogo : ComponentBase
7+
{
8+
[Parameter] public UAuthLogoVariant Variant { get; set; } = UAuthLogoVariant.Brand;
9+
10+
[Parameter] public int Size { get; set; } = 32;
11+
12+
[Parameter] public string? ShieldColor { get; set; } = "#00072d";
13+
[Parameter] public string? KeyColor { get; set; } = "#f6f5ae";
14+
15+
[Parameter] public string? Class { get; set; }
16+
[Parameter] public string? Style { get; set; }
17+
18+
private string BuildStyle()
19+
{
20+
if (Variant == UAuthLogoVariant.Mono)
21+
return $"color: {KeyColor}; {Style}";
22+
23+
return Style ?? "";
24+
}
25+
26+
protected string KeyPath => @"
27+
M120.43,39.44H79.57A11.67,11.67,0,0,0,67.9,51.11V77.37
28+
A11.67,11.67,0,0,0,79.57,89H90.51l3.89,3.9v5.32l-3.8,3.81v81.41H99
29+
v-5.33h13.69V169H108.1v-3.8H99C99,150.76,111.9,153,111.9,153
30+
V99.79h-8V93.32L108.19,89h12.24
31+
A11.67,11.67,0,0,0,132.1,77.37V51.11
32+
A11.67,11.67,0,0,0,120.43,39.44Z
33+
34+
M79.57,48.19h5.84a2.92,2.92 0 0 1 2.92,2.92
35+
v5.84a2.92,2.92 0 0 1 -2.92,2.92
36+
h-5.84a2.91,2.91 0 0 1 -2.91,-2.92
37+
v-5.84a2.91,2.91 0 0 1 2.91,-2.92Z
38+
39+
M79.57,68.62h5.84a2.92,2.92 0 0 1 2.92,2.92
40+
v5.83a2.92,2.92 0 0 1 -2.92,2.92
41+
h-5.84a2.91,2.91 0 0 1 -2.91,-2.92
42+
v-5.83a2.91,2.91 0 0 1 2.91,-2.92Z
43+
44+
M114.59,48.19h5.84a2.92,2.92 0 0 1 2.91,2.92
45+
v5.84a2.91,2.91 0 0 1 -2.91,2.91
46+
h-5.84a2.92,2.92 0 0 1 -2.92,-2.91
47+
v-5.84a2.92,2.92 0 0 1 2.92,-2.92Z
48+
49+
M114.59,68.62h5.84a2.92,2.92 0 0 1 2.91,2.92
50+
v5.83a2.91,2.91 0 0 1 -2.91,2.92
51+
h-5.84a2.92,2.92 0 0 1 -2.92,-2.92
52+
v-5.83a2.92,2.92 0 0 1 2.92,-2.92Z
53+
";
54+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace CodeBeam.UltimateAuth.Sample;
2+
3+
public enum UAuthLogoVariant
4+
{
5+
Brand,
6+
Mono
7+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<IsPackable>false</IsPackable>
8+
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="9.0.4" />
13+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.5" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.5">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.5" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.5">
20+
<PrivateAssets>all</PrivateAssets>
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
</PackageReference>
23+
<PackageReference Include="MudBlazor" Version="9.3.0" />
24+
<PackageReference Include="Scalar.AspNetCore" Version="2.13.22" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<ProjectReference Include="..\..\..\nuget\CodeBeam.UltimateAuth.EntityFrameworkCore\CodeBeam.UltimateAuth.EntityFrameworkCore.Bundle.csproj" />
29+
<ProjectReference Include="..\..\..\src\client\CodeBeam.UltimateAuth.Client.Blazor\CodeBeam.UltimateAuth.Client.Blazor.csproj" />
30+
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Server\CodeBeam.UltimateAuth.Server.csproj" />
31+
<ProjectReference Include="..\..\CodeBeam.UltimateAuth.Sample.Seed\CodeBeam.UltimateAuth.Sample.Seed.csproj" />
32+
</ItemGroup>
33+
34+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<base href="/" />
8+
<ResourcePreloader />
9+
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
10+
<link rel="stylesheet" href="@Assets["app.css"]" />
11+
<link rel="stylesheet" href="@Assets["CodeBeam.UltimateAuth.Sample.UAuthHub.EFCore.styles.css"]" />
12+
<ImportMap />
13+
<link rel="icon" type="image/png" href="UltimateAuth-Logo.png" />
14+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
15+
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
16+
<link href="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css" rel="stylesheet" />
17+
<HeadOutlet @rendermode="InteractiveServer" />
18+
</head>
19+
20+
<body>
21+
<Routes @rendermode="InteractiveServer" />
22+
<ReconnectModal />
23+
<script src="@Assets["_framework/blazor.web.js"]"></script>
24+
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
25+
<script src="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"></script>
26+
<script src="_content/CodeBeam.UltimateAuth.Client.Blazor/uauth.min.js"></script>
27+
</body>
28+
29+
</html>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
@inherits UAuthHubLayoutComponentBase
2+
@inject IUAuthClient UAuthClient
3+
@inject ISnackbar Snackbar
4+
@inject NavigationManager Nav
5+
6+
@if (!IsHubAuthorized)
7+
{
8+
<MudAppBar Class="uauth-blur" Color="Color.Transparent" Dense="true" Elevation="0">
9+
<UAuthLogo />
10+
<MudText Class="ml-2 cursor-pointer" Style="user-select: none" @onclick="@(() => Nav.NavigateTo("/home", true))"><b>UltimateAuth</b></MudText>
11+
<MudDivider Class="ml-3 mr-1" Vertical="true" />
12+
<MudText Class="ml-2" Style="line-height: 14px" Typo="Typo.subtitle2">UAuthHub Sample</MudText>
13+
14+
<MudSpacer />
15+
16+
<MudIconButton Icon="@(DarkModeManager.IsDarkMode? Icons.Material.Filled.LightMode : Icons.Material.Filled.DarkMode)" OnClick="@(() => DarkModeManager.ToggleAsync())" />
17+
</MudAppBar>
18+
19+
<MudPage Class="d-flex align-center justify-center" FullScreen="FullScreen.FullWithoutAppbar" Column="1" Row="1">
20+
<MudPaper Class="pa-8" Elevation="4" Style="max-width: 520px; width: 100%;">
21+
<MudStack Spacing="3" AlignItems="AlignItems.Center">
22+
<UAuthLogo Size="72" />
23+
24+
<MudText Typo="Typo.h5"><b>Access Denied</b></MudText>
25+
26+
<MudText Typo="Typo.body2" Align="Align.Center">
27+
This page cannot be accessed directly.
28+
UAuthHub login flows can only be initiated by an authorized client application.
29+
</MudText>
30+
31+
<MudDivider Class="my-2" />
32+
33+
<MudText Typo="Typo.caption" Color="Color.Secondary">
34+
UltimateAuth protects this resource based on your session and permissions.
35+
</MudText>
36+
</MudStack>
37+
</MudPaper>
38+
</MudPage>
39+
return;
40+
}
41+
42+
<MudLayout>
43+
<MudAppBar Class="uauth-blur" Color="Color.Transparent" Dense="true" Elevation="0">
44+
<UAuthLogo />
45+
<MudText Class="ml-2 cursor-pointer" Style="user-select: none" @onclick="@(() => Nav.NavigateTo("/home", true))"><b>UltimateAuth</b></MudText>
46+
<MudDivider Class="ml-3 mr-1" Vertical="true" />
47+
<MudText Class="ml-2" Style="line-height: 14px" Typo="Typo.subtitle2">UAuthHub Sample</MudText>
48+
49+
<MudSpacer />
50+
51+
<MudIconButton Icon="@(DarkModeManager.IsDarkMode? Icons.Material.Filled.LightMode : Icons.Material.Filled.DarkMode)" OnClick="@(() => DarkModeManager.ToggleAsync())" />
52+
53+
<UAuthStateView>
54+
<Authorized Context="state">
55+
<MudMenu PopoverClass="mud-theme-primary uauth-menu-popover" AnchorOrigin="Origin.BottomRight" TransformOrigin="Origin.TopRight">
56+
<ActivatorContent>
57+
<div @onclick="@(() => context.ToggleAsync())">
58+
<MudBadge Overlap="true" Dot="true" Color="@GetBadgeColor()">
59+
<MudAvatar Class="cursor-pointer mud-ripple" Variant="Variant.Filled" Color="Color.Primary">
60+
<MudText Typo="Typo.subtitle2">@((state.Identity?.DisplayName ?? "?").Trim() is var n ? (n.Length >= 2 ? n[..2] : n[..1]) : "?")</MudText>
61+
</MudAvatar>
62+
</MudBadge>
63+
</div>
64+
</ActivatorContent>
65+
66+
<ChildContent>
67+
<MudText Class="px-4 py-2"><b>@state.Identity?.DisplayName</b></MudText>
68+
<MudText Class="px-4" Typo="Typo.subtitle2">@string.Join(", ", state.Claims.Roles)</MudText>
69+
70+
<MudDivider />
71+
72+
<MudMenuItem Icon="@Icons.Material.Filled.Refresh" IconColor="Color.Secondary" Label="Refresh Session" OnClick="@Refresh" />
73+
<MudMenuItem Icon="@Icons.Material.Filled.VerifiedUser" IconColor="Color.Secondary" Label="Validate Session" OnClick="@Validate" />
74+
<MudMenuItem Icon="@Icons.Material.Filled.Logout" IconColor="Color.Secondary" Label="Logout" OnClick="@Logout" />
75+
76+
@if (state.Identity?.SessionState is not null && state.Identity.SessionState != SessionState.Active)
77+
{
78+
<MudDivider />
79+
<MudMenuItem Icon="@Icons.Material.Filled.Login" Label="Reauthenticate" OnClick="@GoToLoginWithReturn" />
80+
}
81+
</ChildContent>
82+
</MudMenu>
83+
</Authorized>
84+
85+
<NotAuthorized>
86+
<MudChip T="string" Style="width: fit-content" Text="Sign In" Color="Color.Primary" Variant="Variant.Filled" Class="cursor-pointer" OnClick="@HandleSignInClick" />
87+
</NotAuthorized>
88+
</UAuthStateView>
89+
</MudAppBar>
90+
91+
<MudMainContent>
92+
@Body
93+
</MudMainContent>
94+
</MudLayout>
95+
96+
97+
<div id="blazor-error-ui">
98+
An unhandled error has occurred.
99+
<a href="" class="reload">Reload</a>
100+
<a class="dismiss">🗙</a>
101+
</div>

0 commit comments

Comments
 (0)