Skip to content

Blazor 9's AddAuthenticationStateSerialization() and AddAuthenticationStateDeserialization() appear to lack support for external API JWT authentication scenarios #59318

@shahabfar

Description

@shahabfar

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

The methods AddAuthenticationStateSerialization() and AddAuthenticationStateDeserialization() appear to only function correctly when using ASP.NET Core Identity in the server project (as used in the Visual Studio sample templates).

When using a remote API for authentication with JWT tokens, these methods do not seem to provide automatic persistent serialization of the authentication state. Since the developers need to implement a custom AuthenticationStateProvider to handle JWT persistence, reducing the utility of these new serializer methods in non-Identity scenarios.

This limitation makes it more challenging to integrate with remote API-based authentication strategies and adds additional development overhead.

Describe the solution you'd like

A new sample should be added to the existing Blazor samples to demonstrate how to use an external API for JWT authentication while employing prerendering authentication, as well as how to transfer the authentication state to the interactive rendering mode.
Although one workaround is to create a custom AuthenticationStateProvider as before and include some boilerplate code to manage the persisted component state, it seems that AddAuthenticationStateSerialization() and AddAuthenticationStateDeserialization() were introduced specifically to eliminate the need for such custom providers.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions