项目作者: ShadyNagy

项目描述 :
Secure an ASP.NET Core Blazor WebAssembly hosted app with Azure Active Directory B2C (Without implicit grant).
高级语言:
项目地址: git://github.com/ShadyNagy/b2c-blazor-wasm-31.git
创建时间: 2020-10-12T00:15:11Z
项目社区:https://github.com/ShadyNagy/b2c-blazor-wasm-31

开源协议:MIT License

下载


Azure B2C Blazor WASM Working with 3.1

Secure an ASP.NET Core Blazor WebAssembly hosted app with Azure Active Directory B2C

Azure B2C not working in Blazor WASM (netstandard2.1) without the implicit grant so that is the solution

1- Create the app Microsoft Documentation

2- Copy file AuthenticationService.js from src folder to your Blazor WASM project (B2CWasm.Client) in wwwroot folder.

3- Change index.html in wwwroot folder from

  1. <script src="_content/Microsoft.Authentication.WebAssembly.Msal/AuthenticationService.js"></script>

to

  1. <script src="AuthenticationService.js"></script>

4- add this package to server

  1. <PackageReference Include="Microsoft.Identity.Web" Version="1.1.0" ></PackageReference>

5- in WeatherForecastController

  1. ...
  2. using Microsoft.Identity.Web.Resource;
  3. ...
  4. public class WeatherForecastController : ControllerBase
  5. {
  6. ...
  7. static readonly string[] scopeRequiredByApi = new string[] { "your scop name" };
  8. ...
  9. [HttpGet]
  10. public IEnumerable<WeatherForecast> Get()
  11. {
  12. HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);
  13. ...
  14. }
  15. }