Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Member

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bff/blazor BFF Blazor extensions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants