Skip to content

docs: Add Dovecot Lua auth guide + required package#3579

Merged
polarathene merged 11 commits intodocker-mailserver:masterfrom
Zepmann:add-dovecot-lua
Nov 8, 2023
Merged

docs: Add Dovecot Lua auth guide + required package#3579
polarathene merged 11 commits intodocker-mailserver:masterfrom
Zepmann:add-dovecot-lua

Conversation

@Zepmann
Copy link
Copy Markdown
Contributor

@Zepmann Zepmann commented Oct 12, 2023

Description

This PR adds Lua support for Dovecot and documentation with an example usage for authentication. Lua authentication can be used to make Dovecot (and Postfix through Dovecot) authenticate against a web server or against anything else that can be used in Lua.

As discussed in #3575, a new xapian situation should be avoided. This PR relies on a standard Dovecot deb package that requires minimum change and maintenance as long as Dovecot deb packages are used. The documentation has a warning that there is minimal support for Lua, and that Lua support will be removed if it does not align with the development of DMS anymore for some reason.

Another warning in the documentation tells users that Lua authentication is an advanced topic, and that they should not open issues for questions about Lua scripting or bother DMS contributors about it.

Fixes #3575.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update - The documentation is included.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Oct 13, 2023

I am informed that this makes the ARM64 build fail. I'll look into it.

Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review pass.

That was a much larger docs contribution than I expected! I appreciate it though 😁

I'll provide some more revision after the current feedback is addressed. Great work so far!

Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread target/scripts/build/packages.sh Outdated
@polarathene
Copy link
Copy Markdown
Member

polarathene commented Oct 13, 2023

I am informed that this makes the ARM64 build fail. I'll look into it.

And I probably should have checked the test suite before diving into a review 😰 (I think it took me roughly 2 hours)

Here's the ARM64 failure:

Unable to locate package dovecot-lua

This is one of those maintenance concerns I raised initially. The Debian package doesn't have an ARM64 variant available. Actually it seems the package name is wrong, where did you get dovecot-lua from? It seems to be dovecot-auth-lua (has full platform support)?

The other test failure with Fail2Ban is unrelated, that's been acting up lately for unknown reasons.


I'm a bit surprised though, as for some reason our AMD64 build was successful. It should not have used a cache due to packages.sh being updated...

This COPY for packages.sh has been treated as CACHED for some reason 🤔

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Oct 13, 2023

Not going into all of your extensive review points of the documentation at the moment. They are good points, and I will update the documentation. 😄

I am informed that this makes the ARM64 build fail. I'll look into it.

And I probably should have checked the test suite before diving into a review 😰 (I think it took me roughly 2 hours)

Here's the ARM64 failure:

Unable to locate package dovecot-lua

This is one of those maintenance concerns I raised initially. The Debian package doesn't have an ARM64 variant available. Actually it seems the package name is wrong, where did you get dovecot-lua from? It seems to be dovecot-auth-lua (has full platform support)?

tools/scripts/build/packages.sh imports the Dovecot deb community repo. This repository provides only x86_64 packages, and it uses package name dovecot-lua for Dovecot's Lua support (dovecot-auth-lua is just a dummy package in this repository, which is the reason it is available for all architectures).

If building on ARM64, the Debian repositories are used since Dovecot's community repository is unable to provide ARM64 packages. Debian repositories use package name dovecot-auth-lua for Dovecot's Lua support.

I will change packages.sh so that Dovecot's community repository is not used when not compiling for x86_64, and I will make it use the right Lua package name for each situation.

The other test failure with Fail2Ban is unrelated, that's been acting up lately for unknown reasons.

Thanks for the notification. I'll ignore these test failures if they pop up for me.

@polarathene
Copy link
Copy Markdown
Member

tools/scripts/build/packages.sh imports the Dovecot deb community repo. This repository provides only x86_64 packages, and it uses package name dovecot-lua for Dovecot's Lua support

Ah thanks for that clarification.

Resolved

I'm not fond of the community repo myself since that's been causing various issues, especially with preventing upgrading to Debian 12.

  • One maintainer wants to push towards Alpine as a new base image, but I'm reluctant towards that from my own experience of many issues encountered with that.
  • I'm more inclined towards Fedora as the base image going forward, but it lacks a reliable package repo for rspamd last I checked.

The only reason we use the community repo for Dovecot AFAIK, was due to needing a version newer than Debian 11 provided. While another maintainer is reluctant to use the Debian 12 Dovecot release as the version is behind the community repo, but Debian 12 won't be supported by the community repo until Dovecot 2.4/3.0 is released AFAIK.

Bit of a predicament 😅


@casperklein @georglauterbach how do you want to resolve this?

  • Defer until Debian 12 upgade.
  • Defer until base image switch
  • Conditionally build for AMD64

I will change packages.sh so that Dovecot's community repository is not used when not compiling for x86_64, and I will make it use the right Lua package name for each situation.

