django-mjml
django-mjml copied to clipboard
Setting necessary for allowing custom authentication/transport for http backend
Current architecture does not allow for any other authentication than 'static' HTTPBasicAuth user+password. It is impossible to authenticate MJML server via API Keys, OAuth2, custom auth header without monkey-patching or forking the code.
Simplest idea: there could be provided a new MJML_HTTP_TRANSPORT
setting with a string being dotted module path to a transport function, accepting kwargs: url, auth, data, headers, timeouts.
Such a config would allow users to procure custom authentication inside and call requests.post
or any other transport from user's code. If not provided, requests.post
could be used as-is.
Using dotted path string will avoid importing this function in settings.py - this follows typical django pattern. The transport function can be imported lazily before use through django.utils.module_loading.import_string
@alex-kowalczyk Is there any MJML backed that uses API Keys or OAuth2?