Browse Source

synapse_djadhere: fix auth of the bot

Guilhem Saurel 6 years ago
parent
commit
7615adc553
2 changed files with 4 additions and 2 deletions
  1. 1 1
      matrix/Dockerfile
  2. 3 1
      matrix/synapse_djadhere.py

+ 1 - 1
matrix/Dockerfile

@@ -8,4 +8,4 @@ RUN curl -sSL https://github.com/vector-im/riot-web/releases/download/$RIOT_VERS
   | tar -xz --strip-components=1
 
 ARG SYNAPSE_FULL_URL
-RUN sed "/default_hs_url/s=https://matrix.org=//$SYNAPSE_FULL_URL=" config.sample.json > config.json
+RUN sed "/default_hs_url/s=https://matrix.org=https://$SYNAPSE_FULL_URL=" config.sample.json > config.json

+ 3 - 1
matrix/synapse_djadhere.py

@@ -11,12 +11,14 @@ from twisted.web import http
 class SynapseDjadhere(object):
     def __init__(self, config, account_handler):
         self.auth_api_token = config.auth_api_token
+        self.bot_user = config.bot_user
+        self.bot_password = config.bot_password
 
     @defer.inlineCallbacks
     def check_password(self, user_id, password):
         localpart = user_id.split(":", 1)[0][1:]
 
-        bot = user_id == self.bot_user and password == self.password
+        bot = (localpart == self.bot_user and password == self.bot_password)
 
         djadhere_response = yield treq.post(
             'https://adherents.tetaneutral.net/accounts/auth_api/%s/' %