Added instructions for setting up captcha in an obviously named file.

pull/10/head
Kegan Dougal 2014-09-05 23:32:07 -07:00
parent b5749c75d9
commit a342867d3f
3 changed files with 54 additions and 11 deletions

46
webclient/CAPTCHA_SETUP Normal file
View File

@ -0,0 +1,46 @@
Captcha can be enabled for this web client / home server. This file explains how to do that.
The captcha mechanism used is Google's ReCaptcha. This requires API keys from Google.
Getting keys
------------
Requires a public/private key pair from:
https://developers.google.com/recaptcha/
Setting Private ReCaptcha Key
-----------------------------
The private key is a config option on the home server config. If it is not
visible, you can generate it via --generate-config. Set the following value:
recaptcha_private_key: YOUR_PRIVATE_KEY
In addition, you MUST enable captchas via:
enable_registration_captcha: true
Setting Public ReCaptcha Key
----------------------------
The web client will look for the global variable webClientConfig for config
options. You should put your ReCaptcha public key there like so:
webClientConfig = {
useCaptcha: true,
recaptcha_public_key: "YOUR_PUBLIC_KEY"
}
This should be put in webclient/config.js which is already .gitignored, rather
than in the web client source files. You MUST set useCaptcha to true else a
ReCaptcha widget will not be generated.
Configuring IP used for auth
----------------------------
The ReCaptcha API requires that the IP address of the user who solved the
captcha is sent. If the client is connecting through a proxy or load balancer,
it may be required to use the X-Forwarded-For (XFF) header instead of the origin
IP address. This can be configured as an option on the home server like so:
captcha_ip_origin_is_x_forwarded: true

View File

@ -11,14 +11,3 @@ Then, open this URL in a WEB browser::
http://127.0.0.1:8000/ http://127.0.0.1:8000/
ReCaptcha Keys
--------------
The web client will look for the global variable webClientConfig for config options. You should
put your ReCaptcha public key there like so:
webClientConfig = {
recaptcha_public_key: "YOUR_PUBLIC_KEY"
}
This should be put in webclient/config.js which is already .gitignored, rather than in the web
client source files.

View File

@ -19,7 +19,11 @@ angular.module('RegisterController', ['matrixService'])
function($scope, $rootScope, $location, matrixService, eventStreamService) { function($scope, $rootScope, $location, matrixService, eventStreamService) {
'use strict'; 'use strict';
var config = window.webClientConfig;
var useCaptcha = true; var useCaptcha = true;
if (config !== undefined) {
useCaptcha = config.useCaptcha;
}
// FIXME: factor out duplication with login-controller.js // FIXME: factor out duplication with login-controller.js
@ -132,6 +136,10 @@ angular.module('RegisterController', ['matrixService'])
else if (error.data.errcode == "M_CAPTCHA_INVALID") { else if (error.data.errcode == "M_CAPTCHA_INVALID") {
$scope.feedback = "Failed captcha."; $scope.feedback = "Failed captcha.";
} }
else if (error.data.errcode == "M_CAPTCHA_NEEDED") {
$scope.feedback = "Captcha is required on this home " +
"server.";
}
} }
else if (error.status === 0) { else if (error.status === 0) {
$scope.feedback = "Unable to talk to the server."; $scope.feedback = "Unable to talk to the server.";