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

Open
Tracked by #190
josephdecock opened this issue Sep 26, 2024 · 0 comments
Open
Tracked by #190

Simplify registration of ServerSideTokenStore #207

josephdecock opened this issue Sep 26, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@josephdecock
Copy link
Member

The AddBlazorServerAccessTokenManagement extension method in Duende.AccessTokenManagement registers an IUserTokenStore implementation as a singleton. This doesn't work in the Duende.Bff.Blazor, because the 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 mentioned this issue Sep 26, 2024
5 tasks
@josephdecock josephdecock added the enhancement New feature or request label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant