summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-01-19 14:28:29 +0000
committerErik Johnston <erik@matrix.org>2016-01-19 14:28:29 +0000
commit7a079adc8f92e36fa31be9c4e2acfadc2537165d (patch)
tree5328090f4f508c2c452634ee362812995fdda6ea
parentUse all_ephemeral_by_room in incremental_sync_with_gap_for_room (diff)
parentUse compiled regex (diff)
downloadsynapse-7a079adc8f92e36fa31be9c4e2acfadc2537165d.tar.xz
Merge pull request #477 from matrix-org/erikj/access_token_log
Don't log urlencoded access_tokens
-rwxr-xr-xsynapse/app/homeserver.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 58a4c812f6..6928d9d3e4 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -88,6 +88,9 @@ import time
 logger = logging.getLogger("synapse.app.homeserver")
 
 
+ACCESS_TOKEN_RE = re.compile(r'(\?.*access(_|%5[Ff])token=)[^&]*(.*)$')
+
+
 def gz_wrap(r):
     return EncodingResourceWrapper(r, [GzipEncoderFactory()])
 
@@ -495,9 +498,8 @@ class SynapseRequest(Request):
         )
 
     def get_redacted_uri(self):
-        return re.sub(
-            r'(\?.*access_token=)[^&]*(.*)$',
-            r'\1<redacted>\2',
+        return ACCESS_TOKEN_RE.sub(
+            r'\1<redacted>\3',
             self.uri
         )