Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
37e53513
Commit
37e53513
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Add config opion for XFF headers when performing ReCaptcha auth.
parent
1829b55b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/config/captcha.py
+6
-0
6 additions, 0 deletions
synapse/config/captcha.py
synapse/handlers/register.py
+1
-0
1 addition, 0 deletions
synapse/handlers/register.py
synapse/rest/register.py
+5
-2
5 additions, 2 deletions
synapse/rest/register.py
with
12 additions
and
2 deletions
synapse/config/captcha.py
+
6
−
0
View file @
37e53513
...
@@ -20,6 +20,7 @@ class CaptchaConfig(Config):
...
@@ -20,6 +20,7 @@ class CaptchaConfig(Config):
super
(
CaptchaConfig
,
self
).
__init__
(
args
)
super
(
CaptchaConfig
,
self
).
__init__
(
args
)
self
.
recaptcha_private_key
=
args
.
recaptcha_private_key
self
.
recaptcha_private_key
=
args
.
recaptcha_private_key
self
.
enable_registration_captcha
=
args
.
enable_registration_captcha
self
.
enable_registration_captcha
=
args
.
enable_registration_captcha
self
.
captcha_ip_origin_is_x_forwarded
=
args
.
captcha_ip_origin_is_x_forwarded
@classmethod
@classmethod
def
add_arguments
(
cls
,
parser
):
def
add_arguments
(
cls
,
parser
):
...
@@ -33,4 +34,9 @@ class CaptchaConfig(Config):
...
@@ -33,4 +34,9 @@ class CaptchaConfig(Config):
"
--enable-registration-captcha
"
,
type
=
bool
,
default
=
False
,
"
--enable-registration-captcha
"
,
type
=
bool
,
default
=
False
,
help
=
"
Enables ReCaptcha checks when registering, preventing signup
"
+
help
=
"
Enables ReCaptcha checks when registering, preventing signup
"
+
"
unless a captcha is answered. Requires a valid ReCaptcha public/private key.
"
"
unless a captcha is answered. Requires a valid ReCaptcha public/private key.
"
)
group
.
add_argument
(
"
--captcha_ip_origin_is_x_forwarded
"
,
type
=
bool
,
default
=
False
,
help
=
"
When checking captchas, use the X-Forwarded-For (XFF) header as the client IP
"
+
"
and not the actual client IP.
"
)
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/handlers/register.py
+
1
−
0
View file @
37e53513
...
@@ -59,6 +59,7 @@ class RegistrationHandler(BaseHandler):
...
@@ -59,6 +59,7 @@ class RegistrationHandler(BaseHandler):
captcha_info
[
"
response
"
]
captcha_info
[
"
response
"
]
)
)
if
not
captcha_response
[
"
valid
"
]:
if
not
captcha_response
[
"
valid
"
]:
logger
.
info
(
"
Invalid captcha entered from %s
"
,
captcha_info
[
"
ip
"
])
raise
InvalidCaptchaError
(
raise
InvalidCaptchaError
(
error_url
=
captcha_response
[
"
error_url
"
]
error_url
=
captcha_response
[
"
error_url
"
]
)
)
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/register.py
+
5
−
2
View file @
37e53513
...
@@ -66,8 +66,11 @@ class RegisterRestServlet(RestServlet):
...
@@ -66,8 +66,11 @@ class RegisterRestServlet(RestServlet):
# TODO determine the source IP : May be an X-Forwarding-For header depending on config
# TODO determine the source IP : May be an X-Forwarding-For header depending on config
ip_addr
=
request
.
getClientIP
()
ip_addr
=
request
.
getClientIP
()
#if self.hs.config.captcha_ip_origin_is_x_forwarded:
if
self
.
hs
.
config
.
captcha_ip_origin_is_x_forwarded
:
# # use the header
# use the header
if
request
.
requestHeaders
.
hasHeader
(
"
X-Forwarded-For
"
):
ip_addr
=
request
.
requestHeaders
.
getRawHeaders
(
"
X-Forwarded-For
"
)[
0
]
captcha
=
{
captcha
=
{
"
ip
"
:
ip_addr
,
"
ip
"
:
ip_addr
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment