diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8b3dc5..a7d622ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,14 @@ ## Release candidate +## Breaking changes +- Config option `sender_email_address` is now called `from` (#257, PLUM Sprint 230825) + ### Fix -- Add id_token_signing_alg_values_supported in OIDC discovery (#260) +- Add `id_token_signing_alg_values_supported` in OIDC discovery (#260) + +### Features +- Unified SMTP config (#257, PLUM Sprint 230825) --- diff --git a/seacatauth/communication/builders/email.py b/seacatauth/communication/builders/email.py index f8a5191e..3faeeb24 100644 --- a/seacatauth/communication/builders/email.py +++ b/seacatauth/communication/builders/email.py @@ -1,5 +1,6 @@ import jinja2 import re +import asab from .abc import MessageBuilderABC @@ -9,19 +10,29 @@ class EmailMessageBuilder(MessageBuilderABC): Channel = "email" ConfigDefaults = { "template_extension": "html", - "sender_email_address": "auth@seacatauth.info", + "from": "auth@seacatauth.info", # "template_path": "/etc/message-templates/email/", # Inherited from [seacatauth:communication] } def __init__(self, config_section_name, config=None): super().__init__(config_section_name, config) self.JinjaEnv.autoescape = jinja2.select_autoescape(['html', 'xml']) - self.Sender = self.Config.get("sender_email_address", None) + + if "smtp" in asab.Config: + self.Config.update(asab.Config["smtp"]) + if "sender_email_address" in self.Config: + asab.LogObsolete.warning( + "Config option 'sender_email_address' in '[smtp]' has been renamed to 'from'. " + "Please update your configuration file.", + struct_data={"eol": "2024-01-31"}) + self.From = self.Config.get("sender_email_address", None) + else: + self.From = self.Config.get("from", None) def build_message(self, template_name, locale, *, email=None, **kwargs): message = super(EmailMessageBuilder, self).build_message(template_name, locale, **kwargs) message["subject"] = self._get_subject_from_body(message["message_body"]) - message["sender"] = self.Sender + message["sender"] = self.From if email is None: raise TypeError("'email' not specified") message["to"] = email diff --git a/seacatauth/communication/email_smtp.py b/seacatauth/communication/email_smtp.py index 458c6151..a1ec5954 100644 --- a/seacatauth/communication/email_smtp.py +++ b/seacatauth/communication/email_smtp.py @@ -30,6 +30,8 @@ class SMTPProvider(CommunicationProviderABC): def __init__(self, provider_id, config_section_name): super().__init__(provider_id, config_section_name) + if "smtp" in asab.Config: + self.Config.update(asab.Config["smtp"]) self.SSL = self.Config.getboolean("ssl") self.StartTLS = self.Config.getboolean("starttls") self.Host = self.Config.get("host")