I about to build a .Net Blazor Server application.
That application then calls a .Net API.
I need authorization in the app and API.
Like “Admin”, “Customer”, “IT”, etc.
So they see different things in the app, and are restricted to what they can call in the API.
Would Roles be the way to go?
In .Net role based authorization you can use the Authorize data annotation.
Should i implement it like this tutorial? With customize the token on login?
Or what would be a good solution?
Unfortunately we won’t be able to help you with that article as it wasn’t developed by us so it’s hard to share advice on a product that you haven’t invented but we can of course try to help you. Can I redirect you to a better place and ask you to ask this question in on of those threads? Thank you!
I tried to figure out what is happening with your application but honestly I’m afraid I can’t do much.
As far as I know, this message is shown when your application comes across a <NotAuthorized> element and in the Blazor WASM case, it should happen on the client side (i.e., the server is not involved).
For example, in the sample project of my article, this message is shown only once, before the user authentication. This is correct because the current not authenticated user is…
Welcome to the Auth0 Community!
To enable role-based authorization in your Blazor application, follow the instructions in this document. I suggest using Actions to add the roles to the token instead of rules.
After this, you can use the authorization components as explained here.
I hope this helps.
February 17, 2023, 3:03pm
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.