Remove usage of TaskCache

This commit is contained in:
Pranav K 2017-06-08 08:43:38 -07:00
parent a561da0b3f
commit 4a258b4565
21 changed files with 37 additions and 60 deletions

View File

@ -6,11 +6,8 @@ using System.Linq;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
@ -50,7 +47,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
{
// Cookies needs to finish the response
Context.Response.OnStarting(FinishResponseAsync);
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
/// <summary>

View File

@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication.Cookies
{
@ -18,22 +17,22 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
/// <summary>
/// A delegate assigned to this property will be invoked when the related method is called.
/// </summary>
public Func<CookieValidatePrincipalContext, Task> OnValidatePrincipal { get; set; } = context => TaskCache.CompletedTask;
public Func<CookieValidatePrincipalContext, Task> OnValidatePrincipal { get; set; } = context => Task.CompletedTask;
/// <summary>
/// A delegate assigned to this property will be invoked when the related method is called.
/// </summary>
public Func<CookieSigningInContext, Task> OnSigningIn { get; set; } = context => TaskCache.CompletedTask;
public Func<CookieSigningInContext, Task> OnSigningIn { get; set; } = context => Task.CompletedTask;
/// <summary>
/// A delegate assigned to this property will be invoked when the related method is called.
/// </summary>
public Func<CookieSignedInContext, Task> OnSignedIn { get; set; } = context => TaskCache.CompletedTask;
public Func<CookieSignedInContext, Task> OnSignedIn { get; set; } = context => Task.CompletedTask;
/// <summary>
/// A delegate assigned to this property will be invoked when the related method is called.
/// </summary>
public Func<CookieSigningOutContext, Task> OnSigningOut { get; set; } = context => TaskCache.CompletedTask;
public Func<CookieSigningOutContext, Task> OnSigningOut { get; set; } = context => Task.CompletedTask;
/// <summary>
/// A delegate assigned to this property will be invoked when the related method is called.
@ -49,7 +48,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
{
context.Response.Redirect(context.RedirectUri);
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
};
/// <summary>
@ -66,7 +65,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
{
context.Response.Redirect(context.RedirectUri);
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
};
/// <summary>
@ -82,7 +81,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
{
context.Response.Redirect(context.RedirectUri);
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
};
/// <summary>
@ -98,7 +97,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies
{
context.Response.Redirect(context.RedirectUri);
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
};
private static bool IsAjaxRequest(HttpRequest request)

View File

@ -18,7 +18,6 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -3,7 +3,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication.JwtBearer
{
@ -15,22 +14,22 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
/// <summary>
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
/// </summary>
public Func<AuthenticationFailedContext, Task> OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask;
public Func<AuthenticationFailedContext, Task> OnAuthenticationFailed { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked when a protocol message is first received.
/// </summary>
public Func<MessageReceivedContext, Task> OnMessageReceived { get; set; } = context => TaskCache.CompletedTask;
public Func<MessageReceivedContext, Task> OnMessageReceived { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked after the security token has passed validation and a ClaimsIdentity has been generated.
/// </summary>
public Func<TokenValidatedContext, Task> OnTokenValidated { get; set; } = context => TaskCache.CompletedTask;
public Func<TokenValidatedContext, Task> OnTokenValidated { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked before a challenge is sent back to the caller.
/// </summary>
public Func<JwtBearerChallengeContext, Task> OnChallenge { get; set; } = context => TaskCache.CompletedTask;
public Func<JwtBearerChallengeContext, Task> OnChallenge { get; set; } = context => Task.CompletedTask;
public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context);

View File

@ -3,7 +3,6 @@
using System;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Builder
{

View File

@ -11,6 +11,5 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelOpenIdVersion)" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -3,7 +3,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication.OAuth
{
@ -15,7 +14,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
/// <summary>
/// Gets or sets the function that is invoked when the CreatingTicket method is invoked.
/// </summary>
public Func<OAuthCreatingTicketContext, Task> OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask;
public Func<OAuthCreatingTicketContext, Task> OnCreatingTicket { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked.
@ -23,7 +22,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth
public Func<OAuthRedirectToAuthorizationContext, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context =>
{
context.Response.Redirect(context.RedirectUri);
return TaskCache.CompletedTask;
return Task.CompletedTask;
};
/// <summary>

View File

@ -13,7 +13,6 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="$(JsonNetVersion)" />
</ItemGroup>

View File

@ -3,7 +3,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication.OpenIdConnect
{
@ -15,47 +14,47 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect
/// <summary>
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
/// </summary>
public Func<AuthenticationFailedContext, Task> OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask;
public Func<AuthenticationFailedContext, Task> OnAuthenticationFailed { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked after security token validation if an authorization code is present in the protocol message.
/// </summary>
public Func<AuthorizationCodeReceivedContext, Task> OnAuthorizationCodeReceived { get; set; } = context => TaskCache.CompletedTask;
public Func<AuthorizationCodeReceivedContext, Task> OnAuthorizationCodeReceived { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked when a protocol message is first received.
/// </summary>
public Func<MessageReceivedContext, Task> OnMessageReceived { get; set; } = context => TaskCache.CompletedTask;
public Func<MessageReceivedContext, Task> OnMessageReceived { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked before redirecting to the identity provider to authenticate.
/// </summary>
public Func<RedirectContext, Task> OnRedirectToIdentityProvider { get; set; } = context => TaskCache.CompletedTask;
public Func<RedirectContext, Task> OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked before redirecting to the identity provider to sign out.
/// </summary>
public Func<RedirectContext, Task> OnRedirectToIdentityProviderForSignOut { get; set; } = context => TaskCache.CompletedTask;
public Func<RedirectContext, Task> OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked when a request is received on the RemoteSignOutPath.
/// </summary>
public Func<RemoteSignOutContext, Task> OnRemoteSignOut { get; set; } = context => TaskCache.CompletedTask;
public Func<RemoteSignOutContext, Task> OnRemoteSignOut { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked after "authorization code" is redeemed for tokens at the token endpoint.
/// </summary>
public Func<TokenResponseReceivedContext, Task> OnTokenResponseReceived { get; set; } = context => TaskCache.CompletedTask;
public Func<TokenResponseReceivedContext, Task> OnTokenResponseReceived { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked when an IdToken has been validated and produced an AuthenticationTicket.
/// </summary>
public Func<TokenValidatedContext, Task> OnTokenValidated { get; set; } = context => TaskCache.CompletedTask;
public Func<TokenValidatedContext, Task> OnTokenValidated { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked when user information is retrieved from the UserInfoEndpoint.
/// </summary>
public Func<UserInformationReceivedContext, Task> OnUserInformationReceived { get; set; } = context => TaskCache.CompletedTask;
public Func<UserInformationReceivedContext, Task> OnUserInformationReceived { get; set; } = context => Task.CompletedTask;
public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context);

View File

@ -10,7 +10,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelOpenIdVersion)" />
</ItemGroup>
</Project>

View File

@ -3,7 +3,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication.Twitter
{
@ -15,7 +14,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter
/// <summary>
/// Gets or sets the function that is invoked when the Authenticated method is invoked.
/// </summary>
public Func<TwitterCreatingTicketContext, Task> OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask;
public Func<TwitterCreatingTicketContext, Task> OnCreatingTicket { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked.
@ -23,7 +22,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter
public Func<TwitterRedirectToAuthorizationEndpointContext, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context =>
{
context.Response.Redirect(context.RedirectUri);
return TaskCache.CompletedTask;
return Task.CompletedTask;
};
/// <summary>

View File

@ -13,7 +13,6 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -7,7 +7,6 @@ using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -119,7 +118,7 @@ namespace Microsoft.AspNetCore.Authentication
/// <returns>A task</returns>
protected virtual Task InitializeHandlerAsync()
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
protected string BuildRedirectUri(string targetPath)
@ -193,7 +192,7 @@ namespace Microsoft.AspNetCore.Authentication
protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
public async Task SignOutAsync(AuthenticationProperties properties)
@ -205,7 +204,7 @@ namespace Microsoft.AspNetCore.Authentication
protected virtual Task HandleSignOutAsync(AuthenticationProperties properties)
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
/// <summary>
@ -216,7 +215,7 @@ namespace Microsoft.AspNetCore.Authentication
protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties)
{
Response.StatusCode = 403;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
/// <summary>
@ -229,7 +228,7 @@ namespace Microsoft.AspNetCore.Authentication
protected virtual Task HandleChallengeAsync(AuthenticationProperties properties)
{
Response.StatusCode = 401;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
public async Task ChallengeAsync(AuthenticationProperties properties)

View File

@ -3,15 +3,14 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authentication
{
public class RemoteAuthenticationEvents
{
public Func<FailureContext, Task> OnRemoteFailure { get; set; } = context => TaskCache.CompletedTask;
public Func<FailureContext, Task> OnRemoteFailure { get; set; } = context => Task.CompletedTask;
public Func<TicketReceivedContext, Task> OnTicketReceived { get; set; } = context => TaskCache.CompletedTask;
public Func<TicketReceivedContext, Task> OnTicketReceived { get; set; } = context => Task.CompletedTask;
/// <summary>
/// Invoked when there is a remote failure

View File

@ -19,7 +19,6 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.SecurityHelper.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="$(AspNetCoreVersion)" />
</ItemGroup>

View File

@ -17,7 +17,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.SecurityHelper.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authorization.Infrastructure
{
@ -68,7 +67,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure
context.Succeed(requirement);
}
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}

View File

@ -3,7 +3,6 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authorization.Infrastructure
{
@ -28,7 +27,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure
{
context.Succeed(requirement);
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authorization.Infrastructure
{
@ -47,7 +46,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure
context.Succeed(requirement);
}
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Authorization.Infrastructure
{
@ -62,7 +61,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure
context.Succeed(requirement);
}
}
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}

View File

@ -17,7 +17,6 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute</Description>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>