Skip to content

Instantly share code, notes, and snippets.

using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.MicrosoftAccount;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.Identity.Web;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using System.Security.Claims;
namespace AzureAD
{
namespace AzureAD
{
using System.Collections.Generic;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Cms.Core;
public class AzureB2CMembersExternalLoginProviderOptions : IConfigureNamedOptions<MemberExternalLoginProviderOptions>
{
public const string SchemeName = "OpenIdConnect";
@sergiutesu
sergiutesu / Startup.cs
Created September 21, 2022 07:36
.ConfigureAuthenticationMembers() method under the Startup.cs ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddWebsite()
.AddComposers()
.ConfigureAuthenticationMembers()
.Build();
}
using System.Security.Claims;
namespace AzureAD
{
public static class MemberAuthenticationExtensions
{
public static IUmbracoBuilder ConfigureAuthenticationMembers(this IUmbracoBuilder builder)
{
builder.Services.ConfigureOptions<AzureB2CMembersExternalLoginProviderOptions>();
@sergiutesu
sergiutesu / AzureB2CBackofficeExternalLoginProviderOptions.cs
Created September 21, 2022 07:27
It is important that autoLinkUser.IsApproved = true; is set to true, By design, the new user will be disabled by setting the autoLinkUser.IsApproved to true it will not be disabled.
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Web.BackOffice.Security;
namespace AzureAD
{
public class AzureB2CBackofficeExternalLoginProviderOptions : IConfigureNamedOptions<BackOfficeExternalLoginProviderOptions>
{
public const string SchemeName = "OpenIdConnect";
@sergiutesu
sergiutesu / Startup.cs
Created September 21, 2022 07:25
Calling our extension .ConfigureAuthentication() from the Startup.cs under ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddWebsite()
.AddComposers()
.ConfigureAuthentication()
.ConfigureAuthenticationMembers()
.Build();
}
@sergiutesu
sergiutesu / BackofficeAuthenticationExtensions.cs
Created September 21, 2022 07:21
Azure AD B2C BackofficeAuthenticationExtensions.cs
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.MicrosoftAccount;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.Identity.Web;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using System.Security.Claims;
namespace AzureAD
{