-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Invalidate Cached WASM Auth Token on Authentication State Change #36358
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
Conversation
...omponents/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs
Outdated
Show resolved
Hide resolved
...omponents/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs
Show resolved
Hide resolved
@@ -16,10 +13,11 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication | |||
/// Access tokens will only be added when the request URI is within one of the base addresses configured using | |||
/// <see cref="ConfigureHandler(IEnumerable{string}, IEnumerable{string}, string)"/>. | |||
/// </summary> | |||
public class AuthorizationMessageHandler : DelegatingHandler | |||
public class AuthorizationMessageHandler : DelegatingHandler, IDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpMessageHandler
from which DelegatingHandler
inherits already implements IDisposable
so you could just override the existing protected virtual void Dispose(bool disposing)
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'd originally done prior to e2351d3. The issue with that approach is it requires adding a new public API, which at this stage of the release is a bit tougher.
{ | ||
authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; | ||
} | ||
Dispose(disposing: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulted this to true.
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1225280935 |
Fixes: #35888
This should work. I'm unable to validate it as for some reason the
AuthenticationStateChanged
event is never invoked (should be invoked on sign in/out). I'm assuming this is some issue with the debugger. I've validated that the event does in fact attach (line 44).