From c1c58122ea1ee8ef2095e53e26b9ed753ca53b2f Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Tue, 28 Nov 2023 05:14:04 +0100 Subject: [PATCH] bicep/matrix: Improve flexibility of username login It should be possible to log in with @username:pvv.ntnu.no now That way client well-known in third party clients will work it might also fix the weird logout of session issues in element --- .../services/matrix/smtp-authenticator/smtp_auth_provider.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py b/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py index ac6694f..ae4e04d 100644 --- a/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py +++ b/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py @@ -5,6 +5,7 @@ from smtplib import SMTP_SSL as SMTP import synapse from synapse import module_api +import re class SMTPAuthProvider: def __init__(self, config: dict, api: module_api): @@ -27,6 +28,10 @@ class SMTPAuthProvider: if login_type != "m.login.password": return None + # Convert `@username:server` to `username` + match = re.match(r'^@([\da-z\-\.=_\/\+]+):[\w\d\.:\[\]]+$', username) + username = match.group(1) if match else username + result = False with SMTP(self.config["smtp_host"]) as smtp: password = login_dict.get("password")