Skip to content

Commit cf2cf6f

Browse files
authored
Preparation of First Release (Part 6/7) (#14)
* Preparation of First Release (Part 6/7) * Add Required Projects * Project Name Change to Proper Ones * Add Contracts & Reference Projects For Users & Credentials * Complete Reference & InMemory Projects for Users & Credentials * Add Role Support & Enhance ClaimsSnapshot * User Management Endpoints & Orchestrator Basics * Add Credential Endpoints * Added Policy Project * Added User Client
1 parent 763c4ea commit cf2cf6f

File tree

329 files changed

+7308
-1433
lines changed

Some content is hidden

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

329 files changed

+7308
-1433
lines changed

UltimateAuth.slnx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,26 @@
1212
<Folder Name="/Tests/">
1313
<Project Path="tests/CodeBeam.UltimateAuth.Tests.Unit/CodeBeam.UltimateAuth.Tests.Unit.csproj" Id="6f4b22da-849a-4a79-b5c5-aee7cb1429a6" />
1414
</Folder>
15+
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Contracts/CodeBeam.UltimateAuth.Authorization.Contracts.csproj" Id="40a23002-f885-42a8-bdd9-fd962ab28742" />
16+
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.InMemory/CodeBeam.UltimateAuth.Authorization.InMemory.csproj" Id="a1e6d007-bdc0-4574-b549-ec863757edd3" />
17+
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Reference/CodeBeam.UltimateAuth.Authorization.Reference.csproj" Id="84b784d0-bb48-406a-a0d1-c600da667597" />
18+
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization/CodeBeam.UltimateAuth.Authorization.csproj" Id="28b1d647-fb0b-4cc3-8503-2680c4a9b28f" />
1519
<Project Path="src/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj" Id="eb60a3b7-ba9d-48c9-98ad-b28e879b23bf" />
1620
<Project Path="src/CodeBeam.UltimateAuth.Core/CodeBeam.UltimateAuth.Core.csproj" />
1721
<Project Path="src/CodeBeam.UltimateAuth.Server/CodeBeam.UltimateAuth.Server.csproj" Id="0a8cdd12-a8c4-4530-87e8-ae778c46322b" />
18-
<Project Path="src/CodeBeam.UltimateAuth.Users/CodeBeam.UltimateAuth.Server.Users.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
22+
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.Contracts/CodeBeam.UltimateAuth.Credentials.Contracts.csproj" Id="88b70848-fa74-40ea-bf34-3fa2f70f4f37" />
1923
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore/CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.csproj" Id="1fd362d5-864b-4bb3-97be-9095d94cfdba" />
2024
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.InMemory/CodeBeam.UltimateAuth.Credentials.InMemory.csproj" Id="62ee7b1d-46ce-4f2e-985d-1e794f891b8b" />
25+
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.Reference/CodeBeam.UltimateAuth.Credentials.Reference.csproj" Id="ca03a140-f3dc-4a21-9b7d-895a3b10808b" />
26+
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials/CodeBeam.UltimateAuth.Credentials.csproj" Id="2281c3b5-1d60-4542-a673-553f96eed25b" />
27+
<Project Path="src/policies/CodeBeam.UltimateAuth.Policies/CodeBeam.UltimateAuth.Policies.csproj" Id="b37c337f-2446-4f54-8684-b72fa83ac444" />
2128
<Project Path="src/security/CodeBeam.UltimateAuth.Security.Argon2/CodeBeam.UltimateAuth.Security.Argon2.csproj" Id="6abfb7a6-ea36-42db-a843-38054dd40fd8" />
2229
<Project Path="src/sessions/CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore/CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.csproj" Id="5b9a090d-1689-4a81-9dfa-3ba69f0bda38" />
2330
<Project Path="src/sessions/CodeBeam.UltimateAuth.Sessions.InMemory/CodeBeam.UltimateAuth.Sessions.InMemory.csproj" Id="fc9bfef0-8a89-4639-81ee-3f84f6e33816" />
2431
<Project Path="src/tokens/CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore/CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore.csproj" Id="6eb14b32-0b56-460f-a2b2-f95d28bad625" />
2532
<Project Path="src/tokens/CodeBeam.UltimateAuth.Tokens.InMemory/CodeBeam.UltimateAuth.Tokens.InMemory.csproj" Id="8220884e-4958-4b49-8c69-56ce9d2b6c6f" />
33+
<Project Path="src/users/CodeBeam.UltimateAuth.Users.Contracts/CodeBeam.UltimateAuth.Users.Contracts.csproj" Id="3a04f065-8f9d-46b3-9726-1febffe6d46f" />
34+
<Project Path="src/users/CodeBeam.UltimateAuth.Users.InMemory/CodeBeam.UltimateAuth.Users.InMemory.csproj" Id="7ce3df22-4773-4b9b-afd0-8ba506e0f9de" />
35+
<Project Path="src/users/CodeBeam.UltimateAuth.Users.Reference/CodeBeam.UltimateAuth.Users.Reference.csproj" Id="601176dd-b760-4b6f-9cc7-c618134ae178" />
36+
<Project Path="src/users/CodeBeam.UltimateAuth.Users/CodeBeam.UltimateAuth.Users.csproj" Id="30d5db36-6dc8-46f6-9139-8b6b3d6053d5" />
2637
</Solution>

samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net10.0</TargetFramework>
@@ -14,13 +14,21 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.InMemory\CodeBeam.UltimateAuth.Authorization.InMemory.csproj" />
18+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.Reference\CodeBeam.UltimateAuth.Authorization.Reference.csproj" />
19+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization\CodeBeam.UltimateAuth.Authorization.csproj" />
1720
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Client\CodeBeam.UltimateAuth.Client.csproj" />
1821
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Core\CodeBeam.UltimateAuth.Core.csproj" />
1922
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Server\CodeBeam.UltimateAuth.Server.csproj" />
2023
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.InMemory\CodeBeam.UltimateAuth.Credentials.InMemory.csproj" />
24+
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.Reference\CodeBeam.UltimateAuth.Credentials.Reference.csproj" />
25+
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials\CodeBeam.UltimateAuth.Credentials.csproj" />
2126
<ProjectReference Include="..\..\..\src\security\CodeBeam.UltimateAuth.Security.Argon2\CodeBeam.UltimateAuth.Security.Argon2.csproj" />
2227
<ProjectReference Include="..\..\..\src\sessions\CodeBeam.UltimateAuth.Sessions.InMemory\CodeBeam.UltimateAuth.Sessions.InMemory.csproj" />
2328
<ProjectReference Include="..\..\..\src\tokens\CodeBeam.UltimateAuth.Tokens.InMemory\CodeBeam.UltimateAuth.Tokens.InMemory.csproj" />
29+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users.InMemory\CodeBeam.UltimateAuth.Users.InMemory.csproj" />
30+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users.Reference\CodeBeam.UltimateAuth.Users.Reference.csproj" />
31+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users\CodeBeam.UltimateAuth.Users.csproj" />
2432
</ItemGroup>
2533

2634
</Project>

samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/Components/Pages/Home.razor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ private async Task ProgrammaticPkceLogin()
7878

7979
var request = new PkceLoginRequest
8080
{
81-
Identifier = "Admin",
82-
Secret = "Password!",
81+
Identifier = "admin",
82+
Secret = "admin",
8383
AuthorizationCode = credentials?.AuthorizationCode ?? string.Empty,
8484
CodeVerifier = credentials?.CodeVerifier ?? string.Empty,
8585
ReturnUrl = _state?.ReturnUrl ?? string.Empty
8686
};
87-
await UAuthClient.CompletePkceLoginAsync(request);
87+
await UAuthClient.Flows.CompletePkceLoginAsync(request);
8888
}
8989

9090
private async Task StartNewPkceAsync()
9191
{
9292
var returnUrl = await ResolveReturnUrlAsync();
93-
await UAuthClient.BeginPkceAsync(returnUrl);
93+
await UAuthClient.Flows.BeginPkceAsync(returnUrl);
9494
}
9595

9696
private async Task<string> ResolveReturnUrlAsync()

samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/Program.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
using CodeBeam.UltimateAuth.Authorization.InMemory;
2+
using CodeBeam.UltimateAuth.Authorization.InMemory.Extensions;
3+
using CodeBeam.UltimateAuth.Authorization.Reference.Extensions;
14
using CodeBeam.UltimateAuth.Client.Extensions;
2-
using CodeBeam.UltimateAuth.Core.Abstractions;
35
using CodeBeam.UltimateAuth.Core.Domain;
46
using CodeBeam.UltimateAuth.Core.Extensions;
7+
using CodeBeam.UltimateAuth.Core.Infrastructure;
58
using CodeBeam.UltimateAuth.Core.Runtime;
6-
using CodeBeam.UltimateAuth.Credentials.InMemory;
9+
using CodeBeam.UltimateAuth.Credentials.InMemory.Extensions;
10+
using CodeBeam.UltimateAuth.Credentials.Reference;
711
using CodeBeam.UltimateAuth.Sample.UAuthHub.Components;
812
using CodeBeam.UltimateAuth.Security.Argon2;
913
using CodeBeam.UltimateAuth.Server.Authentication;
14+
using CodeBeam.UltimateAuth.Server.Defaults;
1015
using CodeBeam.UltimateAuth.Server.Extensions;
11-
using CodeBeam.UltimateAuth.Server.Infrastructure;
1216
using CodeBeam.UltimateAuth.Sessions.InMemory;
1317
using CodeBeam.UltimateAuth.Tokens.InMemory;
18+
using CodeBeam.UltimateAuth.Users;
19+
using CodeBeam.UltimateAuth.Users.InMemory.Extensions;
20+
using CodeBeam.UltimateAuth.Users.Reference;
21+
using CodeBeam.UltimateAuth.Users.Reference.Extensions;
1422
using MudBlazor.Services;
1523
using MudExtensions.Services;
1624

