Go to file
Brennan Kinney f3a7f08f96
tests: Revise OAuth2 tests (#3795)
* tests: OAuth2 - Replace Python `/userinfo` endpoint with Caddy

Better documented, easier flow and separation of concerns via Caddy.

The python code had additional noise related to setting up a basic API which is abstracted away via `Caddyfile` config that's dedicated to this task.

* tests: OAuth2 - Minimize noise + Improve test assertion

Caddyfile can use an Access Token instead of a JWT. Much smaller and correct for this OAuth2 configuration. This new value has been documented inline.

Likewise the `sub` field returned is not important to this test. `email_verified` is kept as it may be helpful for further coverage testing.

The actual test-case has better assertions for success and failure by checking for Dovecot logs we expect instead of netcat response.

`oauth2` to `auth` for the Caddy container hostname is not necessary, just a more generic subdomain choice.

* tests: OAuth2 - Caddyfile `imap/xoauth2` route dynamic via query string

This way is more flexible and doesn't require modifying the `Caddyfile` directly, while still easy to use.

Additionally simplifies understanding the Caddyfile to maintainers by removing the `route` directive that was required to ensure a deterministic order of vars.

* tests: OAuth2 - `/imap/xoauth2` respond with IMAP commands for netcat

Since this is the only intended usage, might as well have it respond with the full file content.

* tests: OAuth2 - Implement coverage for `OAUTHBEARER`

Caddyfile route for `/imap/` now accepts any subpath to support handling both `xoauth2` and `oauthbearer` subpaths.

Both SASL mechanisms represent the same information, with `XOAUTH2` being a common mechanism to encounter defined by Google, whilst `OAUTHBEARER` is the newer variant standardized by RFC 7628 but not yet as widely adopted.

The request to `/userinfo` endpoint will be the same, only the `credentials` value to be encoded differs.

Instead of repeating the block for a similar route, this difference is handled via the Caddyfile `map` directive.

We match the path context (_`/xoauth2` or `/oauthbearer`, the `/imap` prefix was stripped by `handle_path` earlier_), when there is a valid match, `sasl_mechanism` and `credentials` map vars are created and assigned to be referenced by the later `respond` directive.

---

Repeat the same test-case logic, DRY with log asserts extracted to a common function call. This should be fine as the auth method will be sufficient to match against or a common failure caught.

* tests: OAuth2 - Minor revisions

Separate test cases and additional comment on creating the same base64 encoded credentials via CLI as an alternative to running Caddy.

Added a simple `compose.yaml` for troubleshooting or running the container for the `/imap/xoauth2` / `/imap/oauthbearer` endpoints.

* tests: OAuth2 - Route endpoints in Caddyfile with snippets instead

`reverse_proxy` was a bit more convenient, but the additional internal ports weren't really relevant. It also added noise to logging when troubleshooting.

The `import` directive with Snippet blocks instead is a bit cleaner, but when used in a single file snippets must be defined prior to referencing them with the `import` directive.

---

`compose.yaml` inlines the examples, with slight modification to `localhost:80`, since the Caddyfile examples `auth.example.test` is more relevant to the tests which can use it, and not applicable to troubleshooting locally outside of tests.

* chore: Add entry to `CHANGELOG.md`

* chore: Additional context on access token
2024-01-20 10:49:09 +01:00
.github docs: misc improvements (#3773) 2024-01-16 08:38:08 +00:00
config-examples docs: Fix typos (#3443) 2023-07-27 12:24:36 +12:00
docs docs: Guidance for binding outbound SMTP with multiple interfaces available (#3465) 2024-01-19 14:58:20 +13:00
target docs: Add maintenance comment for `reject_unknown_sender_domain` (#3793) 2024-01-20 17:51:32 +13:00
test tests: Revise OAuth2 tests (#3795) 2024-01-20 10:49:09 +01:00
.all-contributorsrc Update contributors (#2143) 2021-08-28 15:23:11 +02:00
.dockerignore Update check (#1951) 2021-05-19 21:18:06 +02:00
.editorconfig ci(fix): Normalize for `.gitattributes` + improve `eclint` coverage (#3566) 2023-10-04 12:53:32 +02:00
.gitattributes ci: `.gitattributes` - Ensure `eol=lf` for shell scripts (#3755) 2024-01-08 09:34:24 +13:00
.gitignore feat: Auth - OAuth2 (Dovecot PassDB) (#3480) 2024-01-13 09:45:14 +13:00
.gitmodules removal: configomat (submodule) (#3045) 2023-02-05 12:39:05 +01:00
CHANGELOG.md tests: Revise OAuth2 tests (#3795) 2024-01-20 10:49:09 +01:00
CODE_OF_CONDUCT.md docs(fix): Update wiki references to the new docs url 2021-03-25 11:49:24 +13:00
CONTRIBUTORS.md docs: updated `CONTRIBUTORS.md` (#3777) 2024-01-14 14:08:27 +01:00
Dockerfile feat: Add MTA-STS support for outbound mail (#3592) 2024-01-13 21:37:20 +13:00
LICENSE Final Migration Step (#6) 2021-01-16 10:16:05 +01:00
Makefile ci: add `run-local-instance` target to `Makefile` (#3663) 2023-12-04 10:28:40 +13:00
README.md feat: Auth - OAuth2 (Dovecot PassDB) (#3480) 2024-01-13 09:45:14 +13:00
SECURITY.md ci/docs: add vulnerability scanning workflow & security policy (#3106) 2023-02-23 08:53:12 +01:00
VERSION release: v13.2.0 (#3746) 2024-01-04 22:14:51 +01:00
compose.yaml compose.yaml: Add comment about disabled authentication on port 25 (#3464) 2023-08-14 01:58:54 +02:00
mailserver.env fix: Revert quoting `SA_SPAM_SUBJECT` in `mailserver.env` (#3767) 2024-01-15 11:23:23 +13:00
setup.sh Change 'while' style (#3365) 2023-05-26 01:39:39 +02:00

README.md

Docker Mailserver

ci::status docker::pulls documentation::badge

📃 About

A production-ready fullstack but simple containerized mail server (SMTP, IMAP, LDAP, Anti-spam, Anti-virus, etc.). Only configuration files, no SQL database. Keep it simple and versioned. Easy to deploy and upgrade. Originally created by @tomav, this project is now maintained by volunteers since January 2021.

💡 Documentation

We provide a dedicated documentation hosted on GitHub Pages. Make sure to read it as it contains all the information necessary to set up and configure your mail server. The documentation is crafted with Markdown & MkDocs Material.

💥 Issues

If you have issues, please search through the documentation for your version before opening an issue. The issue tracker is for issues, not for personal support. Make sure the version of the documentation matches the image version you're using!

  1. FAQ
  2. Usage
  3. Examples
  4. Issues and Contributing
  5. Release Notes
  6. Environment Variables
  7. Updating

📦 Included Services