External Authentication Providers

As ZauberCMS uses identity you can use the external providers from Microsoft to allow registration and login using the external providers.

Link to the docs on the Microsoft website

We have included Facebook, Google & Microsoft out of the box, you just need to put your credentials in the appSettings and they will automatically show on the login and registration pages

"ExternalProviders": {
  "Google": {
    "ClientId": "",
    "ClientSecret": ""
  },
  "Facebook": {
    "AppId": "",
    "AppSecret": ""
  },
  "Microsoft": {
    "ClientId": "",
    "ClientSecret": ""
  }
}

Adding New External Authentication Providers

If you want to add a new external provider, you need to Implement

IExternalAuthenticationProvider

And you will need to reference the Nuget package from microsoft or write your own code to handle the provider. Below is an example of adding the Microsoft provider using the IExternalAuthenticationProvider

public class MicrosoftAuthentication : IExternalAuthenticationProvider
{
    public void Add(IServiceCollection servicesCollection, AuthenticationBuilder authenticationBuilder, IConfiguration configuration)
    {
        var microsoftId = configuration.GetValue<string>("Zauber:Identity:ExternalProviders:Microsoft:ClientId");
        if (!microsoftId.IsNullOrWhiteSpace())
        {
            // https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/microsoft-logins?view=aspnetcore-5.0
            authenticationBuilder.AddMicrosoftAccount(microsoftOptions =>
            {
                microsoftOptions.ClientId = microsoftId;
                microsoftOptions.ClientSecret = configuration.GetValue<string>("Zauber:Identity:ExternalProviders:Microsoft:ClientSecret") ?? "";
            });
        }
    }
}

Last updated