Forge Security Jwt Web Browser storages
$ dotnet add package Forge.Security.Jwt.Client.Storage.BrowserForge.Security.Jwt.Client.Storage.Browser is a library extension that provides access to the browsers local and session storage APIs for WASM applications.
To install the package add the following line to you csproj file replacing x.x.x with the latest version number:
<PackageReference Include="Forge.Security.Jwt.Client.Storage.Browser" Version="x.x.x" />
You can also install via the .NET CLI with the following command:
dotnet add package Forge.Security.Jwt.Client.Storage.Browser
If you're using Visual Studio you can also install via the built in NuGet package manager.
You will need to register the local storage services with the service collection in your Startup.cs file in Blazor Server.
public void ConfigureServices(IServiceCollection services)
{
// ... preinitialization steps
// always add this code after the "Forge.Security.Jwt.Client" library initialization
services.AddForgeJwtClientAuthenticationCoreWithLocalStorage();
services.AddForgeJwtClientAuthenticationCoreWithSessionStorage();
}
Or in your Program.cs file in Blazor WebAssembly.
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddForgeJwtClientAuthenticationCoreWithLocalStorage();
builder.Services.AddForgeJwtClientAuthenticationCoreWithSessionStorage();
await builder.Build().RunAsync();
}
If you would like to register Storage Provider services as singletons, it is possible by using the following method:
builder.Services.AddForgeJwtClientAuthenticationCoreAsSingletonWithLocalStorage();
builder.Services.AddForgeJwtClientAuthenticationCoreAsSingletonWithSessionStorage();
This method is not recommended in the most cases, try to avoid using it.
Please also check the following projects in my repositories: