Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #720

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions docs/development/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Getting started

The easiest way to get started with Userli is to use podman or docker.
We provide a `docker-compose.yml` file that starts Userli, Dovecot and MariaDB.
We provide a `docker-compose.yml` file that starts Userli, Dovecot and MariaDB to set up a development environment.

## Requirements

- `docker-compose` or `podman-compose`
- `yarn` (or `yarn-pkg` on Ubuntu or Debian based systems)
- `composer`

!!! info
If you don't have podman or docker installed, you can find the installation instructions on the [podman website](https://podman.io/getting-started/installation) or the [docker website](https://docs.docker.com/get-docker/).

## Set up

Start Userli, Dovecot and MariaDB with podman or docker:
Start the containers:

=== "podman"

Expand All @@ -21,37 +27,36 @@ Start Userli, Dovecot and MariaDB with podman or docker:
docker compose up -d
```

Install dependencies and run composer scripts:
!!! info
`$command compose up -d` will initiate building the containers on first run. Append `--build` to force a full rebuild



Install PHP dependencies, run composer scripts and update assets:


```shell
composer install --ignore-platform-reqs
yarn
yarn encore dev
```

Initialize the database:
Initialize the database and install sample data:

=== "podman"

```shell
podman compose exec userli bin/console doctrine:schema:create
```

=== "docker"
```shell
docker compose exec userli bin/console doctrine:schema:create
```

Install sample data:

=== "podman"
```shell
podman compose exec userli bin/console doctrine:fixtures:load
```

=== "docker"
```shell
docker compose exec userli bin/console doctrine:schema:create
docker compose exec userli bin/console doctrine:fixtures:load
```


Open your browser and go to [http://localhost:8000](http://localhost:8000)


Expand Down
43 changes: 0 additions & 43 deletions docs/installation/checkpassword.md

This file was deleted.

63 changes: 63 additions & 0 deletions docs/installation/dovecot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Dovecot Authentication

Userli provides an API for `userdb` and `passdb` lookups.
This can be used to authenticate users with Dovecot by using [Lua based authentication](https://doc.dovecot.org/2.3/configuration_manual/authentication/lua_based_authentication/).
An adapter script is provided in the source code in `contrib/dovecot/userli.lua`.

If the mailcrypt is enabled in Userli, the Lua adapter will also forward the required key material with each lookup.

## On the Userli Host

In `.env.local`, following environment variables needs to be configured:

```shell
DOVECOT_API_ENABLED=true
DOVECOT_API_IP_ALLOWLIST="127.0.0.1, ::1"
DOVECOT_API_ACCESS_TOKEN="replace-me-with-a-secure-token"
```

## On the Dovecot host

### Prerequisites

* `lua`
* `json-lua`
* `dovecot-auth-lua`

### Example configuration

`/etc/dovecot/conf.d/auth-lua.conf.ext`:

```text
import_environment=USERLI_API_ACCESS_TOKEN USERLI_HOST DOVECOT_LUA_DEBUG DOVECOT_LUA_INSECURE

passdb {
driver = lua
args = file=/path/to/userli-adapter.lua blocking=yes
}

userdb {
driver = lua
args = file=/path/to/userli-adapter.lua blocking=yes
}
```

Export the env vars to be picked up by Dovecots `import_environment` config:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not understand right away how and where I have to export the env vars.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to make the role of Dovecots import statement more clear


- `USERLI_API_ACCESS_TOKEN` (mandatory)
- `USERLI_HOST` (mandatory)
- `DOVECOT_LUA_AGENT`, defaults "Dovecot-Lua-Auth"
- `DOVECOT_LUA_INSECURE`, to connect to the Userli host via unencrypted HTTP, defaults to `false`
- `DOVECOT_LUA_DEBUG`, defaults to `false`
- `DOVECOT_LUA_MAX_ATTEMPTS`, defaults to `3`
- `DOVECOT_LUA_TIMEOUT`, defaults to `10000`

## MailCrypt

In order to enable MailCrypt in Dovecot, the following is required:

* Add `mail_crypt` to the `mail_plugins` list in `/etc/dovecot/conf.d/10-mail.conf`
* Set `mail_crypt_save_version = 0` in `/etc/dovecot/conf.d/90-mail-crypt.conf`

The latter disables MailCrypt per default and is necessary to not break incoming mail for legacy users without MailCrypt keys.
The Lua adapter automatically sets `mail_crypt_save_version = 2` for all users with MailCrypt keys.
15 changes: 3 additions & 12 deletions docs/mail_crypt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
The software has builtin support for
[Dovecot's mailbox encryption](https://wiki.dovecot.org/Plugins/MailCrypt), using the
[global keys mode](https://wiki.dovecot.org/Plugins/MailCrypt#Global_keys).
Keys are created and maintained by userli and handed over to Dovecot via
`checkpassword` script.
Keys are created and maintained by userli and handed over via an API and can
be consumed by Dovecot by a Lua script. See [here](/installation/dovecot)
for how to configure authentication and mailcrypt in Dovecot.

The MailCrypt feature is enabled per default and can optionally be switched
off globally by setting `MAIL_CRYPT=0` in the dotenv (`.env`) file.
Expand All @@ -20,16 +21,6 @@ have MailCrypt enabled per default, you can set `MAIL_CRYPT=1` in the dotenv
* `MAIL_CRYPT=3` - Enforce MailCrypt key generation for all users, see the
documentation about migrating legacy users for more info

In order to enable MailCrypt in Dovecot, the following is required:

* Add `mail_crypt` to the `mail_plugins` list in `/etc/dovecot/conf.d/10-mail.conf`
* Set `mail_crypt_save_version = 0` in `/etc/dovecot/conf.d/90-mail-crypt.conf`

The latter disables MailCrypt per default and is necessary to not break
incoming mail for legacy users without MailCrypt keys. The checkpassword script
automatically sets `mail_crypt_save_version = 2` for all users with MailCrypt
keys.

MailCrypt can be turned on/off for individual users by setting the `mail_crypt`
switch in the `virtual_users` database table. This switch is mainly meant to
provide a migration path from legacy users without MailCrypt keys. On new
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ nav:
- Tests: development/tests.md
- Installation:
- Installation: installation/index.md
- Checkpassword: installation/checkpassword.md
- Commands: installation/commands.md
- Configuration: installation/configuration.md
- Customize: installation/customize.md
- Database: installation/database.md
- Dovecot: installation/dovecot.md
- Finalize: installation/finalize.md
- Webserver: installation/webserver.md
- MailCrypt:
Expand Down
Loading