// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.AspNet.Authentication; namespace Microsoft.Extensions.DependencyInjection { /// /// Extension methods for setting up authentication services in an . /// public static class AuthenticationServiceCollectionExtensions { /// /// Adds authentication services to the specified . /// /// The to add services to. /// A reference to this instance after the operation has completed. public static IServiceCollection AddAuthentication(this IServiceCollection services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddWebEncoders(); services.AddDataProtection(); return services; } /// /// Adds authentication services to the specified . /// /// The to add services to. /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. public static IServiceCollection AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configureOptions == null) { throw new ArgumentNullException(nameof(configureOptions)); } services.Configure(configureOptions); return services.AddAuthentication(); } } }