Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
BridgeDB
Commits
7e4a1134
Commit
7e4a1134
authored
Feb 07, 2014
by
Matthew Finkel
Browse files
Make the remoteip configurable during recaptcha verification
Closes
#10834
parent
aa835c1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
bridgedb.conf
View file @
7e4a1134
...
...
@@ -223,6 +223,9 @@ RECAPTCHA_ENABLED = False
RECAPTCHA_PUB_KEY
=
''
RECAPTCHA_PRIV_KEY
=
''
# The remoteip we send to reCAPTCHA during verification
RECAPTCHA_REMOTEIP
=
''
#-------------------------------
# Email Distribution Options \
#------------------------------------------------------------------------------
...
...
lib/bridgedb/HTTPServer.py
View file @
7e4a1134
...
...
@@ -113,11 +113,13 @@ def replaceErrorPage(error, template_name=None):
class
CaptchaProtectedResource
(
twisted
.
web
.
resource
.
Resource
):
def
__init__
(
self
,
useRecaptcha
=
False
,
recaptchaPrivKey
=
''
,
recaptchaPubKey
=
''
,
useForwardedHeader
=
False
,
resource
=
None
):
recaptchaPubKey
=
''
,
remoteip
=
''
,
useForwardedHeader
=
False
,
resource
=
None
):
self
.
isLeaf
=
resource
.
isLeaf
self
.
useForwardedHeader
=
useForwardedHeader
self
.
recaptchaPrivKey
=
recaptchaPrivKey
self
.
recaptchaPubKey
=
recaptchaPubKey
self
.
recaptchaRemoteIP
=
remoteip
self
.
resource
=
resource
def
getClientIP
(
self
,
request
):
...
...
@@ -182,9 +184,12 @@ class CaptchaProtectedResource(twisted.web.resource.Resource):
except
:
return
redirectTo
(
request
.
URLPath
(),
request
)
# generate a random IP for the captcha submission
remote_ip
=
'%d.%d.%d.%d'
%
(
randint
(
1
,
255
),
randint
(
1
,
255
),
randint
(
1
,
255
),
randint
(
1
,
255
))
if
self
.
recaptchaRemoteIP
:
remote_ip
=
self
.
recaptchaRemoteIP
else
:
# generate a random IP for the captcha submission
remote_ip
=
'%d.%d.%d.%d'
%
(
randint
(
1
,
255
),
randint
(
1
,
255
),
randint
(
1
,
255
),
randint
(
1
,
255
))
recaptcha_response
=
captcha
.
submit
(
challenge
,
response
,
self
.
recaptchaPrivKey
,
remote_ip
)
...
...
@@ -464,6 +469,7 @@ def addWebServer(cfg, dist, sched):
RECAPTCHA_ENABLED
RECAPTCHA_PUB_KEY
RECAPTCHA_PRIV_KEY
RECAPTCHA_REMOTEIP
dist -- an IPBasedDistributor object.
sched -- an IntervalSchedule object.
"""
...
...
@@ -487,6 +493,7 @@ def addWebServer(cfg, dist, sched):
protected
=
CaptchaProtectedResource
(
recaptchaPrivKey
=
cfg
.
RECAPTCHA_PRIV_KEY
,
recaptchaPubKey
=
cfg
.
RECAPTCHA_PUB_KEY
,
remoteip
=
cfg
.
RECAPTCHA_REMOTEIP
,
useForwardedHeader
=
cfg
.
HTTP_USE_IP_FROM_FORWARDED_HEADER
,
resource
=
resource
)
httpdist
.
putChild
(
'bridges'
,
protected
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment