public void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData) { try { _secretStorageProvider = new DynamoDbSecretStorageProvider(); _usedCodeProvider = new DynamoDbUsedCodeProvider(); } catch (Exception ex) { Logger.Log(ex.Message); Logger.Log(ex.StackTrace); } }
private static bool CheckCode(string upn, string secretKey, string code, IUsedCodeProvider usedCodeProvider, DateTime when) { var currentInterval = GetInterval(when); var success = false; for (var timeIndex = currentInterval - PastIntervals; timeIndex <= currentInterval + FutureIntervals; timeIndex++) { var intervalCode = GetCode(secretKey, timeIndex); var intervalCodeHasBeenUsed = usedCodeProvider.IsCodeUsed(upn, timeIndex); if (!intervalCodeHasBeenUsed && ConstantTimeEquals(intervalCode, code)) { success = true; usedCodeProvider.SetUsedCode(upn, timeIndex); break; } } return(success); }
public static bool CheckCode(string upn, string secretKey, string code, IUsedCodeProvider usedCodeProvider) { return(CheckCode(upn, secretKey, code, usedCodeProvider, DateTime.Now)); }