public abstract Task <PipelineState> DoInvoke(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest, ILoginStatistics loginStatistics);
        private async Task Challenge(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest, ILoginStatistics loginStatistics)
        {
            var numberOfFailedLogins = await loginStatistics.GetNumberOfFailedLoginsForIpAddress(openIdConnectRequest.GetRemoteIpAddress());

            await ChallengeWithRequestForRecaptcha(context, openIdConnectRequest, numberOfFailedLogins);
        }
        protected override async Task <PipelineState> DoInvoke(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest, ILoginStatistics loginStatistics)
        {
            var recaptchaValidationService = context.Get <IRecaptchaValidationService>();

            var recaptchaChallengeResponse = openIdConnectRequest.GetRecaptchaChallengeResponse();

            if (!string.IsNullOrEmpty(recaptchaChallengeResponse))
            {
                var recaptchaVerificationResponse = await recaptchaValidationService.Validate(recaptchaChallengeResponse, Options);

                if (recaptchaVerificationResponse.Succeeded)
                {
                    context.Set <IRecaptchaContext>(new RecaptchaContext(RecaptchaState.ChallengeSucceeded, recaptchaVerificationResponse.Hostname, recaptchaVerificationResponse.Timestamp));
                    return(PipelineState.Continue);
                }

                context.Set <IRecaptchaContext>(new RecaptchaContext(RecaptchaState.Failed, recaptchaVerificationResponse.Hostname, recaptchaVerificationResponse.Timestamp));
                return(PipelineState.Challenge);
            }

            return(PipelineState.Continue);
        }
예제 #4
0
        public override async Task <PipelineState> DoInvoke(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest, ILoginStatistics loginStatistics)
        {
            var numberOfFailedLogins = await loginStatistics.GetNumberOfFailedLoginsForIpAddress(openIdConnectRequest.GetRemoteIpAddress());

            if (numberOfFailedLogins < _options.NumberOfAllowedLoginFailuresPerIpAddress)
            {
                await loginStatistics.IncrementUnchallengedLoginsForUserAndIpAddress(openIdConnectRequest.GetUsername(),
                                                                                     openIdConnectRequest.GetRemoteIpAddress(), numberOfFailedLogins, _options.NumberOfAllowedLoginFailuresPerIpAddress);

                return(PipelineState.Continue);
            }

            return(PipelineState.Challenge);
        }
예제 #5
0
        protected override async Task <PipelineState> DoInvoke(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest, ILoginStatistics loginStatistics)
        {
            var challengeForAllLogins = await ShouldChallengeForAllLogins(context);

            if (challengeForAllLogins)
            {
                return(PipelineState.Challenge);
            }

            return(PipelineState.Continue);
        }