Make AddAuthorization() idempotent

Found this issue which looking into making AddMvc() idempotent. You'll end
up with multiple pass-through handlers registered if two components call
AddAuthorization(). This is very possible to happen if used two frameworks
in the same app.
This commit is contained in:
Ryan Nowak 2015-07-08 15:29:01 -07:00
parent d2701f4897
commit 831785fe9f
1 changed files with 1 additions and 1 deletions

View File

@ -14,7 +14,7 @@ namespace Microsoft.Framework.DependencyInjection
{
services.AddOptions();
services.TryAdd(ServiceDescriptor.Transient<IAuthorizationService, DefaultAuthorizationService>());
services.AddTransient<IAuthorizationHandler, PassThroughAuthorizationHandler>();
services.TryAddEnumerable(ServiceDescriptor.Transient<IAuthorizationHandler, PassThroughAuthorizationHandler>());
return services;
}