From c802134737a2599785ec46ebae12b75f0bf96629 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Sat, 4 Jan 2020 20:39:24 +0000 Subject: [PATCH] Use ISystemClock for request timestamps (#18124) Use ISystemClock to generate timestamps for Twitter authentication. Remove custom static field for the epoch. --- src/Security/Authentication/Twitter/src/TwitterHandler.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Security/Authentication/Twitter/src/TwitterHandler.cs b/src/Security/Authentication/Twitter/src/TwitterHandler.cs index e963d7a27e..5f09e608b9 100644 --- a/src/Security/Authentication/Twitter/src/TwitterHandler.cs +++ b/src/Security/Authentication/Twitter/src/TwitterHandler.cs @@ -21,8 +21,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterHandler : RemoteAuthenticationHandler { - private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - private HttpClient Backchannel => Options.Backchannel; /// @@ -301,9 +299,9 @@ namespace Microsoft.AspNetCore.Authentication.Twitter return result; } - private static string GenerateTimeStamp() + private string GenerateTimeStamp() { - var secondsSinceUnixEpocStart = DateTime.UtcNow - Epoch; + var secondsSinceUnixEpocStart = Clock.UtcNow - DateTimeOffset.UnixEpoch; return Convert.ToInt64(secondsSinceUnixEpocStart.TotalSeconds).ToString(CultureInfo.InvariantCulture); }