Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*.userosscache
*.sln.docstates

*.db-shm
*.db-wal

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.1.0-preview.2</Version>
<Version>0.1.0-rc.1</Version>
<NoWarn>$(NoWarn);1591</NoWarn>

<Authors>CodeBeam</Authors>
Expand Down
49 changes: 44 additions & 5 deletions docs/content/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In this guide, you will set up UltimateAuth in a few minutes and perform your **

## 1. Create a Project

Create a new Blazor Server web app:
Start by creating a new Blazor app:

```bash
dotnet new blazorserver -n UltimateAuthDemo
Expand All @@ -21,7 +21,7 @@ cd UltimateAuthDemo

## 2. Install Packages

Add UltimateAuth packages:
Install the required UltimateAuth packages:

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

## 8. Perform Your First Login
## 8. Recommended Setup (Optional)
Add these for better experience:

For login page (Use this only once in your application)
```csharp
@attribute [UAuthLoginPage]
```

For protected pages
```csharp
@attribute [UAuthAuthorize]
```

For any page that you use UltimateAuth features like AuthState etc.
```csharp
@inherits UAuthFlowPageBase
```

## 9. Seed Data For QuickStart (Optional)
This code creates admin and user users with same password and admin role.

For in memory
```csharp
builder.Services.AddUltimateAuthSampleSeed();
```

For entity framework core:
```csharp
builder.Services.AddScopedUltimateAuthSampleSeed();
```

In pipeline configuration
```csharp
if (app.Environment.IsDevelopment())
{
await app.SeedUltimateAuthAsync();
}
```

## 10. Perform Your First Login
Example using IUAuthClient:
```csharp
[Inject] IUAuthClient UAuthClient { get; set; } = null!;
Expand All @@ -78,8 +117,8 @@ private async Task Login()
{
await UAuthClient.Flows.LoginAsync(new LoginRequest
{
Identifier = "demo",
Secret = "password"
Identifier = "admin",
Secret = "admin"
});
}
```
Expand Down
38 changes: 37 additions & 1 deletion docs/content/getting-started/real-world-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ builder.Services.AddUltimateAuthServer(o => {
});
```

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

Expand All @@ -91,6 +91,42 @@ app.MapUltimateAuthEndpoints();
app.MapUAuthHub();
```

## Blazor Web App Setup
A blazor web app contains two projects that includes host and client. You need to arrange them both.

In the host project:
```csharp
builder.Services.AddUltimateAuthClientBlazor(o =>
{
o.Endpoints.BasePath = "https://localhost:6112/auth"; // UAuthHub URL
o.Pkce.ReturnUrl = "https://localhost:6132/home"; // Current application domain + path
});

// In pipeline configuration
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(UAuthAssemblies.BlazorClient().First());
```

In the client project:
```csharp
builder.Services.AddUltimateAuthClientBlazor(o =>
{
o.Endpoints.BasePath = "https://localhost:6112/auth"; // UAuthHub URL
o.Pkce.ReturnUrl = "https://localhost:6132/home"; // Current application domain + path
});

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

// Optional if you use external API calls in your client project.
builder.Services.AddHttpClient("resourceApi", client =>
{
client.BaseAddress = new Uri("https://localhost:6122");
});
```

> If you want to use embedded UAuthHub in host project, you can register server services as shown in quickstart.

> ℹ️ UltimateAuth automatically selects the appropriate authentication mode (PureOpaque, Hybrid, etc.) based on the client type.

## ResourceApi Setup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<NoWarn>$(NoWarn);1591</NoWarn>
<PackageId>CodeBeam.UltimateAuth.Sample.Seed</PackageId>

<Description>Minimal seeded data for UltimateAuth samples and quickstart projects.</Description>

<PackageTags>authentication;session;identity;auth-framework;seed;data</PackageTags>
<PackageIcon>uauthlogo.png</PackageIcon>
</PropertyGroup>

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

<ItemGroup>
<None Include="uauthlogo.png" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using CodeBeam.UltimateAuth.Core.Infrastructure;
using CodeBeam.UltimateAuth.Core.MultiTenancy;

namespace CodeBeam.UltimateAuth.Sample.Seed.Extensions;

public static class UAuthSeedExtensions
{
public static async Task SeedUltimateAuthAsync(this WebApplication app, TenantKey? tenant = null, CancellationToken ct = default)
{
using var scope = app.Services.CreateScope();
var runner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
await runner.RunAsync(tenant, ct);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@
using (var scope = app.Services.CreateScope())
{
await UAuthDbInitializer.InitializeAsync(app.Services, reset: true);

var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
await seedRunner.RunAsync(null);
}

await app.SeedUltimateAuthAsync();
}

app.UseHttpsRedirection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@
app.MapOpenApi();
app.MapScalarApiReference();

using var scope = app.Services.CreateScope();
var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
await seedRunner.RunAsync(null);
await app.SeedUltimateAuthAsync();
}

app.UseHttpsRedirection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,9 @@
using (var scope = app.Services.CreateScope())
{
await UAuthDbInitializer.InitializeAsync(app.Services, reset: true);

var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
await seedRunner.RunAsync(null);
}
await app.SeedUltimateAuthAsync();
}

app.UseForwardedHeaders();

app.UseHttpsRedirection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
app.MapOpenApi();
app.MapScalarApiReference();

using var scope = app.Services.CreateScope();
var seedRunner = scope.ServiceProvider.GetRequiredService<SeedRunner>();
await seedRunner.RunAsync(null);
await app.SeedUltimateAuthAsync();
}

app.UseForwardedHeaders();
Expand Down
Loading