You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement Blazor InteractiveServer with Oidc and cookies. Logging in/out and redirecting the loginpage of the IdP works like it's supposed to, no issues there. My issues start with the CookieOidcRefresher class.
I have @attribute [Authorize] set in _Imports.razor to make sure every page needs authorization. For the rest my testproject uses the code of the BlazorWebAppOidcServer example.
When i navigate to a different page, the event OnValidatePrincipal doesn't trigger. So the tokens/cookies may be expired when i try to use them on the page. I did some tinkering and found that when i put the code app.MapBlazorHub() (this line of code is NOT in the example) then the event triggers when i navigate to a different page. However, now none of the buttons on any page work because of the AmbiguousMatchException error. Which is documented here. So i added the .WithOrder(-1). Now the buttons are working again and i have no AmbiguousMatchException anymore, however now the OnValidatePrincipal event doesn't trigger anymore when i navigate to a different page.
I can work around it by adding a timer in the CookieOidcRefresher class. But this feels hacky and i don't think this is the intended way of working.
What am i missing here?
Expected behavior
That the OnValidatePrincipal event triggers every time i navigate to a different page.
I created a sample project on GitHub
I removed the authority/clientid/clientsecret from the oidc-settings as those are irrelevant to this issue.
Describe the issue
I'm trying to implement Blazor InteractiveServer with Oidc and cookies. Logging in/out and redirecting the loginpage of the IdP works like it's supposed to, no issues there. My issues start with the
CookieOidcRefresher
class.I have
@attribute [Authorize]
set in_Imports.razor
to make sure every page needs authorization. For the rest my testproject uses the code of theBlazorWebAppOidcServer
example.When i navigate to a different page, the event
OnValidatePrincipal
doesn't trigger. So the tokens/cookies may be expired when i try to use them on the page. I did some tinkering and found that when i put the codeapp.MapBlazorHub()
(this line of code is NOT in the example) then the event triggers when i navigate to a different page. However, now none of the buttons on any page work because of theAmbiguousMatchException
error. Which is documented here. So i added the.WithOrder(-1)
. Now the buttons are working again and i have noAmbiguousMatchException
anymore, however now theOnValidatePrincipal
event doesn't trigger anymore when i navigate to a different page.I can work around it by adding a timer in the
CookieOidcRefresher
class. But this feels hacky and i don't think this is the intended way of working.What am i missing here?
Expected behavior
That the
OnValidatePrincipal
event triggers every time i navigate to a different page.I created a sample project on GitHub
I removed the authority/clientid/clientsecret from the oidc-settings as those are irrelevant to this issue.
cc: @guardrex dotnet/blazor-samples#470
The text was updated successfully, but these errors were encountered: