Reputation: 450
So I was looking at the latest version of blazor application and noticed, that there is no template for blazor web app (I assume this is a goto template for the hybrid hosting model) that incorporates b2c from teh get go (unlike older wasm or server templates).
In a few tracks on github I also discovered that not everybody was able to work with that and there is a track to update documentation, but that section is not completed yet.
Does anybody know where can I get a comprehensive guide on how to actually make it work with B2C if I start from a template with no authorization (since Identity is clearly not that I need and there is no other option for now at least)? Assuming B2C tenant is in place and custom policies are working (in terms that jwt.ms can parse a token with custom claims)? Mb some useful repositories to look for and copy their Program.cs setup?
Thanks you in advance.
Upvotes: 1
Views: 409
Reputation: 7347
Yes, In the template you can only see the option for Individual Accounts.
We have an option to add Microsoft Identity Platform
from Connected Services (Code related to Authentication gets generated automatically by configuring this)- Works in all the previous versions.
I am trying to configure the same in .NET 8 Blazor Web App.
I have added in both Web and Client App.
Observations when added in Web App:
.csproj
is updated with the below packages. <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.13.4" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.13.4" />
Configurations:
Program.cs
and appsettings.json
file.Observations when added in ClientApp:
.csproj
file is updated with the below package. <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="8.0.0" />
Program.cs
file in both Web and Client Apps.Even this MSDoc explains the Authentication only for Blazor WASM and Server Applications.
Upvotes: 2