Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Log the hostname the reCAPTCHA was completed on #946

Merged
merged 2 commits into from Jul 25, 2016

Conversation

Projects
None yet
2 participants
Member

dbkr commented Jul 22, 2016

This could be useful information to have in the logs. Also comment about how & why we don't verify the hostname.

Log the hostname the reCAPTCHA was completed on
This could be useful information to have in the logs. Also comment about how & why we don't verify the hostname.

@NegativeMjark NegativeMjark commented on an outdated diff Jul 22, 2016

synapse/handlers/auth.py
@@ -279,8 +279,17 @@ def _check_recaptcha(self, authdict, clientip):
data = pde.response
resp_body = simplejson.loads(data)
- if 'success' in resp_body and resp_body['success']:
- defer.returnValue(True)
+ if 'success' in resp_body:
+ # Note that we do NOT check the hostname here: we explicitly
+ # intend the CAPTCHA to be presented by whatever client the
+ # user is using, we just care that they have completed a CAPTCHA.
+ logger.info(
+ "%s reCAPTCHA from hostname %s",
+ "Successful" if resp_body['success'] else "Failed",
+ resp_body['hostname']
@NegativeMjark

NegativeMjark Jul 22, 2016

Contributor

Maybe use .get to default the 'hostname' key here?

 resp_body.get('hostname', "<missing hostname key>")
Contributor

NegativeMjark commented Jul 22, 2016 edited

LGTM other than the possibility for KeyErrors
(Which is probably what's causing the test failures)

Member

dbkr commented Jul 22, 2016

Done. Are these tests still 'expected' to fail?

Contributor

NegativeMjark commented Jul 22, 2016

Done. Are these tests still 'expected' to fail?

No, but they're now failing due to changes that were snuck in while the CI was broken :(.

Contributor

NegativeMjark commented Jul 25, 2016

LGTM

@dbkr dbkr merged commit 4fcdf7b into develop Jul 25, 2016

8 of 10 checks passed

Sytest Dendron (Commit) Build #326 origin/dbkr/log_recaptcha_hostname failed in 6 min 24 sec
Details
Sytest Dendron (Merged PR) Build finished.
Details
Flake8 + Packaging (Commit) Build #1214 origin/dbkr/log_recaptcha_hostname succeeded in 34 sec
Details
Flake8 + Packaging (Merged PR) Build finished.
Details
Sytest Postgres (Commit) Build #1161 origin/dbkr/log_recaptcha_hostname succeeded in 6 min 53 sec
Details
Sytest Postgres (Merged PR) Build finished.
Details
Sytest SQLite (Commit) Build #1185 origin/dbkr/log_recaptcha_hostname succeeded in 5 min 47 sec
Details
Sytest SQLite (Merged PR) Build finished.
Details
Unit Tests (Commit) Build #1251 origin/dbkr/log_recaptcha_hostname succeeded in 2 min 29 sec
Details
Unit Tests (Merged PR) Build finished.
Details

@richvdh richvdh deleted the dbkr/log_recaptcha_hostname branch Dec 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment