Making CAPTCHA optional so that I can test this locally
This commit is contained in:
parent
a8291c0e27
commit
d6999fb2b4
@ -5,7 +5,7 @@
|
||||
First, set up a tunnel to Jenkins LDAP server. Run the following command and
|
||||
keep the terminal open:
|
||||
|
||||
ssh -L 9389:localhost:389 cucumber.jenkins-ci.org
|
||||
ssh -L 9389:localhost:389 ldap.jenkins.io
|
||||
|
||||
Create `config.properties` in the same directory as `pom.xml`. See the
|
||||
`Parameters` class for the details, but it should look something like the
|
||||
@ -15,8 +15,6 @@ following:
|
||||
managerDN=cn=admin,dc=jenkins-ci,dc=org
|
||||
newUserBaseDN=ou=people,dc=jenkins-ci,dc=org
|
||||
smtpServer=localhost
|
||||
recaptchaPublicKey=6Ld--8ASAAAAANHmHaM1sdSYshtmXTin1BNtaw86
|
||||
recaptchaPrivateKey=*****
|
||||
managerPassword=*****
|
||||
circuitBreakerFile=./circuitBreaker.txt
|
||||
url=http://localhost:8080/account/
|
||||
|
@ -134,10 +134,13 @@ public class Application {
|
||||
ip = extractFirst(ip);
|
||||
|
||||
String uresponse = request.getParameter("g-recaptcha-response");
|
||||
if (uresponse==null) throw new Error("captcha missing");
|
||||
|
||||
if (!verifyCaptcha(uresponse, ip)) {
|
||||
throw new UserError("Captcha mismatch. Please try again and retry a captcha to prove that you are a human");
|
||||
if (isCaptchaOn()) {
|
||||
if (uresponse == null) throw new Error("captcha missing");
|
||||
|
||||
if (!verifyCaptcha(uresponse, ip)) {
|
||||
throw new UserError("Captcha mismatch. Please try again and retry a captcha to prove that you are a human");
|
||||
}
|
||||
}
|
||||
|
||||
userid = userid.toLowerCase();
|
||||
@ -252,6 +255,10 @@ public class Application {
|
||||
return new HttpRedirect("doneMail");
|
||||
}
|
||||
|
||||
private boolean isCaptchaOn() {
|
||||
return params.recaptchaPublicKey()!=null;
|
||||
}
|
||||
|
||||
private String dumpHeaders(StaplerRequest request) {
|
||||
Enumeration headerNames = request.getHeaderNames();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
@ -26,9 +26,11 @@
|
||||
document.getElementById("hp").style.display = "none";
|
||||
]]>
|
||||
</script>
|
||||
<h5>Captcha</h5>
|
||||
<script src="https://www.google.com/recaptcha/api.js" async="true" defer="true"></script>
|
||||
<div class="g-recaptcha" data-sitekey="${it.captchaPublicKey()}"></div>
|
||||
<j:if test="${it.captchaPublicKey()}">
|
||||
<h5>Captcha</h5>
|
||||
<script src="https://www.google.com/recaptcha/api.js" async="true" defer="true"></script>
|
||||
<div class="g-recaptcha" data-sitekey="${it.captchaPublicKey()}"></div>
|
||||
</j:if>
|
||||
<br/>
|
||||
<input type="submit" style="margin-top:2em; display:block"/>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user