In my server side Blazor app, the authentication is being handled in a very unconventional way. Essentially, when a user visits the page they are authenticated using their windows credentials. At that point, a custom policy is created to look up that username in an external database (Informix) in which the authorization for that user in the application is found. Specifically for each level of authorization in the app (can update, go to this page, etc.), I am creating a new claim to add to the current user based on permissions stored in the database.
Normally in the view, I just use the AuthenticationStateProvider
to get this information and it works with no issues. However, when I need to access the user information in my service classes that are handling the updates/business logic I can't seem to access the claims/User at all. For example, one use case is getting the username stored in the database for the current Windows account based on a claim added during the initial authentication to log their activities/track. Another would be grabbing the current logged in users full name from the database.
I have tried DI in the service classes w/ the authentication state providers and HTTPContext
but neither of them work. I know the overall structure isn't ideal but it's what I have to work with.
Any insights in how to go about this would be much appreciated!