-
Notifications
You must be signed in to change notification settings - Fork 10.9k
[Blazor] Propagate SignalR authentication refresh to server circuits #68221
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,26 @@ | |
|
|
||
| <script src="_framework/blazor.server.js" autostart="false"></script> | ||
| <script> | ||
| if (new URLSearchParams(location.search).has('captureAuthenticationRefresh')) { | ||
| const originalFetch = window.fetch; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really hacky, I don't know if you want this in the code base. Ideally, you'd either get the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I removed the interception and now wrap the builder build call inside configureSignalR to retrieve the HubConnection. The test now calls refreshAuthentication directly, verifies the authorization state updates, and confirms the connection ID didn't change. |
||
| window.authenticationRefreshTest = { | ||
| negotiateCount: 0, | ||
| async refresh() { | ||
| const url = new URL('_blazor/refresh', document.baseURI); | ||
| url.searchParams.set('id', this.connectionToken); | ||
| return (await originalFetch(url, { method: 'POST' })).status; | ||
| }, | ||
| }; | ||
| window.fetch = async (input, init) => { | ||
| const response = await originalFetch(input, init); | ||
| if (`${input}`.includes('/negotiate')) { | ||
| authenticationRefreshTest.negotiateCount++; | ||
| authenticationRefreshTest.connectionToken = (await response.clone().json()).connectionToken; | ||
| } | ||
| return response; | ||
| }; | ||
| } | ||
|
|
||
| Blazor.start({ | ||
| reconnectionOptions: { | ||
| // It's easier to test the reconnection logic if we wait a bit | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.