stefmde / EasyGCaptchaMVC

Easy ReCaptcha wrapper for MVC
MIT License
3 stars 1 forks source link

What is the correct way to bypass reCaptcha in development environment #10

Open blaiseliu opened 6 years ago

blaiseliu commented 6 years ago

I have a bool setting in Web.Config to decide if bypass would happen.

Then I copied your ActionFilter EasyGCaptcha and added these lines of code:

var isByPassed = Settings.Default.BypassCaptchaInDebugMode;
if (isByPassed)
{
    filterContext.ActionParameters["easyGCaptchaResult"] =
        new EasyGCaptchaResult {Date = DateTime.Now, GErrorCodes = null, Success = true};
    return;
}

Only to find out the EasyGCaptchaResult.Success is an internal get;.

In the extension, there is a property called UsePassthruInDebugMode. How to use it? Any documentation or example code?

What is your preferred way to bypass reCaptcha? I just need it for Selenium.

Thanks.

stefmde commented 6 years ago

There is no build in way to bypass it from the frontend because that would be a big security issue. You can use multiple ways to pass thru the validation. But please understand that right "Bypass" or "PassThru" only means that google will always respond with a "success". That is the build in way from google for testing to keep the test conditions as near as possible to the "production". So even if the ByPass mode is enabled you still have to click on the captcha. Or you dont have to if you use the invisible captcha with the size parameter. By default the bypass is used in debugging mode: https://github.com/stefmde/EasyGCaptchaMVC/blob/2831aa18a3032e3ec99b616d001082a11dded4af/EasyGCaptchaMVC/Configuration/Settings.cs#L110

If you dont want you site always in debugging mode in VisualStudio while testing, you can host you site in an IIS or someting like that and set the following parameter to always pypass: https://github.com/stefmde/EasyGCaptchaMVC/blob/2831aa18a3032e3ec99b616d001082a11dded4af/EasyGCaptchaMVC/Configuration/Settings.cs#L105

My code is well documented if you check the github sources, with samples on the project start page or you cann check the demo project: https://github.com/stefmde/EasyGCaptchaMVC/tree/master/EasyGCaptchaMVC.Demo

Hope that helps.