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

RemoteAuthenticationService injected into DefaultHttpClientFactory is created every 2min #60119

Open
danroth27 opened this issue Jan 30, 2025 · 0 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@danroth27
Copy link
Member

Originally reported by @ascott18:

#40764 (comment)

Another problem I just ran into:

  • RemoteAuthenticationService is a scoped service that implements IAccessTokenProvider.
  • IAccessTokenProvider is injected into a transient service AuthorizationMessageHandler (and its derivatives like BaseAddressAuthorizationMessageHandler).
  • AuthorizationMessageHandler instances are requested dynamically from a singleton service (DefaultHttpClientFactory). Because this is dynamic, it is not caught by static scope validation via ValidateScopes when building the service collection.
  • Ergo, a scoped service (RemoteAuthenticationService) is being injected into a singleton (DefaultHttpClientFactory), which is causing multiple instances of RemoteAuthenticationService to be created. In this case, a new instance is made every 2 minutes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

1 participant