@@ -46,7 +54,12 @@
4654
//o.Session.TouchInterval = TimeSpan.FromSeconds(9);
4755
//o.Session.IdleTimeout = TimeSpan.FromSeconds(15);
4856
})
49-
.AddInMemoryCredentials()
57+
.AddUltimateAuthUsersInMemory()
58+
.AddUltimateAuthUsersReference()
59+
.AddUltimateAuthCredentialsInMemory()
60+
.AddUltimateAuthCredentialsReference()
61+
.AddUltimateAuthAuthorizationInMemory()
62+
.AddUltimateAuthAuthorizationReference()
5063
.AddUltimateAuthInMemorySessions()
5164
.AddUltimateAuthInMemoryTokens()
5265
.AddUltimateAuthArgon2();
@@ -73,6 +86,19 @@
7386

7487
var app = builder.Build();
7588

89+
using (var scope = app.Services.CreateScope())
90+
{
91+
scope.ServiceProvider.GetRequiredService<IUserLifecycleStore>();
92+
scope.ServiceProvider.GetRequiredService<IUserProfileStore>();
93+
scope.ServiceProvider.GetRequiredService<IUserStore<UserKey>>();
94+
95+
var seeder = scope.ServiceProvider.GetService<IAuthorizationSeeder>();
96+
//if (seeder is not null)
97+
// await seeder.SeedAsync();
98+
99+
100+
}
101+
76102
// Configure the HTTP request pipeline.
77103
if (!app.Environment.IsDevelopment())
78104
{

samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/CodeBeam.UltimateAuth.Sample.BlazorServer.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,28 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
1112
<PackageReference Include="MudBlazor" Version="9.0.0-preview.1" />
1213
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="9.0.0-preview.2" />
14+
<PackageReference Include="Scalar.AspNetCore" Version="2.12.18" />
1315
</ItemGroup>
1416

1517
<ItemGroup>
18+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.InMemory\CodeBeam.UltimateAuth.Authorization.InMemory.csproj" />
19+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.Reference\CodeBeam.UltimateAuth.Authorization.Reference.csproj" />
20+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization\CodeBeam.UltimateAuth.Authorization.csproj" />
1621
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Client\CodeBeam.UltimateAuth.Client.csproj" />
1722
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Core\CodeBeam.UltimateAuth.Core.csproj" />
1823
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Server\CodeBeam.UltimateAuth.Server.csproj" />
24+
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.Reference\CodeBeam.UltimateAuth.Credentials.Reference.csproj" />
25+
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials\CodeBeam.UltimateAuth.Credentials.csproj" />
1926
<ProjectReference Include="..\..\..\src\security\CodeBeam.UltimateAuth.Security.Argon2\CodeBeam.UltimateAuth.Security.Argon2.csproj" />
2027
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.InMemory\CodeBeam.UltimateAuth.Credentials.InMemory.csproj" />
2128
<ProjectReference Include="..\..\..\src\sessions\CodeBeam.UltimateAuth.Sessions.InMemory\CodeBeam.UltimateAuth.Sessions.InMemory.csproj" />
2229
<ProjectReference Include="..\..\..\src\tokens\CodeBeam.UltimateAuth.Tokens.InMemory\CodeBeam.UltimateAuth.Tokens.InMemory.csproj" />
30+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users.InMemory\CodeBeam.UltimateAuth.Users.InMemory.csproj" />
31+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users.Reference\CodeBeam.UltimateAuth.Users.Reference.csproj" />
32+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users\CodeBeam.UltimateAuth.Users.csproj" />
2333
</ItemGroup>
2434

2535
</Project>

samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/Components/Pages/Home.razor

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@inject IClock Clock
1919
@inject IUAuthCookieManager CookieManager
2020
@inject IHttpContextAccessor HttpContextAccessor
21-
@inject IUAuthClient UAuthClient
21+
@inject IUAuthClient UAuth
2222
@inject NavigationManager Nav
2323
@inject IUAuthProductInfoProvider ProductInfo
2424
@inject AuthenticationStateProvider AuthStateProvider
@@ -45,6 +45,8 @@
4545

4646
<MudStack Class="mud-width-full">
4747
<MudButton Variant="Variant.Filled" Color="Color.Info" OnClick="ProgrammaticLogin">Programmatic Login</MudButton>
48+
<MudButton Variant="Variant.Filled" Color="Color.Info" OnClick="HandleGetMe">GetMe</MudButton>
49+
<MudButton Variant="Variant.Filled" Color="Color.Info" OnClick="ChangeUserInactive">Change User Inactive</MudButton>
4850
</MudStack>
4951

5052
<MudStack Spacing="0">
@@ -64,6 +66,12 @@
6466
<MudText>Not Authorized context is shown.</MudText>
6567
</NotAuthorized>
6668
</AuthorizeView>
69+
70+
<AuthorizeView Roles="Admin">
71+
<Authorized>
72+
<MudText>This is Admin content.</MudText>
73+
</Authorized>
74+
</AuthorizeView>
6775
</MudStack>
6876

6977
<MudStack>

samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/Components/Pages/Home.razor.cs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using CodeBeam.UltimateAuth.Client.Device;
33
using CodeBeam.UltimateAuth.Core.Contracts;
44
using CodeBeam.UltimateAuth.Core.Domain;
5+
using CodeBeam.UltimateAuth.Users.Contracts;
56
using Microsoft.AspNetCore.Components.Authorization;
67
using MudBlazor;
78

@@ -41,17 +42,17 @@ private async Task ProgrammaticLogin()
4142
var deviceId = await DeviceIdProvider.GetOrCreateAsync();
4243
var request = new LoginRequest
4344
{
44-
Identifier = "Admin",
45-
Secret = "Password!",
45+
Identifier = "admin",
46+
Secret = "admin",
4647
Device = DeviceContext.FromDeviceId(deviceId),
4748
};
48-
await UAuthClient.LoginAsync(request);
49+
await UAuth.Flows.LoginAsync(request);
4950
_authState = await AuthStateProvider.GetAuthenticationStateAsync();
5051
}
5152

