瀏覽代碼

Fixed a problem where captcha challenges couldn't be skipped.

Captcha challenges couldn't be skipped, even when the Captcha Skip Parameter Value has been set.
James Albright 8 年之前
父節點
當前提交
3a03cb4c0d

+ 7 - 5
src/main/java/password/pwm/http/servlet/ActivateUserServlet.java

@@ -211,11 +211,13 @@ public class ActivateUserServlet extends AbstractPwmServlet {
         final Configuration config = pwmApplication.getConfig();
         final LocalSessionStateBean ssBean = pwmSession.getSessionStateBean();
 
-        if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
-            final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
-            LOGGER.debug(pwmRequest, errorInfo);
-            setLastError(pwmRequest, errorInfo);
-            return;
+        if (CaptchaUtility.captchaEnabledForRequest(pwmRequest)) {
+            if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
+                final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
+                LOGGER.debug(pwmRequest, errorInfo);
+                setLastError(pwmRequest, errorInfo);
+                return;
+            }
         }
 
 

+ 8 - 6
src/main/java/password/pwm/http/servlet/ForgottenUsernameServlet.java

@@ -130,12 +130,14 @@ public class ForgottenUsernameServlet extends AbstractPwmServlet {
         final PwmSession pwmSession = pwmRequest.getPwmSession();
         final LocalSessionStateBean ssBean = pwmSession.getSessionStateBean();
 
-        if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
-            final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
-            LOGGER.debug(pwmRequest, errorInfo);
-            setLastError(pwmRequest, errorInfo);
-            forwardToFormJsp(pwmRequest);
-            return;
+        if (CaptchaUtility.captchaEnabledForRequest(pwmRequest)) {
+            if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
+                final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
+                LOGGER.debug(pwmRequest, errorInfo);
+                setLastError(pwmRequest, errorInfo);
+                forwardToFormJsp(pwmRequest);
+                return;
+            }
         }
 
         final String contextParam = pwmRequest.readParameterAsString(PwmConstants.PARAM_CONTEXT);

+ 4 - 2
src/main/java/password/pwm/http/servlet/LoginServlet.java

@@ -209,8 +209,10 @@ public class LoginServlet extends ControlledPwmServlet {
             throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_MISSING_PARAMETER,"missing password parameter"));
         }
 
