Skip to content

Commit

Permalink
Used TimeProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmccannon committed Jun 25, 2024
1 parent 118e9bd commit 9d296b2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IStepUpAuthorizationRequirement : IAuthorizationRequirement
public string Name { get; }
}

public class StepUpAuthorizationHandler(StepUpPurpose stepUpPurpose) : AuthorizationHandler<IStepUpAuthorizationRequirement>
public class StepUpAuthorizationHandler(StepUpPurpose stepUpPurpose, TimeProvider timeProvider) : AuthorizationHandler<IStepUpAuthorizationRequirement>
{
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, IStepUpAuthorizationRequirement requirement)
{
Expand All @@ -36,9 +36,9 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte

private static Predicate<Claim> MatchesClaim(IStepUpAuthorizationRequirement requirement) => claim => claim.Type == requirement.Name;

private static bool IsExpired(DateTime expiration)
private bool IsExpired(DateTime expiration)
{
return expiration > DateTime.UtcNow;
return expiration > timeProvider.GetUtcNow().DateTime;
}

private static DateTime GetExpiration(Claim claim)
Expand Down

0 comments on commit 9d296b2

Please sign in to comment.