5253
private async Task ValidateAsync()
5354
{
54-
var result = await UAuthClient.ValidateAsync();
55+
var result = await UAuth.Flows.ValidateAsync();
5556

5657
Snackbar.Add(
5758
result.IsValid ? "Session is valid ✅" : $"Session invalid ❌ ({result.State})",
@@ -60,13 +61,45 @@ private async Task ValidateAsync()
6061

6162
private async Task LogoutAsync()
6263
{
63-
await UAuthClient.LogoutAsync();
64+
await UAuth.Flows.LogoutAsync();
6465
Snackbar.Add("Logged out", Severity.Success);
6566
}
6667

6768
private async Task RefreshAsync()
6869
{
69-
await UAuthClient.RefreshAsync();
70+
await UAuth.Flows.RefreshAsync();
71+
}
72+
73+
private async Task HandleGetMe()
74+
{
75+
var profileResult = await UAuth.Users.GetMeAsync();
76+
if (profileResult.Ok)
77+
{
78+
var profile = profileResult.Value;
79+
Snackbar.Add($"User Profile: {profile?.UserName} ({profile?.DisplayName})", Severity.Info);
80+
}
81+
else
82+
{
83+
Snackbar.Add($"Failed to get profile: {profileResult.Error}", Severity.Error);
84+
}
85+
}
86+
87+
private async Task ChangeUserInactive()
88+
{
89+
ChangeUserStatusRequest request = new ChangeUserStatusRequest
90+
{
91+
UserKey = UserKey.FromString("user"),
92+
NewStatus = UserStatus.Disabled
93+
};
94+
var result = await UAuth.Users.ChangeStatusAsync(request);
95+
if (result.Ok)
96+
{
97+
Snackbar.Add($"User is disabled.", Severity.Info);
98+
}
99+
else
100+
{
101+
Snackbar.Add($"Failed to change user status.", Severity.Error);
102+
}
70103
}
71104

72105
protected override void OnAfterRender(bool firstRender)

samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/Program.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1+
using CodeBeam.UltimateAuth.Authorization.InMemory;
2+
using CodeBeam.UltimateAuth.Authorization.InMemory.Extensions;
3+
using CodeBeam.UltimateAuth.Authorization.Reference.Extensions;
14
using CodeBeam.UltimateAuth.Client.Extensions;
25
using CodeBeam.UltimateAuth.Core.Domain;
36
using CodeBeam.UltimateAuth.Core.Extensions;
4-
using CodeBeam.UltimateAuth.Credentials.InMemory;
7+
using CodeBeam.UltimateAuth.Credentials.InMemory.Extensions;
8+
using CodeBeam.UltimateAuth.Credentials.Reference;
59
using CodeBeam.UltimateAuth.Sample.BlazorServer.Components;
610
using CodeBeam.UltimateAuth.Security.Argon2;
711
using CodeBeam.UltimateAuth.Server.Authentication;
12+
using CodeBeam.UltimateAuth.Server.Defaults;
813
using CodeBeam.UltimateAuth.Server.Extensions;
914
using CodeBeam.UltimateAuth.Sessions.InMemory;
1015
using CodeBeam.UltimateAuth.Tokens.InMemory;
16+
using CodeBeam.UltimateAuth.Users.InMemory.Extensions;
17+
using CodeBeam.UltimateAuth.Users.Reference;
18+
using CodeBeam.UltimateAuth.Users.Reference.Extensions;
1119
using Microsoft.AspNetCore.Components;
1220
using MudBlazor.Services;
1321
using MudExtensions.Services;
22+
using Scalar.AspNetCore;
1423

1524
var builder = WebApplication.CreateBuilder(args);
1625

@@ -24,6 +33,8 @@
2433

2534
builder.Services.AddMudServices();
2635
builder.Services.AddMudExtensions();
36+
builder.Services.AddEndpointsApiExplorer();
37+
builder.Services.AddOpenApi();
2738

2839
builder.Services
2940
.AddAuthentication(options =>
@@ -44,7 +55,12 @@
4455
//o.Session.TouchInterval = TimeSpan.FromSeconds(9);
4556
//o.Session.IdleTimeout = TimeSpan.FromSeconds(15);
4657
})
47-
.AddInMemoryCredentials()
58+
.AddUltimateAuthUsersInMemory()
59+
.AddUltimateAuthUsersReference()
60+
.AddUltimateAuthCredentialsInMemory()
61+
.AddUltimateAuthCredentialsReference()
62+
.AddUltimateAuthAuthorizationInMemory()
63+
.AddUltimateAuthAuthorizationReference()
4864
.AddUltimateAuthInMemorySessions()
4965
.AddUltimateAuthInMemoryTokens()
5066
.AddUltimateAuthArgon2();
@@ -80,13 +96,29 @@
8096

8197
var app = builder.Build();
8298

99+
using (var scope = app.Services.CreateScope())
100+
{
101+
scope.ServiceProvider.GetRequiredService<IUserLifecycleStore>();
102+
//scope.ServiceProvider.GetRequiredService<IUserProfileStore>();
103+
//scope.ServiceProvider.GetRequiredService<IUserStore<UserKey>>();
104+
105+
var seeder = scope.ServiceProvider.GetService<IAuthorizationSeeder>();
106+
//if (seeder is not null)
107+
// await seeder.SeedAsync();
108+
}
109+
83110
// Configure the HTTP request pipeline.
84111
if (!app.Environment.IsDevelopment())
85112
{
86113
app.UseExceptionHandler("/Error", createScopeForErrors: true);
87114
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
88115
app.UseHsts();
89116
}
117+
else
118+
{
119+
app.MapOpenApi();
120+
app.MapScalarApiReference();
121+
}
90122

91123
app.UseHttpsRedirection();
92124

samples/blazor-standalone-wasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20+
<ProjectReference Include="..\..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.Contracts\CodeBeam.UltimateAuth.Authorization.Contracts.csproj" />
2021
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Client\CodeBeam.UltimateAuth.Client.csproj" />
2122
<ProjectReference Include="..\..\..\src\CodeBeam.UltimateAuth.Core\CodeBeam.UltimateAuth.Core.csproj" />
23+
<ProjectReference Include="..\..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.Contracts\CodeBeam.UltimateAuth.Credentials.Contracts.csproj" />
24+
<ProjectReference Include="..\..\..\src\users\CodeBeam.UltimateAuth.Users.Contracts\CodeBeam.UltimateAuth.Users.Contracts.csproj" />
2225
</ItemGroup>
2326

2427
</Project>

samples/blazor-standalone-wasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm/Pages/Home.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
<MudText>Not Authorized context is shown.</MudText>
6060
</NotAuthorized>
6161
</AuthorizeView>
62+
63+
<AuthorizeView Roles="Admin">
64+
<MudText>This is Admin content.</MudText>
65+
</AuthorizeView>
6266
</MudStack>
6367

6468
<MudStack>

0 commit comments

Comments
 (0)