-
I am trying to figure out how to properly wire up CSLA using IdentityServer for authentication. I have everything working as far as logging in is concerned. My problem is that after the initial login, if the page is refreshed, CSLA losses the identity. I tried using the CslaAuthenticationStateProvider, but that causes a casting error on the authentication page with the RemoteAuthenticatorView component. See error details below. Right now I am using the OnLogInSucceeded event of the RemoteAuthenticatorView to set the CslaUserService.CurrentUser to the logged in user. Being that I currently only have 2 pages, to mitigate the issue of losing the login, I placed some code in the OnInitialized event of these 2 pages to also set the CslaUserService.CurrentUser to the logged in user when the user is authenticated. (I am getting the logged in user via a cascading AuthenticationState parameter,) What is the proper way to wire this up? Thank you Casting Error Details: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
The CSLA part of this is that the principal ( Blazor itself uses a This is a long way of saying that I don't know the answer to how (or if) you can have a Blazor wasm app survive a restart and still remain authenticated. If this is possible I would expect it to be through a cookie that your authentication framework (not CSLA, but the framework you are using for authentication) would store, because that should survive unless the browser window is closed. You'll have to detect that the app restarted, use the cookie to connect to the server, ask the server for the principal/identity pair, and store that pair in memory on the client again. |
Beta Was this translation helpful? Give feedback.
-
I don't think so as I don't believe I would have access to the logged in user that early. Currently I am getting it via the AuthenticationState parameter which is a cascading parameter from CascadingAuthenticationState in App.razor. Perhaps I can do it in App.razor. Didn't think of that before. I'll give it a try. |
Beta Was this translation helpful? Give feedback.
I don't think so as I don't believe I would have access to the logged in user that early. Currently I am getting it via the AuthenticationState parameter which is a cascading parameter from CascadingAuthenticationState in App.razor. Perhaps I can do it in App.razor. Didn't think of that before. I'll give it a try.