I have a bad habit of replying too eagerly and didn't read this far 😑 Well that's sorted then 👍

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Oct 13, 2023

The only reason we use the community repo for Dovecot AFAIK, was due to needing a version newer than Debian 11 provided. While another maintainer is reluctant to use the Debian 12 Dovecot release as the version is behind the community repo, but Debian 12 won't be supported by the community repo until Dovecot 2.4/3.0 is released AFAIK.

I read this as that there is a Dovecot version difference between DMS on x86_64 and ARM64. After some testing, it turns out this is true.

x86_64: Dovecot 2.3.21 (from the community repo)
ARM64: Dovecot 2.3.13 (from Debian's repo)

I do agree that this is quite a conundrum if stability is preferred and you wish to avoid community repos. Still, if you consider the rspamd community repository for Fedora, they do provide ARM64 packages in their rpm repositores, unlike Dovecot (rspamd's documentation seems to be lagging behind on this). That would at least take care of the software version discrepancy between architectures, and any headaches that might cause.

I have a bad habit of replying too eagerly and didn't read this far 😑 Well that's sorted then 👍

All is forgiven. Please provide the same courtesy if I do that at some point (which I try to avoid, but no guarantees!). 😄

I'll keep working on this PR in the coming few days.

@polarathene

This comment was marked as resolved.

@Zepmann

This comment was marked as resolved.

@casperklein

This comment was marked as resolved.

@polarathene

This comment was marked as resolved.

@polarathene

This comment was marked as resolved.

@Zepmann

This comment was marked as resolved.

@polarathene

This comment was marked as resolved.

@Zepmann

This comment was marked as resolved.

@georglauterbach
Copy link
Copy Markdown
Member

I do not have the time to read through the whole thread, so here are my two cents:

The version discrepancy of Dovecot between amd64 and arm64 is similar to Rspamd, and not an issue if you ask me. It is not perfect, and I try to keep the differences for Rspamd at a minimum. We should not care about this at the moment if you ask me.

About the newly added package: this may sound harsh, but I really don't see why this could not be done with user-patches.sh. I really appreciate the Documentation effort, and I think we should merge that 🚀 But I see bigger maintenance issues on the horizon with the package addition. So, can we maybe only merge an adjusted version of the new documentation?

@polarathene
Copy link
Copy Markdown
Member

@georglauterbach

I really don't see why this could not be done with user-patches.sh.

This was explained in their response prior to two maintainer approvals: #3575 (comment)

_ All I did was add dovecot-lua to the package list in packages.sh (and disable my user-patches.sh, of course). Lua support in Dovecot works immediately.
I would not like to use user-patches.sh, since the deb packages in the image do not have to be in sync with the deb packages in Dovecot's repository.

Previously they had been using user-patches.sh, but the concern was due to third-party repo not being in sync with image release. Since we don't regularly update any tags beyond :edge due to current CI infrastructure this is a valid concern while the Dovecot community repo remains the default in builds.

In my docs review I have pointed out that they may need to rely on user-patches.sh in future for other changes to reliably be applied, as replacing entire Dovecot config files for small changes is not advisable, especially when it's a custom config we override with file replacement ourselves (as has been problematic for some users when we changed the Dovecot SASL auth socket file path).

But the package concern AFAIK is valid to warrant inclusion into the image instead of user-patches.sh.


I see bigger maintenance issues on the horizon with the package addition.

As per the issue link with maintainer approvals and my docs review feedback above, maintainers have been very clear that @Zepmann is responsible for resolving any related maintenance issues that arise with the inclusion of this package.

If it causes us any problems that are not resolved to maintainer satisfaction in a timely manner, the package will be dropped in a future release. This is the stance for any community contributed packages / features that are deemed niche like fetchmail and getmail (which also lack thorough testing).

To further take that stance, I've also suggested like the debug group in packages.sh we do something similar for community contributed packages, so that the distinction for maintenance is clear.

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Oct 20, 2023

I have updated the documentation based on comments from @polarathene. Furthermore, I changed packages.sh so that the Dovecot community repository is only used when relevant (i.e. the platform is x86_64). This fixes the ARM build issue.

Everything works with the current development version of DMS. As discussed, there will be changes to DMS in the future that will break the example in the documentation. I think it is best to start with a new PR when that time comes. This is a community effort, and as such it is no issue if it lags behind official development and breaks sometimes. The documentation also notes this as a warning for any users who want to use Lua-based authentication.

@Zepmann Zepmann requested a review from polarathene October 20, 2023 11:15
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for taking the time to address and respond to feedback 😁

Two changes remaining:

  • Add title to admonition example.
  • Address feedback for packages.sh.

The two large review comments are responses to prior discussion and can be ignored. One debates the relevance of mkdir and docker cp (vs clearly documenting an explicit userdb config override for the versioned release at time of writing), but I won't block on either of these.


Should the lua auth docs be part of the config docs, or would they be better suited in the examples section? (tutorials / use-cases)

Seems like it may be better suited there given the focus as a community guide? Up to you :)

Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread docs/content/config/advanced/auth-lua.md
Comment thread docs/content/config/advanced/auth-lua.md Outdated
Comment thread target/scripts/build/packages.sh Outdated
Comment thread target/scripts/build/packages.sh Outdated
@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Oct 31, 2023

This PR is not forgotten. I'll pick it up later this week.

@georglauterbach georglauterbach added kind/new feature A new feature is requested in this issue or implemeted with this PR service/dovecot labels Oct 31, 2023
@georglauterbach georglauterbach added this to the v13.1.0 milestone Oct 31, 2023
@georglauterbach
Copy link
Copy Markdown
Member

I've marked this for v13.1.0. The next release is v13.0.0, so this PR will not block on v13.0.0

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Nov 6, 2023

Finally had some time to work on this!

I think most of the comments have been solved adequately. If not, please let me know.

Also, the Lua documentation was simplified somewhat. By configuring Nextcloud (as the server) better, it is not necessary to test in Lua (as the client) if the provided password is a Nextcloud application password. The relevant Nextcloud configuration parameters are also included now in the documentation.

Finally, I am considering adding this documentation to the examples section instead of as a main page in the advanced configuration section, but I do not know if this would make the review process harder. Therefore, please review this first, but do not merge the PR if you think it is acceptable. Instead, let me know your comments and I'll make another change to move the documentation to the proper section.

I am considering adding the documentation to the 'Use Cases' subsection of Examples. This will take the page out of the more important parts of the documentation, making it less critical if it lags behind a bit with the current state of DMS.

Most critical for this PR remains the added Lua support for Dovecot. This support is now explicitly marked as coming from the community, to make it stand out from the 'core' development of DMS. I expect that it will not be difficult to keep this support, since it is not hard to enable Lua support with any method used to build/install Dovecot. However, this depends on future versions of Dovecot keep playing nice.

Please notify me if Dovecot Lua support is ever considered problematic or a feature to be removed. This way, I can add my $ 0.02 and maybe help by solving the problem or by thinking of alternatives.

@Zepmann Zepmann requested a review from polarathene November 7, 2023 07:09
@polarathene
Copy link
Copy Markdown
Member

I am considering adding this documentation to the examples section instead of as a main page in the advanced configuration section, but I do not know if this would make the review process harder.
I am considering adding the documentation to the 'Use Cases' subsection of Examples

Yes, this sounds like a good choice 👍

Thanks for waiting for review before making the change, I had been thinking of relocating it from my initial review but I didn't want to deal with any added review friction :)

Great work, thanks for the contribution to DMS! ❤️

Please notify me if Dovecot Lua support is ever considered problematic or a feature to be removed. This way, I can add my $ 0.02 and maybe help by solving the problem or by thinking of alternatives.

Will do 👍

polarathene
polarathene previously approved these changes Nov 8, 2023
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Waiting on one last change before merge, relocation of docs to examples section.

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Nov 8, 2023

Thanks for the extensive feedback and an open mind, @polarathene. I'm looking forward to working together again in the future.

Currently I'm busy with some other stuff. I'll move the documentation page later today (as in 'within 12 hours from now', but I'll do it ASAP within that timeframe).

For expectation management, is this PR to be included in release v13.0.0 or v13.1.0, considering the timeline and the v13.1.0 milestone?

@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Nov 8, 2023

For expectation management, is this PR to be included in release v13.0.0 or v13.1.0, considering the timeline and the v13.1.0 milestone?

If this is to be merged in the next few days, it's going to be in v13.0.0. When @polarathene merges this PR, they can just adjust the milestone.

@Zepmann
Copy link
Copy Markdown
Contributor Author

Zepmann commented Nov 8, 2023

Moved the documentation. I have nothing more to add for this PR unless something new pops up. In that case, let me know! 😃

Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thanks for your patience and the great contribution! 😁

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 8, 2023

Documentation preview for this PR is ready! 🎉

Built with commit: 1f703a8

@polarathene polarathene changed the title Add support for Lua in Dovecot with documentation for Lua-based authentication docs: Add Dovecot Lua auth guide + required package Nov 8, 2023
@polarathene polarathene merged commit 290355c into docker-mailserver:master Nov 8, 2023
reneploetz pushed a commit to reneploetz/docker-mailserver that referenced this pull request Nov 14, 2023
…r#3579)

* Dovecot: add deb package dovecot-lua to support Lua scripting
* Adding documentation for Lua authentication
* Updated documentation and made a better distinction between Dovecot packages for officially supported features and for community supported features.

---------

Co-authored-by: Brennan Kinney <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation area/features kind/new feature A new feature is requested in this issue or implemeted with this PR service/dovecot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: Dovecot LUA support

4 participants