Blazor WASM Authentication with separate APIs
I have a Blazor WASM app and an API for that client app. Now I'd like to decouple things and extract the authentication layer into it's own project an API.
So I'd have 4 projects (in reality there're also Domain, Infrastructre etc. projects but for the sake of this example I wanna keep it simple):
I would like to have a centralized authentication API like
Questions:
So I'd have 4 projects (in reality there're also Domain, Infrastructre etc. projects but for the sake of this example I wanna keep it simple):
- MyProject.BlazorClient
- MyProject.HostApi
- MyProject.Shared (would contain Models, DBContext etc.)
- MyProject.Authentication.Api (should basically act like auth0 and manage authentication)
I would like to have a centralized authentication API like
accounts.myproject.tld which could be used for other services on that domain like service1.myproject.tld and service2.myproject.tld without the need of 2 separate authentication providers. So like I said, basically a "self hosted auth0".Questions:
- Are there any examples/tutorials/references of this available? Can't seem to find any and I don't want to reinvent the wheel
- How can I secure my HostApi with the authentication server?
- How can I implement authentication with this pattern in blazor?
Do I need to configure the Blazor WASM app to use one API for authentication and another one for data retrieval? If so, how?