Skip to content

Commit 8256d65

Browse files
authored
Update 0.1.0-rc.1 (#45)
1 parent b86616f commit 8256d65

11 files changed

Lines changed: 118 additions & 23 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*.userosscache
1111
*.sln.docstates
1212

13+
*.db-shm
14+
*.db-wal
15+
1316
# User-specific files (MonoDevelop/Xamarin Studio)
1417
*.userprefs
1518

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.1.0-preview.2</Version>
3+
<Version>0.1.0-rc.1</Version>
44
<NoWarn>$(NoWarn);1591</NoWarn>
55

66
<Authors>CodeBeam</Authors>

docs/content/getting-started/quickstart.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In this guide, you will set up UltimateAuth in a few minutes and perform your **
1212

1313
## 1. Create a Project
1414

15-
Create a new Blazor Server web app:
15+
Start by creating a new Blazor app:
1616

1717
```bash
1818
dotnet new blazorserver -n UltimateAuthDemo
@@ -21,7 +21,7 @@ cd UltimateAuthDemo
2121

2222
## 2. Install Packages
2323

24-
Add UltimateAuth packages:
24+
Install the required UltimateAuth packages:
2525

2626
```csharp
2727
dotnet add package CodeBeam.UltimateAuth.Server
@@ -69,7 +69,46 @@ Replace `Routes.razor` with this code:
6969
<UAuthApp UseBuiltInRouter="true" AppAssembly="typeof(Program).Assembly" DefaultLayout="typeof(Layout.MainLayout)" />
7070
```
7171

72-
## 8. Perform Your First Login
72+
## 8. Recommended Setup (Optional)
73+
Add these for better experience:
74+
75+
For login page (Use this only once in your application)
76+
```csharp
77+
@attribute [UAuthLoginPage]
78+
```
79+
80+
For protected pages
81+
```csharp
82+
@attribute [UAuthAuthorize]
83+
```
84+
85+
For any page that you use UltimateAuth features like AuthState etc.
86+
```csharp
87+
@inherits UAuthFlowPageBase
88+
```
89+
90+
## 9. Seed Data For QuickStart (Optional)
91+
This code creates admin and user users with same password and admin role.
92+
93+
For in memory
94+
```csharp
95+
builder.Services.AddUltimateAuthSampleSeed();
96+
```
97+
98+
For entity framework core:
99+
```csharp
100+
builder.Services.AddScopedUltimateAuthSampleSeed();
101+
```
102+
103+
In pipeline configuration
104+
```csharp
105+
if (app.Environment.IsDevelopment())
106+
{
107+
await app.SeedUltimateAuthAsync();
108+
}
109+
```
110+
111+
## 10. Perform Your First Login
73112
Example using IUAuthClient:
74113
```csharp
75114
[Inject] IUAuthClient UAuthClient { get; set; } = null!;
@@ -78,8 +117,8 @@ private async Task Login()
78117
{
79118
await UAuthClient.Flows.LoginAsync(new LoginRequest
80119
{
81-
Identifier = "demo",
82-
Secret = "password"
120+
Identifier = "admin",
121+
Secret = "admin"
83122
});
84123
}
85124
```

docs/content/getting-started/real-world-setup.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ builder.Services.AddUltimateAuthServer(o => {
6565
});
6666
```
6767

68-
## Blazor WASM Setup
68+
## Blazor Standalone WASM Setup
6969
Blazor WASM applications run entirely on the client and cannot securely handle credentials.
7070
For this reason, UltimateAuth uses a dedicated Auth server called **UAuthHub**.
7171

@@ -91,6 +91,42 @@ app.MapUltimateAuthEndpoints();
9191
app.MapUAuthHub();
9292
```
9393

94+
## Blazor Web App Setup
95+
A blazor web app contains two projects that includes host and client. You need to arrange them both.
96+
97+
In the host project:
98+
```csharp
99+
builder.Services.AddUltimateAuthClientBlazor(o =>
100+
{
101+
o.Endpoints.BasePath = "https://localhost:6112/auth"; // UAuthHub URL
102+
o.Pkce.ReturnUrl = "https://localhost:6132/home"; // Current application domain + path
103+
});
104+
105+
// In pipeline configuration
106+
app.MapRazorComponents<App>()
107+
.AddInteractiveWebAssemblyRenderMode()
108+
.AddAdditionalAssemblies(UAuthAssemblies.BlazorClient().First());
109+
```
110+
111+
In the client project:
112+
```csharp
113+
builder.Services.AddUltimateAuthClientBlazor(o =>
114+
{
115+
o.Endpoints.BasePath = "https://localhost:6112/auth"; // UAuthHub URL
116+
o.Pkce.ReturnUrl = "https://localhost:6132/home"; // Current application domain + path
117+
});
118+
119+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
120+
121+
// Optional if you use external API calls in your client project.
122+
builder.Services.AddHttpClient("resourceApi", client =>
123+
{
124+
client.BaseAddress = new Uri("https://localhost:6122");
125+
});
126+
```
127+
128+
> If you want to use embedded UAuthHub in host project, you can register server services as shown in quickstart.
129+
94130
> ℹ️ UltimateAuth automatically selects the appropriate authentication mode (PureOpaque, Hybrid, etc.) based on the client type.
95131
96132
## ResourceApi Setup
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
5+
<NoWarn>$(NoWarn);1591</NoWarn>
6+
<PackageId>CodeBeam.UltimateAuth.Sample.Seed</PackageId>
7+
8+
<Description>Minimal seeded data for UltimateAuth samples and quickstart projects.</Description>
9+
10+
<PackageTags>authentication;session;identity;auth-framework;seed;data</PackageTags>
11+
<PackageIcon>uauthlogo.png</PackageIcon>
712
</PropertyGroup>
813

914
<ItemGroup>
1015
<ProjectReference Include="..\..\src\bundle\CodeBeam.UltimateAuth.Reference.Bundle\CodeBeam.UltimateAuth.Reference.Bundle.csproj" />
1116
</ItemGroup>
1217

18+
<ItemGroup>
19+
<None Include="uauthlogo.png" Pack="true" PackagePath="\" />
20+
</ItemGroup>
21+
1322
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using CodeBeam.UltimateAuth.Core.Infrastructure;
4+
using CodeBeam.UltimateAuth.Core.MultiTenancy;
5+
6+
namespace CodeBeam.UltimateAuth.Sample.Seed.Extensions;
7+
8+
public static class UAuthSeedExtensions
9+
{
10+
public static async Task SeedUltimateAuthAsync(this WebApplication app, TenantKey? tenant = null, CancellationToken ct = default)
11+
{
12+
using var scope = app.Services.CreateScope();
13+
var runner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
14+
await runner.RunAsync(tenant, ct);
15+
}
16+
}
4.84 KB
Loading

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@
7171
using (var scope = app.Services.CreateScope())
7272
{
7373
await UAuthDbInitializer.InitializeAsync(app.Services, reset: true);
74-
75-
var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
76-
await seedRunner.RunAsync(null);
7774
}
75+
76+
await app.SeedUltimateAuthAsync();
7877
}
7978

8079
app.UseHttpsRedirection();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@
6363
app.MapOpenApi();
6464
app.MapScalarApiReference();
6565

66-
using var scope = app.Services.CreateScope();
67-
var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
68-
await seedRunner.RunAsync(null);
66+
await app.SeedUltimateAuthAsync();
6967
}
7068

7169
app.UseHttpsRedirection();

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,9 @@
8989
using (var scope = app.Services.CreateScope())
9090
{
9191
await UAuthDbInitializer.InitializeAsync(app.Services, reset: true);
92-
93-
var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
94-
await seedRunner.RunAsync(null);
9592
}
93+
await app.SeedUltimateAuthAsync();
9694
}
97-
9895
app.UseForwardedHeaders();
9996

10097
app.UseHttpsRedirection();

0 commit comments

Comments
 (0)