Search code examples
asp.net-identityduende-identity-server

Is it possible to use AspNetIdentity with Duende IdentityServer Backend for Frontend (BFF) approach?


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.


Solution

  • 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