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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
f4f1cda9
Commit
f4f1cda9
authored
6 years ago
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
add ip_range_whitelist parameter to limit where ASes can connect from
parent
6350bf92
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
synapse/api/auth.py
+6
-0
6 additions, 0 deletions
synapse/api/auth.py
synapse/appservice/__init__.py
+3
-1
3 additions, 1 deletion
synapse/appservice/__init__.py
synapse/config/appservice.py
+10
-1
10 additions, 1 deletion
synapse/config/appservice.py
with
19 additions
and
2 deletions
synapse/api/auth.py
+
6
−
0
View file @
f4f1cda9
...
...
@@ -19,6 +19,7 @@ from six import itervalues
import
pymacaroons
from
twisted.internet
import
defer
from
netaddr
import
IPAddress
import
synapse.types
from
synapse
import
event_auth
...
...
@@ -244,6 +245,11 @@ class Auth(object):
if
app_service
is
None
:
defer
.
returnValue
((
None
,
None
))
if
app_service
.
ip_range_whitelist
:
ip_address
=
IPAddress
(
self
.
hs
.
get_ip_from_request
(
request
))
if
ip_address
not
in
app_service
.
ip_range_whitelist
:
defer
.
returnValue
((
None
,
None
))
if
"
user_id
"
not
in
request
.
args
:
defer
.
returnValue
((
app_service
.
sender
,
app_service
))
...
...
This diff is collapsed.
Click to expand it.
synapse/appservice/__init__.py
+
3
−
1
View file @
f4f1cda9
...
...
@@ -85,7 +85,8 @@ class ApplicationService(object):
NS_LIST
=
[
NS_USERS
,
NS_ALIASES
,
NS_ROOMS
]
def
__init__
(
self
,
token
,
hostname
,
url
=
None
,
namespaces
=
None
,
hs_token
=
None
,
sender
=
None
,
id
=
None
,
protocols
=
None
,
rate_limited
=
True
):
sender
=
None
,
id
=
None
,
protocols
=
None
,
rate_limited
=
True
,
ip_range_whitelist
=
None
):
self
.
token
=
token
self
.
url
=
url
self
.
hs_token
=
hs_token
...
...
@@ -93,6 +94,7 @@ class ApplicationService(object):
self
.
server_name
=
hostname
self
.
namespaces
=
self
.
_check_namespaces
(
namespaces
)
self
.
id
=
id
self
.
ip_range_whitelist
=
ip_range_whitelist
if
"
|
"
in
self
.
id
:
raise
Exception
(
"
application service ID cannot contain
'
|
'
character
"
)
...
...
This diff is collapsed.
Click to expand it.
synapse/config/appservice.py
+
10
−
1
View file @
f4f1cda9
...
...
@@ -17,6 +17,8 @@ from ._base import Config, ConfigError
from
synapse.appservice
import
ApplicationService
from
synapse.types
import
UserID
from
netaddr
import
IPSet
import
yaml
import
logging
...
...
@@ -154,6 +156,12 @@ def _load_appservice(hostname, as_info, config_filename):
"
will not receive events or queries.
"
,
config_filename
,
)
if
as_info
.
get
(
'
ip_range_whitelist
'
):
ip_range_whitelist
=
IPSet
(
as_info
.
get
(
'
ip_range_whitelist
'
)
)
return
ApplicationService
(
token
=
as_info
[
"
as_token
"
],
hostname
=
hostname
,
...
...
@@ -163,5 +171,6 @@ def _load_appservice(hostname, as_info, config_filename):
sender
=
user_id
,
id
=
as_info
[
"
id
"
],
protocols
=
protocols
,
rate_limited
=
rate_limited
rate_limited
=
rate_limited
,
ip_range_whitelist
=
ip_range_whitelist
,
)
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