Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Replace client_secret with <redacted> in server logs #6158

Merged
merged 2 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6158.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Redact `client_secret` in server logs.
6 changes: 4 additions & 2 deletions synapse/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ def cancelled_to_request_timed_out_error(value, timeout):


ACCESS_TOKEN_RE = re.compile(r"(\?.*access(_|%5[Ff])token=)[^&]*(.*)$")
CLIENT_SECRET_RE = re.compile(r"(\?.*client(_|%5[Ff])secret=)[^&]*(.*)$")


def redact_uri(uri):
"""Strips access tokens from the uri replaces with <redacted>"""
return ACCESS_TOKEN_RE.sub(r"\1<redacted>\3", uri)
"""Strips sensitive information from the uri replaces with <redacted>"""
uri = ACCESS_TOKEN_RE.sub(r"\1<redacted>\3", uri)
return CLIENT_SECRET_RE.sub(r"\1<redacted>\3", uri)


class QuieterFileBodyProducer(FileBodyProducer):
Expand Down