Lyo.Authentication.Web.Components.Wasm
1.0.1
dotnet add package Lyo.Authentication.Web.Components.Wasm --version 1.0.1
NuGet\Install-Package Lyo.Authentication.Web.Components.Wasm -Version 1.0.1
<PackageReference Include="Lyo.Authentication.Web.Components.Wasm" Version="1.0.1" />
<PackageVersion Include="Lyo.Authentication.Web.Components.Wasm" Version="1.0.1" />
<PackageReference Include="Lyo.Authentication.Web.Components.Wasm" />
paket add Lyo.Authentication.Web.Components.Wasm --version 1.0.1
#r "nuget: Lyo.Authentication.Web.Components.Wasm, 1.0.1"
#:package Lyo.Authentication.Web.Components.Wasm@1.0.1
#addin nuget:?package=Lyo.Authentication.Web.Components.Wasm&version=1.0.1
#tool nuget:?package=Lyo.Authentication.Web.Components.Wasm&version=1.0.1
Lyo.Authentication.Web.Components.Wasm
Blazor WebAssembly host adapter for Lyo.Authentication.Web.Components. Implements the same login / debug / profile pages over a pure-browser auth flow — no consumer-side server, no HttpOnly cookie. Tokens live in Blazored.LocalStorage and the browser talks directly to the Lyo API.
Examples
Quick start
builder.Services.AddLyoAuthWebComponents(builder.Configuration);
builder.Services.AddLyoAuthWebComponentsWasm(builder.Configuration);
Quick start (2)
{
"LyoAuthWebComponents": {
"Providers": [
{ "Name": "google", "DisplayName": "Sign in with Google", "IconKey": "Icons.Material.Filled.Google" },
{ "Name": "keycloak:my-realm", "DisplayName": "Sign in with Keycloak", "IconKey": "Icons.Material.Filled.Lock" }
]
},
"LyoAuthWasmClient": {
"AuthBaseUrl": "https://api.example.com",
"HandoffCallbackPath": "/auth/handoff",
"PostSignOutRedirectPath": "/",
"StorageKey": "lyo_auth_session",
"AccessTokenSkew": "00:00:30"
}
}
Quick start (3)
{
"LyoOidcBff": {
"AllowedReturnOrigins": [ "https://spa.example.com" ],
"DefaultReturnUrl": "/",
"HandoffCodeTtl": "00:00:30"
}
}
Flow
browser SPA ── click "Sign in with X" ──► WasmAuthSignInLauncher
│
▼
browser ── GET /auth/login/{provider}?returnUrl=https://spa/auth/handoff&mode=browser ──► API
│
(IdP roundtrip) ▼
browser ── 302 https://spa/auth/handoff?lyo_handoff=lyoh_... ──► WasmAuthHandoffPage
│
▼
browser ── POST /auth/handoff/exchange { code } ──► API
│
▼
{ access_token, refresh_token, expires_in } ──► WasmAuthSessionStore (in-mem + LocalStorage)
What's inside
| Service | Role |
|---|---|
WasmAuthClientOptions |
AuthBaseUrl, HandoffCallbackPath (default /auth/handoff), StorageKey, AccessTokenSkew. |
WasmAuthSessionStore |
Singleton store with in-memory cache + Blazored.LocalStorage snapshot. Survives page reloads inside the SPA. |
WasmAuthApiClient |
Typed HttpClient for /auth/handoff/exchange, /auth/refresh, /auth/logout. |
WasmAuthDelegatingHandler |
Outbound bearer-injection + auto-refresh handler for any user HttpClient. |
WasmAuthStateProvider |
Blazor AuthenticationStateProvider that re-runs LyoJwtClaimsParser over the cached access token. |
WasmAuthSignInLauncher |
IAuthSignInLauncher implementation. Sign-in 302s to the API; sign-out revokes the refresh token and clears local state. |
WasmAuthUserClient |
IAuthUserClient implementation against /auth/me and /auth/users/{id}. |
WasmAuthSessionAccessor |
IAuthSessionAccessor implementation used by the debug page. |
Pages/WasmAuthHandoffPage |
Route /auth/handoff — redeems the ?lyo_handoff=... code and stores the tokens. |
Quick start
In the consuming WASM host's Program.cs: appsettings.json (served from the WASM client's wwwroot/): On the API side, the WASM origin must appear in LyoOidcBff.AllowedReturnOrigins:
Outbound API calls
Add the delegating handler to any of your own typed clients so they automatically carry the bearer:
builder.Services
.AddHttpClient<MyApi>(c => c.BaseAddress = new("https://api.example.com"))
.AddHttpMessageHandler<WasmAuthDelegatingHandler>();
Caveats vs. the Server adapter
- Tokens live in LocalStorage on the browser. That's the standard SPA trade-off; XSS hijacks the session. If you can't accept that, use the Server (BFF) adapter instead, which stores tokens server-side and only puts a data-protected session id in the cookie.
- No cross-tab broadcast: a sign-out in one tab doesn't drop the session in another. (Possible follow-up via the LocalStorage
storageevent.) - The handoff exchange happens in the browser (
fetch), so the WASM origin must be in the API's allow-list.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Authentication.Web.Components— (direct, lyo)Lyo.Diagnostic— (direct, lyo)Blazored.LocalStorage4.5.0— (direct, third-party)Microsoft.AspNetCore.Components.WebAssembly10.0.5— (direct, microsoft)Lyo.Api.Client— (transitive, lyo)Lyo.Api.Models— (transitive, lyo)Lyo.Authentication.Models— (transitive, lyo)Lyo.Common— (transitive, lyo)Lyo.DataTable.Models— (transitive, lyo)Lyo.DateAndTime— (transitive, lyo)Lyo.Encryption— (transitive, lyo)Lyo.Exceptions— (transitive, lyo)Lyo.Hashing— (transitive, lyo)Lyo.IO.Temp— (transitive, lyo)Lyo.KeyStore— (transitive, lyo)Lyo.Metrics— (transitive, lyo)Lyo.PackageMetadata— (transitive, lyo)Lyo.Query.Models— (transitive, lyo)Lyo.Result— (transitive, lyo)Lyo.Streams— (transitive, lyo)Lyo.Validation— (transitive, lyo)Lyo.Web.Components— (transitive, lyo)BouncyCastle.Cryptography2.6.2— (transitive, third-party, netstandard2.0)Konscious.Security.Cryptography.Argon21.3.1— (transitive, third-party)Microsoft.AspNetCore.Components.Authorization10.0.5— (transitive, microsoft)Microsoft.Bcl.AsyncInterfaces10.0.5— (transitive, microsoft, netstandard2.0)Microsoft.Extensions.Configuration.Binder10.0.5— (transitive, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5— (transitive, microsoft, net10.0, netstandard2.0)Microsoft.Extensions.Hosting.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Http10.0.5— (transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5— (transitive, microsoft)MudBlazor9.3— (transitive, third-party)System.Buffers4.6.1— (transitive, microsoft, netstandard2.0)System.ComponentModel.Annotations5.0.0— (transitive, microsoft)System.IO.Hashing10.0.5— (transitive, microsoft, net10.0)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)System.Threading.Tasks.Extensions4.6.3— (transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Blazored.LocalStorage (>= 4.5.0)
- Lyo.Authentication.Web.Components (>= 1.0.1)
- Lyo.Diagnostic (>= 1.0.1)
- Microsoft.AspNetCore.Components.WebAssembly (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.