We have a .NET Core web application that we have installed on several clients. We use the appsettings file to configure slight differences between clients, such as database connection. And we have been using Microsoft Account authentication for each client.
Now we have a client that wants us to use ADFS authentication. Ideally, we would like to be able to configure this using our appsettings file, but I'm not sure how to do this. So, how can we use both the Microsoft Account and the ADFS authentication, and specify which to use? Below is the authentication portion of my startup file. I have omitted a few things for confidentiality reasons. I don't know if I need all of this:
services.AddAuthentication().AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ApplicationId"];
microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:Password"];
microsoftOptions.AuthorizationEndpoint = Configuration["Authentication:Microsoft:OAuth"];
microsoftOptions.TokenEndpoint = Configuration["Authentication:Microsoft:Token"];
microsoftOptions.CallbackPath = new PathString("/auth/callback");
microsoftOptions.UsePkce = false;
}).AddWsFederation(options =>
{
// MetadataAddress represents the Active Directory instance used to authenticate users.
options.MetadataAddress = "Omitted";
// Wtrealm is the app's identifier in the Active Directory instance.
// For ADFS, use the relying party's identifier, its WS-Federation Passive protocol URL:
options.Wtrealm = "Omitted";
// For AAD, use the Application ID URI from the app registration's Overview blade:
//options.Wtrealm = "api://bbd35166-7c13-49f3-8041-9551f2847b69";
});