-        if (!CaptchaUtility.verifyReCaptcha(pwmRequest, recaptchaResponse)) {
-            throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE, "captcha incorrect"));
+        if (CaptchaUtility.captchaEnabledForRequest(pwmRequest)) {
+            if (!CaptchaUtility.verifyReCaptcha(pwmRequest, recaptchaResponse)) {
+                throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE, "captcha incorrect"));
+            }
         }
 
         final SessionAuthenticator sessionAuthenticator = new SessionAuthenticator(

+ 7 - 6
src/main/java/password/pwm/http/servlet/forgottenpw/ForgottenPasswordServlet.java

@@ -354,14 +354,15 @@ public class ForgottenPasswordServlet extends ControlledPwmServlet {
         // clear the bean
         clearForgottenPasswordBean(pwmRequest);
 
-        if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
-            final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
-            LOGGER.debug(pwmRequest, errorInfo);
-            setLastError(pwmRequest, errorInfo);
-            return ProcessStatus.Continue;
+        if (CaptchaUtility.captchaEnabledForRequest(pwmRequest)) {
+            if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
+                final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
+                LOGGER.debug(pwmRequest, errorInfo);
+                setLastError(pwmRequest, errorInfo);
+                return ProcessStatus.Continue;
+            }
         }
 
-
         final List<FormConfiguration> forgottenPasswordForm = pwmApplication.getConfig().readSettingAsForm(
                 PwmSetting.FORGOTTEN_PASSWORD_SEARCH_FORM);
 

+ 8 - 6
src/main/java/password/pwm/http/servlet/newuser/NewUserServlet.java

@@ -509,12 +509,14 @@ public class NewUserServlet extends ControlledPwmServlet {
     {
         final NewUserBean newUserBean = getNewUserBean(pwmRequest);
 
-        if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
-            final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
-            LOGGER.debug(pwmRequest, errorInfo);
-            setLastError(pwmRequest, errorInfo);
-            forwardToFormPage(pwmRequest, newUserBean);
-            return ProcessStatus.Halt;
+        if (CaptchaUtility.captchaEnabledForRequest(pwmRequest)) {
+            if (!CaptchaUtility.verifyReCaptcha(pwmRequest)) {
+                final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_BAD_CAPTCHA_RESPONSE);
+                LOGGER.debug(pwmRequest, errorInfo);
+                setLastError(pwmRequest, errorInfo);
+                forwardToFormPage(pwmRequest, newUserBean);
+                return ProcessStatus.Halt;
+            }
         }
 
         newUserBean.setFormPassed(false);

+ 1 - 0
src/main/webapp/WEB-INF/jsp/activateuser.jsp

@@ -49,6 +49,7 @@
                 <input type="hidden" name="processAction" value="activate"/>
                 <%@ include file="/WEB-INF/jsp/fragment/cancel-button.jsp" %>
                 <input type="hidden" name="pwmFormID" value="<pwm:FormID/>"/>
+                <input type="hidden" name="skipCaptcha" value="${param.skipCaptcha}"/>
             </div>
         </form>
     </div>

+ 1 - 0
src/main/webapp/WEB-INF/jsp/forgottenpassword-search.jsp

@@ -57,6 +57,7 @@
                     </button>
                 </pwm:if>
                 <input type="hidden" name="pwmFormID" value="<pwm:FormID/>"/>
+                <input type="hidden" name="skipCaptcha" value="${param.skipCaptcha}"/>
             </div>
         </form>
     </div>

+ 1 - 0
src/main/webapp/WEB-INF/jsp/forgottenusername-search.jsp

@@ -50,6 +50,7 @@
                 </button>
                 <%@ include file="/WEB-INF/jsp/fragment/cancel-button.jsp" %>
                 <input type="hidden" name="pwmFormID" value="<pwm:FormID/>"/>
+                <input type="hidden" name="skipCaptcha" value="${param.skipCaptcha}"/>
             </div>
         </form>
     </div>

+ 1 - 0
src/main/webapp/WEB-INF/jsp/login.jsp

@@ -60,6 +60,7 @@
                         <%@ include file="/WEB-INF/jsp/fragment/cancel-button.jsp" %>
                     </pwm:if>
                     <input type="hidden" id="pwmFormID" name="pwmFormID" value="<pwm:FormID/>"/>
+                    <input type="hidden" name="skipCaptcha" value="${param.skipCaptcha}"/>
                 </div>
             </div>
         </form>

+ 1 - 0
src/main/webapp/WEB-INF/jsp/newuser.jsp

@@ -53,6 +53,7 @@
                     <pwm:display key="Button_Continue"/>
                 </button>
                 <input type="hidden" name="pwmFormID" value="<pwm:FormID/>"/>
+                <input type="hidden" name="skipCaptcha" value="${param.skipCaptcha}"/>
 
                 <% if ((Boolean)JspUtility.getAttribute(pageContext, PwmRequestAttribute.NewUser_FormShowBackButton)) { %>
                 <button type="button" id="button-goBack" name="button-goBack" class="btn" >

+ 1 - 1
src/main/webapp/public/resources/js/main.js

@@ -380,7 +380,7 @@ PWM_MAIN.handleLoginFormSubmit = function(form, event) {
             options['content'] = domForm.toObject(form);
             delete options['content']['processAction'];
             delete options['content']['pwmFormID'];
-            var url = 'login?processAction=restLogin';
+            var url = 'login?processAction=restLogin&skipCaptcha=' + options['content']['skipCaptcha'];
             var loadFunction = function(data) {
                 if (data['error'] == true) {
                     PWM_MAIN.getObject('password').value = '';