Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4262

Authentication and Authorization on Client like Blazor Web Application and Hybrid Maui Application

$
0
0

In .NET 8, I've got a shared Razor component library, here I'm using Blazored localstorage to store and read the session information. That's because the application needs to run offline.

For this purpose, I need a way to verify, that the JWT token exists and the expiry date is greater than now, if that's the case, I want to skip the login page. Also if I'm visiting any of the pages under /, but I'm not authenticated, I want to be redirected to the login page.

Also I want to use the authorize attribute on some pages that should only be available to specific user roles.

How is this possible? I've created a CustomAuthenticationStateProvider, but my breakpoint is never reached.

If I'm using the authorize attribute I'm getting an error. If I'm creating a CustomAuthenticationHandler, the error disappears, but the handling doesn't work like expected, if I'm referencing the CustomAuthenticationStateProvider in my CustomAuthenticationHandler, I'm getting a java interop failure, so I don't know if this all is the right way at all, because on some websites I'm reading that localstorage cant be accessed at a middleware like point.

As I only know middleware in the backend, I don't know if this is the case. Also I'm not using prerender!


Viewing all articles
Browse latest Browse all 4262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>