Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Simplify registration of ServerSideTokenStore #207

Closed
josephdecock opened this issue Sep 26, 2024 · 0 comments · Fixed by #225
Closed

Simplify registration of ServerSideTokenStore #207

josephdecock opened this issue Sep 26, 2024 · 0 comments · Fixed by #225
Assignees
Labels
area/bff/blazor BFF Blazor extensions
Milestone

Comments

@josephdecock
Copy link
Contributor

josephdecock commented Sep 26, 2024

The AddBlazorServerAccessTokenManagement extension method in Duende.AccessTokenManagement registers an IUserTokenStore implementation as a singleton. This doesn't work in the Duende.Bff.Blazor, because its implementation of the store (ServerSideTokenStore) has a dependency on the AuthenticationStateProvider, which can't be resolved in a singleton context.

Right now, we have this workaround:

       builder.Services.AddOpenIdConnectAccessTokenManagement()
            .AddBlazorServerAccessTokenManagement<ServerSideTokenStore>();

        var removeThis = builder.Services.First(d => d.ImplementationType == typeof(ServerSideTokenStore));
        builder.Services.Remove(removeThis);
        builder.Services.AddScoped<IUserTokenStore, ServerSideTokenStore>();

Instead, we should fix AccessTokenManagement to register the type parameter as Scoped. I think it would be ok to release that as a patch release, as this is pretty clearly a bug.

@josephdecock josephdecock added this to the 3.0.0 milestone Sep 26, 2024
@josephdecock josephdecock added area/bff Core Backend-For-Frontend library area/bff/blazor BFF Blazor extensions and removed area/bff Core Backend-For-Frontend library labels Dec 16, 2024
@josephdecock josephdecock linked a pull request Dec 27, 2024 that will close this issue
@josephdecock josephdecock self-assigned this Dec 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/bff/blazor BFF Blazor extensions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants