using IdentityServer.Wrapper; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; using System; namespace NDB.Security.Authentication.Identity { public static class BasicAuthenticationExtensions { public static IServiceCollection AddBasicAuthentication(this IServiceCollection services, string identityServerBaseAddress) { if (string.IsNullOrEmpty(identityServerBaseAddress)) throw new Exception($"Identity server base address must be provided."); // Identity server services.UseIdentityServices(identityServerBaseAddress); // configure basic authentication services.AddAuthentication("BasicAuthentication") .AddScheme("BasicAuthentication", null); return services; } } }