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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# BUILD
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:11.0 AS build
WORKDIR /src

ENV CI=true

COPY docs/website/CodeBeam.UltimateAuth.Docs.Wasm/CodeBeam.UltimateAuth.Docs.Wasm/*.csproj CodeBeam.Website/
COPY docs/website/CodeBeam.UltimateAuth.Docs.Wasm/CodeBeam.UltimateAuth.Docs.Wasm.Client/*.csproj CodeBeam.Website.Client/

RUN dotnet restore CodeBeam.Website/CodeBeam.UltimateAuth.Docs.Wasm.csproj -p:UltimateAuthBuildTargetFrameworks=net10.0
RUN dotnet restore CodeBeam.Website/CodeBeam.UltimateAuth.Docs.Wasm.csproj -p:UltimateAuthBuildTargetFrameworks=net11.0

COPY . .

RUN dotnet publish docs/website/CodeBeam.UltimateAuth.Docs.Wasm/CodeBeam.UltimateAuth.Docs.Wasm/CodeBeam.UltimateAuth.Docs.Wasm.csproj \
-c Release -p:UltimateAuthBuildTargetFrameworks=net10.0 -o /app/publish
-c Release -p:UltimateAuthBuildTargetFrameworks=net11.0 -o /app/publish

# RUNTIME
FROM mcr.microsoft.com/dotnet/aspnet:10.0
FROM mcr.microsoft.com/dotnet/aspnet:11.0
WORKDIR /app

COPY --from=build /app/publish .
Expand Down
8 changes: 4 additions & 4 deletions .docker/Dockerfile.identitylab
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:11.0 AS build
WORKDIR /src

COPY . .

RUN dotnet restore \
apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/CodeBeam.UltimateAuth.IdentityLab.csproj \
-p:UltimateAuthBuildTargetFrameworks=net10.0
-p:UltimateAuthBuildTargetFrameworks=net11.0

RUN dotnet publish \
apps/identity-lab/CodeBeam.UltimateAuth.IdentityLab/CodeBeam.UltimateAuth.IdentityLab.csproj \
-c Release \
-p:UltimateAuthBuildTargetFrameworks=net10.0 \
-p:UltimateAuthBuildTargetFrameworks=net11.0 \
--no-restore \
-o /app/publish

# Runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:11.0 AS runtime
WORKDIR /app

ENV ASPNETCORE_HTTP_PORTS=8080
Expand Down
3 changes: 3 additions & 0 deletions .docker/docker-compose.identitylab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ services:
LabAdmin__Email: ${LAB_ADMIN_EMAIL:?Admin email is required}
LabAdmin__Password: ${LAB_ADMIN_PASSWORD:?Admin password is required}

UltimateAuth__Cryptography__TokenHashingKey: ${ULTIMATEAUTH_TOKEN_HASHING_KEY:?Token hashing key is required}
UltimateAuth__Cryptography__JwtSigningKey: ${ULTIMATEAUTH_JWT_SIGNING_KEY:?JWT signing key is required}

DataProtection__KeysPath: /app/keys

volumes:
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/ultimateauth-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,10 @@ jobs:
output.write("|---|---:|\n")
output.write(f"| Lines | {line_rate:.2%} |\n")
output.write(f"| Branches | {branch_rate:.2%} |\n")
output.write(
f"| Covered lines | {lines_covered:,} / {lines_valid:,} |\n"
)
output.write(
f"| Covered branches | {branches_covered:,} / {branches_valid:,} |\n"
)
output.write(f"| Covered lines | {lines_covered:,} / {lines_valid:,} |\n")
output.write(f"| Covered branches | {branches_covered:,} / {branches_valid:,} |\n")
output.write("\n")
output.write(
"Coverage is reported separately from UltimateAuth "
"framework coverage.\n"
)
output.write("Coverage is reported separately from UltimateAuth framework coverage.\n")
PY

- name: Upload Identity Lab test and coverage results
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project>
<PropertyGroup>
<!-- Keep this list in ascending version order; the last entry drives regular tests. -->
<UltimateAuthTargetFrameworks>net8.0;net9.0;net10.0</UltimateAuthTargetFrameworks>
<UltimateAuthTargetFrameworks>net8.0;net9.0;net10.0;net11.0</UltimateAuthTargetFrameworks>
<UltimateAuthLatestTargetFramework>$([System.Text.RegularExpressions.Regex]::Match('$(UltimateAuthTargetFrameworks)', '[^;]+$').Value)</UltimateAuthLatestTargetFramework>
<!-- CI may build a supported subset without retargeting single-target applications. -->
<UltimateAuthBuildTargetFrameworks Condition="'$(UltimateAuthBuildTargetFrameworks)' == ''">$(UltimateAuthTargetFrameworks)</UltimateAuthBuildTargetFrameworks>

<Version>0.2.0-preview.3</Version>
<Version>0.2.0-preview.4</Version>
<NoWarn>$(NoWarn);1591</NoWarn>

<Authors>CodeBeam</Authors>
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ UltimateAuth eliminates fragmentation by handling client differences internally

Built-in capabilities designed for real-world scenarios:

- Automatic client profile detection (blazor server - WASM - MAUI)
- Automatic application profile detection (blazor server - WASM - MAUI)
- Selectable authentication modes (Session / Token / Hybrid / SemiHybrid)
- Device-aware sessions
- PKCE flows out of the box
Expand Down Expand Up @@ -251,6 +251,32 @@ Change `Components/Pages/Home.razor`:
<p>Welcome, @AuthState?.Identity?.DisplayName!</p>
```

### Note: Cryptographic Key Configuration

UltimateAuth provides development-only cryptographic defaults for local testing. Applications can run without explicitly configuring keys in development, but **production deployments require securely configured cryptographic keys**.

Generate independent, cryptographically secure keys (at least 32 random bytes each, Base64-encoded) and store them using environment variables or a trusted secret manager.

```csharp
builder.Services.AddUltimateAuthServer(options =>
{
options.Cryptography.TokenHashingKey =
builder.Configuration["UltimateAuth:Cryptography:TokenHashingKey"]
?? throw new InvalidOperationException("Token hashing key is missing.");

options.Cryptography.JwtSigningKey =
builder.Configuration["UltimateAuth:Cryptography:JwtSigningKey"]
?? throw new InvalidOperationException("JWT signing key is missing.");
});
```

- **TokenHashingKey:** Protects server-managed token hashes, including opaque and refresh-token material.
- **JwtSigningKey:** Signs JWT access tokens for JWT-enabled authentication modes.

Never use development keys in production, commit cryptographic secrets to source control, or reuse the same key for both purposes.

For detailed configuration instructions, see the [QuickStart](https://ultimateauth.com/docs/getting-started/quickstart) and [Real-World Setup](https://ultimateauth.com/docs/getting-started/real-world-setup) guides.

The examples above provide a simplified overview of UltimateAuth integration and are not intended to be a complete, copy-paste-ready application.

For a **complete, step-by-step setup with all required configuration, components, and sample data**, follow the full Quick Start guide.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net11.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
Expand All @@ -10,14 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="9.3.0" />
<PackageReference Include="MudBlazor" Version="9.12.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.14">
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="9.14.0" />
<PackageReference Include="MudBlazor" Version="9.14.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="11.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="11.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.14">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="11.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@inject IUAuthClient UAuthClient
@inject IDialogService DialogService
@inject ISnackbar Snackbar
@inject LabSessionDiagnosticsPolicyService PolicyService
@inject NavigationManager Navigation

@attribute [UAuthAuthorize(Roles = "Ladmin,Owner,User")]
Expand Down Expand Up @@ -64,6 +65,58 @@
OnClick="LogoutOthersAsync">Logout Other Sessions</MudButton>
</div>

<MudPaper Outlined="true" Class="pa-5 mb-4">
<MudStack Spacing="3">
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
<MudText Typo="Typo.h6">
Device Limits
</MudText>

<MudChip T="string" Size="Size.Small" Color="Color.Success" Variant="Variant.Outlined">
Configured
</MudChip>
</MudStack>

<MudGrid Spacing="3">
<MudItem xs="12" sm="6">
<MudText Typo="Typo.caption" Color="Color.Secondary">
MAXIMUM DEVICES
</MudText>

<MudText Typo="Typo.h4">
@MaxDevicesText
</MudText>

<LabOptionInfo Title="Maximum Devices" OptionPath="o.DeviceLimits.MaxDevices" CurrentValue="@MaxDevicesText" Description="Maximum number of distinct active devices per user." />
</MudItem>

<MudItem xs="12" sm="6">
<MudText Typo="Typo.caption" Color="Color.Secondary">
WEB DEVICE LIMIT
</MudText>

<MudText Typo="Typo.h4">
@WebDeviceLimitText
</MudText>

<LabOptionInfo Title="Web Device Limit" OptionPath="o.DeviceLimits.TypeLimits[&quot;web&quot;]" CurrentValue="@WebDeviceLimitText" Description="Maximum number of distinct active web devices." />
</MudItem>
</MudGrid>

<MudDivider />

<MudText Typo="Typo.body2">
Limit behavior:
<strong>@_devicePolicy?.DeviceLimitBehavior</strong>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
Limits apply to distinct active device identities,
not the number of sessions.
</MudText>
</MudStack>
</MudPaper>

@* TODO (SDK): Provide direct current-chain lookup without scanning pages. *@
@if (_currentChain is not null)
Expand Down Expand Up @@ -106,21 +159,13 @@
</div>
</div>

<MudButton Variant="Variant.Outlined"
Color="Color.Primary"
Size="Size.Small"
Disabled="@_busy"
OnClick="@(() => OpenSessionManagementAsync(_currentChain.ChainId))">
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Size="Size.Small" Disabled="@_busy" OnClick="@(() => OpenSessionManagementAsync(_currentChain.ChainId))">
Details
</MudButton>

@if (!_currentChain.IsRevoked)
{
<MudButton Variant="Variant.Outlined"
Color="Color.Error"
Size="Size.Small"
Disabled="@_busy"
OnClick="@(() => LogoutAsync(_currentChain))">
<MudButton Variant="Variant.Outlined" Color="Color.Error" Size="Size.Small" Disabled="@_busy" OnClick="@(() => LogoutAsync(_currentChain))">
Logout
</MudButton>
}
Expand All @@ -129,10 +174,7 @@
}
else if (!_loading && _error is null)
{
<MudButton Variant="Variant.Text"
Color="Color.Primary"
Disabled="@_busy"
OnClick="FindCurrentChainAsync">
<MudButton Variant="Variant.Text" Color="Color.Primary" Disabled="@_busy" OnClick="FindCurrentChainAsync">
Locate Current Device
</MudButton>
}
Expand Down Expand Up @@ -332,8 +374,17 @@
private int _treeVisibleCount = 4;
private int TotalPages => Math.Max(1, (_totalChains + PageSize - 1) / PageSize);
private const int PageSize = 20;
private LabSessionDiagnosticsPolicy? _devicePolicy;

protected override async Task OnInitializedAsync() => await LoadAsync();
private string MaxDevicesText => _devicePolicy?.MaxDevices?.ToString() ?? "Unlimited";

private string WebDeviceLimitText => _devicePolicy?.DeviceTypeLimits.TryGetValue("web", out var limit) == true ? limit.ToString() : "Unlimited";

protected override async Task OnInitializedAsync()
{
_devicePolicy = PolicyService.Get();
await LoadAsync();
}

private async Task RefreshAsync()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/login"
@layout PublicLayout
@inherits UAuthPageBase
@inject IUAuthClient UAuthClient
@inject IOptions<UAuthServerOptions> Options
@inject NavigationManager NavigationManager
Expand Down Expand Up @@ -132,7 +133,7 @@
{
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Icon="@Icons.Material.Filled.Shield" Class="mb-2">
<MudStack Spacing="2">
<MudText Typo="Typo.subtitle2">Incorrect credentials</MudText>
<MudText Typo="Typo.subtitle2">@(_loginError?.StartsWith("Device limit reached.") == true ? "Device limit reached" : "Sign-in failed")</MudText>
<MudText Typo="Typo.body2">@_loginError</MudText>

@if (_remainingAttempts is { } remaining)
Expand Down Expand Up @@ -278,9 +279,6 @@
</div>

@code {
[CascadingParameter]
private UAuthState AuthState { get; set; } = default!;

private string _identifier = string.Empty;
private string _password = string.Empty;
private string? _loginError;
Expand Down Expand Up @@ -386,7 +384,13 @@
return;
}

_loginError = "Please check your email or username and password.";
_loginError = result.Reason switch
{
AuthFailureReason.DeviceLimitExceeded =>
"Device limit reached. Sign out from another device before signing in.",

_ => "Please check your email or username and password."
};
}

private void StartLockoutTimer()
Expand Down Expand Up @@ -478,8 +482,33 @@
}
}

public void Dispose()
protected override Task OnUAuthPayloadAsync(AuthFlowPayload payload)
{
if (payload.Flow != AuthFlowType.Login ||
payload.Status != "failed")
{
return Task.CompletedTask;
}

StopLockoutTimer();

_remainingAttempts = null;
_lockoutUntilUtc = null;

_loginError = payload.Reason switch
{
AuthFailureReason.DeviceLimitExceeded =>
"Device limit reached. Sign out from another device before signing in.",

AuthFailureReason.InvalidCredentials =>
"Please check your email or username and password.",

AuthFailureReason.LockedOut =>
"Your account is temporarily locked.",

_ => "Unable to sign in. Please try again."
};

return InvokeAsync(StateHasChanged);
}
}
Loading
Loading