Mailman: Difference between revisions

imported>Benley
Add TOC and upstream docs link
imported>Benley
Explain social logins
Line 1: Line 1:
__TOC__
__TOC__


== Running Mailman on NixOS ==
= Running Mailman on NixOS =


Requires at least NixOS 20.03; the <code>services.mailman</code> module in NixOS 19.09 is insufficient.
Requires at least NixOS 20.03; the <code>services.mailman</code> module in NixOS 19.09 is insufficient.
Line 11: Line 11:
* letsencrypt to acquire TLS certificates for nginx
* letsencrypt to acquire TLS certificates for nginx


=== Deployment steps ===
== Deployment steps ==


* Edit <code>/etc/nixos/configuration.nix</code> and add this stuff:
* Edit <code>/etc/nixos/configuration.nix</code> and add this stuff:
Line 122: Line 122:


At this point you should have a working Mailman installation.  Create and manage lists using the web interface or the <code>mailman</code> commandline tool, and refer to the [https://docs.mailman3.org/ upstream documentation] for lots more information.
At this point you should have a working Mailman installation.  Create and manage lists using the web interface or the <code>mailman</code> commandline tool, and refer to the [https://docs.mailman3.org/ upstream documentation] for lots more information.
== Optional extras ==
=== Social logins ===
Mailman 3 uses [https://django-allauth.readthedocs.io/ django-allauth] to allow logins via many external auth providers, such as GitHub and Google.  To enable these we need to update our Django settings and add some per-provider specifics in the admin UI.
In this example we're just adding GitHub, but there are [https://django-allauth.readthedocs.io/en/latest/providers.html lots of other providers] available.
* Add to your <code>configuration.nix</code> and run <code>nixos-rebuild switch</code>:
<syntaxhighlight lang="nix">
  # Extend the django settings.py directly since this can't all be
  # done via JSON settings (services.mailman.webSettings)
  environment.etc."mailman3/settings.py".text = ''
    INSTALLED_APPS.extend([
      "allauth.socialaccount.providers.github",
    ])
  '';
</syntaxhighlight>
* Register a new OAuth application on GitHub at https://github.com/settings/applications/new.  Your Authorization Callback URL will be <code>https://<your_mailman_hostname>/accounts/github/login/callback/</code>.  Save the Client ID and Client Secret that GitHub gives you at the end of this process.
* Navigate to <code>https://<your_mailman_hostname>/admin/socialaccount/socialapp/add/</code> and fill in the values you got from GitHub.  Make sure you click '''Choose all''' to enable this auth provide for your django site, then click '''Save'''.
*: [[File:Django_admin_add_social_application.png]]
Now you should be able to login to your mailman site with GitHub, and see your account's connections at <code>https://<your_mailman_hostname>/accounts/social/connections/</code>