-
Blazor-WASM-Identity-gRPC
Blazor WASM, IdentityServer4 with Multiple Roles, Additional User Claim(s) & gRPC Roles Authorization
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
ASP.NET Core
ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
Hi folkz, I got my Blazor app up and running using Duende by following this app - https://github.com/JeepNL/Blazor-WASM-Identity-gRPC
there are few pieces to solve the puzzle, but once you figure it out, it is quite straightforward. No need to use Duende for that. for the sake of simplicity, let's say you have a Blazor web assembly "client" app and an asp.net "service" which feeds the data to the client (it could be a gRPC service, or a Rest service, the fundamentals are the same). we want to authenticate the user on the service, and the client app should have access to all claims associated with the user. First, you need to store users somewhere. we can use asp.net identity for that on your service. Second, you need an "authentication" endpoint which accepts user's credentials and returns a jwt token. use UserManager for the asp.net identity to verify the password, fetch all claims you want for the user and wrap them in the jwt token. creating jwt token is pretty straightforward, ping me if you don't know how to do that. Now you can implement Jwt-based authentication on the service, using standard asp.net facilities. Next, now you can call the authentication endpoint from your client app and get the token back. You can store the token in the local storage, for example. Now, how do you fetch the claims on the client? Implement AuthenticationStateProvider which cracks the jwt token and returns the principal with the claims. Now you will be able to access the claims on the client plus authorize access to certain pages based on, say, roles. The client part (which I found more convoluted than the service part) is fairly well explained in Patrick God videos on youtube. Once you've done that, the task is pretty much solved. You can host service and client separately, or your service can host the client app (it is just bunch of static files, after all). The choice is yours