1
Applying: Built in . NET Core 2.2
Is it possible to have two forms of authentication in a single C# project? I found myself in the following scenario:
1 - Users who are employees of the company use Azuread to perform authentication, and this works properly;
2 - Users who are not collaborators, but partners, must perform the authentication in a way other than via Azure.
PS: I don’t have the option to create Guest users in Azuread.
3 - Both employees and partners access the same application.
I tried to add a new form of authentication in the Application Startup, but I don’t know if it’s the best strategy. The section below is Azuread authentication, which is OK.
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
{
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = async ctxt =>
{
await Task.Yield();
},
OnMessageReceived = async ctxt =>
{
await Task.Yield();
},
OnTicketReceived = async ctxt =>
{
if (ctxt.Principal.Identity is ClaimsIdentity identity)
{
//alguma funcionalidade
}
await Task.Yield();
},
};
});
I also read about creating Users via Identity, but I was wondering if the application will understand where to perform the User.Identity verification, whether in Azuread or in another authentication schema.
Task SignInAsync(ApplicationUser user, bool isPersistent)
Someone’s been through something similar ?