1

So lately I am trying to setup my Blazor Webassembly (Core hosted) application with Duende IdentityServer. Although most information is well documented, I can't seem to find any examples on how to integrate AspNetIdentity with Blazor WASM.

The tutorial of using Identityserver with Blazor WASM follows the use of the 'Backend for Frontend (BFF)' approach, so I did that as well. But when I look at the 'Using ASP.NET Core Identity' tutorial, all examples use the

.AddIdentityServer(options =>
    {
        // ...
    })

approach instead of the

.AddBff(options => {
       
    })

approach.

So the question is, is it even possible to use AspNetIdentity with BFF, if so, where do I add the configuration in my startup? Any pointers to a tutorial or example of this approach would also be much appreciated.

Nicolas
  • 2,277
  • 5
  • 36
  • 82
  • 1
    Maybe this helps: https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server?view=aspnetcore-7.0&tabs=visual-studio – MD Zand Dec 07 '22 at 10:14
  • 1
    @MDZand thank you for the link, it pointed me in the right direction. In the end it seemed that the default Blazor WebAssembly template, with 'Use Individual Accounts', was all I needed. Though the docs of Duende suggest I could use the BFF approach, though I think it lacks the information on how to customize it (e.g. use your own login page, using AspNetIdentity, etc.). – Nicolas Dec 07 '22 at 12:05

1 Answers1

1

If you want to use BFF along with AspnetIdentity and IdentityServer, you need to setup a separate project for the BFF server(there's a template). In the BFF project, you specify the OIDC authority as your IdentityServer and you need to setup the BFF project as a client. I don't know Blazor but using the Angular cli, you also need to setup a proxy so that the cookie can be shared between the client and server app.

The following article and sample were really informative to me : : https://timdeschryver.dev/blog/lets-make-our-spa-more-secure-by-consuming-a-duende-bff-with-angular

https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v6/BFF/AngularBffSample

starball
  • 20,030
  • 7
  • 43
  • 238
Maxime Laflamme
  • 3,786
  • 2
  • 11
  • 12