[Blazor][Wasm] Set oidc Authentication Options to Local Storage
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
There is an existing issue for this but it is closed (#20574), I really think this feature is needed to allow the developer to choose where he wants to store. My current problem is that I choose Blazor as my frontend technology and I’m using ElectronJS as my container, I want to be able to allow the user to open multiple windows do make use of multiple monitors. Right now using SessionStorage, every time the user needs to Undock a panel into a separate window it triggers authentication again, I know it does not ask for credentials, it does it silently but it does go through the “Authorizing…” handshake before actually redirecting to the component. That is bad for user experience it is generating a new token in each new window. I tried to remediate this through Electron but it does not work, even populating the sessionStorage with the content of the main window it still goes through the authorization dance.
Describe the solution you’d like
I want to be able to set the Storage mechanism to be used, just like MsalAuthentication:
builder.Services.AddMsalAuthentication(options => { options.ProviderOptions.Cache.CacheLocation = "localStorage"; ... });
so it would be something like:
builder.Services.AddOidcAuthentication(options => { options.ProviderOptions.Cache.CacheLocation = "localStorage"; ... });
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:7 (1 by maintainers)
Top GitHub Comments
As a workaround, you can monkey patch the
window.sessionStorage
to point to thelocalStorage
instead:Just before including the
AuthenticationService.js
you can add this:Yes, this is a bit rough and when you still need to access
sessionStorage
you need to useoriginalSessionStorage
instead, but it works and keeps you logged in between different browser sessions.Please consider this feature more carefully than this comment:
https://github.com/dotnet/aspnetcore/issues/20574#issuecomment-610545261
I don’t think you should dismiss such a fundamental requirement on such a diverse platform like web. Many people have their own unique scenarios which you can’t possibly account for all, so giving more options is the right away here rather than locking ppl down cause you “know better” security.
To put a concrete example where exception is needed, I’m using OIDC Provider which has disabled iFrame with error:
So, I endup having to manually login on each tab, Plus of it I don’t wanna call the server on each tab/new page load, Plus I’m building a internal tool where I’m perfectly happy to take risks of
localStorage
.