ZauberCMS
  • 🪄Welcome to ZauberCMS
  • Getting Started
    • 💡Quick Start
      • Databases
  • Creating A Website
    • 📹Website Build Video Tutorial
    • Content Types
      • Element Types
      • Compositions
    • Current Content Properties
      • Textbox & Textarea
      • Text Editor (Radzen)
      • Text Editor (TinyMCE)
      • Numeric
      • True / False
      • Rating
      • Checkbox, Dropdown & Radio Lists
      • Media Picker
      • Navigation
      • Material Icon Picker
      • Content Picker
      • Date Picker
      • Custom Component Picker
      • Api Key Picker
      • Colour Picker
      • Block List Editor
      • Editor Notes
      • Google Map Location Picker
      • Simple List Manager
      • Simple Dictionary Manager
      • SEO Property
      • Code Editor
      • Colour Theme Picker
    • Content
      • Publish & Unpublish
    • Querying Data
      • Extension Methods
    • Views
    • Controllers (Route Hi-Jacking)
    • Custom Components
    • Users & Roles
      • Restrict Access By Role
    • Logs
    • Audit
    • Global Settings
      • Using Global Settings
    • SEO Sitemaps
    • Hosting
  • Extending ZauberCMS
    • Overview
    • BlockListEditor
      • Content Block Preview
      • Content Block
    • Custom List Data
    • Custom Content Property
    • Custom Validation
    • Custom Admin Sections
      • Section Nav Group Menu
      • Trees
        • Tree Context Menus
      • Reusing Content Editors
    • Saving Custom Data
    • Using AppState Events
    • Before & After Save
    • Email & Storage Providers
    • Seed Data
    • SEO Checks
  • Identity
    • Overview
    • External Authentication Providers
    • Account Layout
  • Language
    • Overview
    • Adding Language Dictionaries
    • Setting The Language
    • Using Language Dictionaries
  • AppSettings
    • Detailed Errors
    • Media Settings
    • Enable Path Urls
Powered by GitBook
On this page
  1. Identity

External Authentication Providers

PreviousOverviewNextAccount Layout

Last updated 10 months ago

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

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") ?? "";
            });
        }
    }
}

Facebook and Google authentication in ASP.NET CoreMicrosoftLearn
Link to the docs on the Microsoft website
Logo