Add an IServiceCollection extensions
This commit is contained in:
parent
e789e82d3d
commit
355a2b0a78
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.Framework.Internal;
|
using Microsoft.Framework.Internal;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Antiforgery
|
namespace Microsoft.AspNet.Antiforgery
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
// 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.Antiforgery;
|
||||||
|
using Microsoft.Framework.Internal;
|
||||||
|
|
||||||
|
namespace Microsoft.Framework.DependencyInjection
|
||||||
|
{
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddAntiforgery([NotNull] this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddDataProtection();
|
||||||
|
|
||||||
|
services.TryAdd(ServiceDescriptor.Singleton<IClaimUidExtractor, DefaultClaimUidExtractor>());
|
||||||
|
services.TryAdd(ServiceDescriptor.Singleton<Antiforgery, Antiforgery>());
|
||||||
|
services.TryAdd(
|
||||||
|
ServiceDescriptor.Singleton<IAntiforgeryAdditionalDataProvider, DefaultAntiforgeryAdditionalDataProvider>());
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection ConfigureAntiforgery(
|
||||||
|
[NotNull] this IServiceCollection services,
|
||||||
|
[NotNull] Action<AntiforgeryOptions> setupAction)
|
||||||
|
{
|
||||||
|
services.Configure(setupAction);
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue