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):
- MyProject.BlazorClient
- MyProject.HostApi
- MyProject.Shared (would contain Models, DBContext etc.)
- MyProject.Authentication.Api (should basically act like auth0 and manage authentication)
Purpose/use case:
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:
1. Are there any examples/tutorials/references of this available? Can't seem to find any and I don't want to reinvent the wheel ๐
2. How can I secure my HostApi with the authentication server?
3. 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?3 Replies
Are you looking for something like this https://github.com/dotnet-presentations/blazor-workshop/blob/main/docs/06-authentication-and-authorization.md ?
GitHub
blazor-workshop/06-authentication-and-authorization.md at main ยท do...
Blazor workshop. Contribute to dotnet-presentations/blazor-workshop development by creating an account on GitHub.
that's the default configuration where authentication and the data API is in the same project/app
I'd like to split this part up
So structure-wise basically like this: https://github.com/marouaneterai/Example/tree/master/Example
but the blazor wasm app he has isn't configured right
GitHub
Example/Example at master ยท marouaneterai/Example
Personal project. Contribute to marouaneterai/Example development by creating an account on GitHub.