MudraX.Blazor.Jwt.Web
9.0.0.5
dotnet add package MudraX.Blazor.Jwt.Web --version 9.0.0.5
NuGet\Install-Package MudraX.Blazor.Jwt.Web -Version 9.0.0.5
<PackageReference Include="MudraX.Blazor.Jwt.Web" Version="9.0.0.5" />
<PackageVersion Include="MudraX.Blazor.Jwt.Web" Version="9.0.0.5" />
<PackageReference Include="MudraX.Blazor.Jwt.Web" />
paket add MudraX.Blazor.Jwt.Web --version 9.0.0.5
#r "nuget: MudraX.Blazor.Jwt.Web, 9.0.0.5"
#:package MudraX.Blazor.Jwt.Web@9.0.0.5
#addin nuget:?package=MudraX.Blazor.Jwt.Web&version=9.0.0.5
#tool nuget:?package=MudraX.Blazor.Jwt.Web&version=9.0.0.5
MudraX.Blazor.Jwt.Web
MudraX.Blazor.Jwt.Web is a robust library designed to integrate XAF Web API authentication seamlessly into Blazor and .NET MAUI applications. Built with .NET 9, this library is optimized for modern cross-platform development, enabling developers to implement secure and scalable authentication solutions with ease.
Installation
To install the library, use the following NuGet command:
Install-Package MudraX.Blazor.Jwt.Web
XAF Web API service - Startup.cs
options.BusinessObject<ApplicationUser>();
appsettings.json
,
"JwtTokenAuth": {
"Authority": "https://localhost:5003",
"Secret": "<API_SERVER_KEY>",
"Issuer": "<ISSUER>"
}
Program.cs
builder.Services.AddMudraBlazorServices(supportedCultures: ["en-US", "zh-TW"]);
//Dependency Injection JwtIdentityService
builder.Services.AddJwtTokenAuthentication(options =>
{
var authority = builder.Configuration["JwtTokenAuth:Authority"];
options.AuthenticateAddress = $"{authority}/api/Authentication/Authenticate";
options.BaseAddress = $"{authority}/api";
options.ODataAddress = $"{authority}/api/odata";
options.JwtSecret = $"{builder.Configuration["JwtTokenAuth:Secret"]}";
options.Issuer = $"{builder.Configuration["JwtTokenAuth:Issuer"]}";
options.TokenKeyName = "ApplicationAccessToken";
options.ExpiresIn = 660;
});
...
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(typeof(AppUserMenu).Assembly);
app.UseMudraBlazorServices();
_Imports.razor
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using System.Globalization
@using Microsoft.Extensions.Localization
@using MudBlazor
@using MudBlazor.Services
@using MudExtensions
@using MudraX.Blazor.Core.Services
@using MudraX.Blazor.Web
@using MudraX.Blazor.Web.Components
@using MudraX.Blazor.Web.Components.Layout
@using MudraX.Blazor.Web.Services
@using MudraX.Blazor.Jwt.Web.Components.Layout
App.razor
Set reder mode to InteractiveServerRenderMode in your App.razor file:
<HeadOutlet @rendermode="new InteractiveServerRenderMode(prerender: false)" />
...
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
MainLayout.razor
Add AppUserMenu to MainLayout.razor
@inherits LayoutComponentBase
@attribute [Authorize]
<ApplicationLayout>
<ApplcationBar>
<AppUserMenu />
</ApplcationBar>
<DrawerMenu>
</DrawerMenu>
<Body>
@Body
</Body>
</ApplicationLayout>
Routes.razor
Add the following route to your Routes.razor file:
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(AppUserMenu).Assembly }">
<Found Context="routeData">
<CascadingValue Value="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
<Authorizing>
<p>Determining session state, please wait...</p>
</Authorizing>
<NotAuthorized>
<MudraX.Blazor.Jwt.Web.Pages.Login />
</NotAuthorized>
</AuthorizeRouteView>
</CascadingValue>
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(Layout.MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
Contributing
Contributions are welcome! To get started:
- Fork the repository and create a new branch for your feature or bug fix.
- Follow the contribution guidelines for detailed instructions.
- Submit a pull request with a clear description of your changes.
For any questions or discussions, feel free to open an issue or join our community forums.
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.11)
- MudraX.Blazor.Jwt (>= 9.0.0.5)
- MudraX.Blazor.Web (>= 9.0.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.