OidcAadB2C 2.0.0

Open ID Connect, Azure Active Directory B2C module to allow MVC apps to use Azure AD B2C connections.

Install-Package OidcAadB2C -Version 2.0.0
dotnet add package OidcAadB2C --version 2.0.0
<PackageReference Include="OidcAadB2C" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OidcAadB2C --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

For use in projects needing Azure Active Directory and Azure B2C directory services.

Startup.cs

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

        services.AddAuthentication(sharedOptions =>
	        {
		        sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
		        sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
	        })
	        .AddAzureAdB2C(options => Configuration.Bind("Authentication:AzureAdB2C", options))
	        .AddCookie(); // your bindings


		services.AddMvc();

        // Adds a default in-memory implementation of IDistributedCache.
		// Required for the B2C authentication
        services.AddDistributedMemoryCache();
        services.AddSession(options =>
        {
	        options.IdleTimeout = TimeSpan.FromHours(1);
	        options.Cookie.HttpOnly = true;
        });
    }

appsettings.json

{
"Authentication": {
"AzureAdB2C": {
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ClientSecret": "----------------------",
"Tenant": "yourb2c.onmicrosoft.com",
"SignUpSignInPolicyId": "B2C_1A_SignUpOrSignInWithAAD",
"EditProfilePolicyId": "B2C_1_DemoProfileEdits",
"ResetPasswordPolicyId": "B2C_1_DemoNameHere",
"RedirectUri": "http://localhost:5000/signin-oidc",
"ApiUrl": "https://fabrikamb2chello.azurewebsites.net/hello",
"ApiScopes": "https://fabrikamb2c.onmicrosoft.com/demoapi/demo.read"
}
},
... rest of the settings

For use in projects needing Azure Active Directory and Azure B2C directory services.

Startup.cs

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

        services.AddAuthentication(sharedOptions =>
	        {
		        sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
		        sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
	        })
	        .AddAzureAdB2C(options => Configuration.Bind("Authentication:AzureAdB2C", options))
	        .AddCookie(); // your bindings


		services.AddMvc();

        // Adds a default in-memory implementation of IDistributedCache.
		// Required for the B2C authentication
        services.AddDistributedMemoryCache();
        services.AddSession(options =>
        {
	        options.IdleTimeout = TimeSpan.FromHours(1);
	        options.Cookie.HttpOnly = true;
        });
    }

appsettings.json

{
"Authentication": {
"AzureAdB2C": {
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ClientSecret": "----------------------",
"Tenant": "yourb2c.onmicrosoft.com",
"SignUpSignInPolicyId": "B2C_1A_SignUpOrSignInWithAAD",
"EditProfilePolicyId": "B2C_1_DemoProfileEdits",
"ResetPasswordPolicyId": "B2C_1_DemoNameHere",
"RedirectUri": "http://localhost:5000/signin-oidc",
"ApiUrl": "https://fabrikamb2chello.azurewebsites.net/hello",
"ApiScopes": "https://fabrikamb2c.onmicrosoft.com/demoapi/demo.read"
}
},
... rest of the settings

Release Notes

Open ID Connect, Azure Active Directory B2C module to allow MVC apps to use Azure AD B2C connections. The MVC application requires the Startup.cs file have settings inserted to use this module. Use the starter template for this project type and then add your application specific settings to the appsettings.json file.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.0.0 301 1/23/2018