C
C#2y ago
Henkypenky

❔ Best place to store a flag globally on ASP.NET Core

Hello everyone. What I'm trying to achieve is given a list of users that each have access to 1...N companies, store a flag app wide (for that current user scope) to determine which is the selected company that they will be performing actions for. So far I tried using claims and it kinda works but I know they are not supposed to be used for that. So anyways, if anyone can think of an alternative it would be great. Not looking for a full blown solution, just another mind to tackle the problem. Here is a diagram to illustrate the problem better. Thanks in advance Blazor Server .NET 7
8 Replies
Henkypenky
HenkypenkyOP2y ago
another idea i found while googling is to have a singleton service that carries that information everything can be loaded on app startup and there is no need to modify stuff while running, we can just restart for this scenarios
HtmlCompiler
HtmlCompiler2y ago
what do you mean my "not looking for a full blown solution", i mean it depends what you will do with this flag to me the obvious would be a relation between user and company, but i don't know if you are using a db or for example if this 'flag' has to be part of migrations, if it has to be available in various redundant services, if it has to be part of data backups, if it can be read/written, and so on
Henkypenky
HenkypenkyOP2y ago
there is no db, everything runs on http requests between the app and a service layer with support of a key vault for secrets
sliceofbytes
sliceofbytes2y ago
Use a cascading aparam Or like you said a singleton with a constructor param to configure the singleton
Henkypenky
HenkypenkyOP2y ago
that might work
HtmlCompiler
HtmlCompiler2y ago
so do you use this like a sort of permission? like RBAC?
Henkypenky
HenkypenkyOP2y ago
this already comes filtered from the db, it's more like a filter to separate company operations, there will be roles configured from azure aswell this works perfectly, thanks
<CascadingValue Value="@Whatever">
@Body
</CascadingValue>
<CascadingValue Value="@Whatever">
@Body
</CascadingValue>
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server