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

Add SMTP via the smtp-integrator charm #127

Merged
merged 49 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2c912c2
Rename smtp_notif_from config to notif_from
javierdelapuente Dec 12, 2023
4a8cec8
WIP add smtp integrator with unit tests
javierdelapuente Dec 14, 2023
2e7a2c1
Integration tests for smtp integrator
javierdelapuente Dec 14, 2023
2915aea
Check relation exists
javierdelapuente Dec 14, 2023
ad0cbda
Disable smtp with secrets test
javierdelapuente Dec 14, 2023
7358013
Fix linter
javierdelapuente Dec 14, 2023
ed72e9c
Revert integration test with secrets and juju 3.1
javierdelapuente Dec 15, 2023
3befa41
Revert juju version in integration tests
javierdelapuente Dec 15, 2023
404c585
Revert juju version to 2.9.45
javierdelapuente Dec 15, 2023
e3f1a7f
Disable self host runner temporarily until they have yq
javierdelapuente Dec 15, 2023
a4e84fd
Merge branch 'main' into ISD-1443-smtp-via-integrator-charm
javierdelapuente Dec 15, 2023
ca8562b
Fix integration test and parameterise it
javierdelapuente Dec 15, 2023
82f590b
Include smtp integration in the documentation
javierdelapuente Dec 15, 2023
d00595f
Set smtp integration as optional
javierdelapuente Dec 15, 2023
9bc3857
Try to fix integration test error because of empty databag
javierdelapuente Dec 15, 2023
19b832e
Improve test info in act
javierdelapuente Dec 15, 2023
01efb6c
Put the self hosted runners back
javierdelapuente Dec 15, 2023
4e1b67a
Update year for license
javierdelapuente Jan 2, 2024
34c5118
Add log when smtp databag is empty
javierdelapuente Jan 2, 2024
e898ddb
Defer the event if it cannot be processed when enabling smtp
javierdelapuente Jan 2, 2024
dd11e6b
defered -> deferred
javierdelapuente Jan 2, 2024
016653d
Update SMTPConfiguration to be a dataclass
javierdelapuente Jan 2, 2024
7c241b5
Merge branch 'main' into ISD-1443-smtp-via-integrator-charm
javierdelapuente Jan 2, 2024
7682b5a
Remove defer in enable smtp in observer
javierdelapuente Jan 3, 2024
162c7e3
Improve working of notif_from description
javierdelapuente Jan 3, 2024
4b268f6
Remove use of test manual secret to secrets.token_hex
javierdelapuente Jan 3, 2024
3e759f7
Removed unnecessary shebang
javierdelapuente Jan 3, 2024
e190d85
Remove extra space
javierdelapuente Jan 4, 2024
29adb24
Update integrations tests to juju 3 and test secrets in smtp
javierdelapuente Jan 4, 2024
3586891
Update smtp library
javierdelapuente Jan 4, 2024
a2613ef
rename method to get default notif_from value
javierdelapuente Jan 4, 2024
a04ea5e
add removed src-docs
javierdelapuente Jan 4, 2024
a48bcad
test juju 3 extra arguments to see if it works
javierdelapuente Jan 4, 2024
1ad6e1a
Try to see if another version of microk8s work
javierdelapuente Jan 4, 2024
e8aeb56
Trying microk8s 1.29-strict
javierdelapuente Jan 4, 2024
0a7a475
let's see if it works hosted runners
javierdelapuente Jan 4, 2024
b74287e
Try with microk8s 1.28
javierdelapuente Jan 4, 2024
4da1228
change mjolnir channel to stable
javierdelapuente Jan 4, 2024
afd7bb4
Remove commented code
javierdelapuente Jan 5, 2024
cd1b1ef
Revert mjolnir to edge as it is working again
javierdelapuente Jan 5, 2024
1488b98
Put smtp configuration in howto instead of tutorial
javierdelapuente Jan 5, 2024
2440393
Use function for parameter to test function
javierdelapuente Jan 5, 2024
dcf0b0a
Comment in pylint: disable=too-many-instance-attributes
javierdelapuente Jan 5, 2024
7cdce56
removed hardcoded secret in test
javierdelapuente Jan 5, 2024
3b5f906
Fail on unsecure SMTP configurations
javierdelapuente Jan 8, 2024
eb76d4e
Merge branch 'main' into ISD-1443-smtp-via-integrator-charm
javierdelapuente Jan 8, 2024
1b6de53
Update doc to explain invalid smtp configurations
javierdelapuente Jan 8, 2024
02b2454
typo. unsecure -> insecure
javierdelapuente Jan 8, 2024
5a7e105
Fix integration test. Use tls in smtp
javierdelapuente Jan 8, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
chaos-enabled: false
chaos-experiments: pod-delete
trivy-image-config: "trivy.yaml"
self-hosted-runner: true
self-hosted-runner-label: "edge"
juju-channel: 3.1/stable
channel: 1.28-strict/stable
29 changes: 4 additions & 25 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ options:
Comma separated list of IP address CIDR ranges that should be allowed for
federation, identity servers, push servers, and for checking key validity
for third-party invite events.
notif_from:
javierdelapuente marked this conversation as resolved.
Show resolved Hide resolved
type: string
description: defines the "From" address to use when sending emails.
It must be set if the SMTP integration is enabled. Defaults to server_name.
public_baseurl:
type: string
description: |
Expand All @@ -53,31 +57,6 @@ options:
Synapse server name. Must be set to deploy the charm. Corresponds to the
server_name option on Synapse configuration file and sets the
public-facing domain of the server.
smtp_enable_tls:
type: boolean
description: If enabled, STARTTLS will be used to use an encrypted SMTP
connection.
default: true
smtp_host:
type: string
description: The hostname of the SMTP host used for sending emails.
default: ''
smtp_notif_from:
type: string
description: defines the "From" address to use when sending emails.
It must be set if email sending is enabled. Defaults to server_name.
smtp_pass:
type: string
description: The password if the SMTP server requires authentication.
default: ''
smtp_port:
type: int
description: The port of the SMTP server used for sending emails.
default: 25
smtp_user:
type: string
description: The username if the SMTP server requires authentication.
default: ''
trusted_key_servers:
type: string
description: Comma separated list of trusted servers to download signing
Expand Down
36 changes: 36 additions & 0 deletions docs/how-to/configure-smtp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# How to integrate with SMTP for sending notifications

This document shows how to integrate Synapse with SMTP for sending
emails. Synapse should be deployed beforehand.

## Deploy smtp-integrator charm

For synapse to use SMTP, it uses the smtp-integrator charm. Replace the configuration options with your specific configuration.
Configuring SMTP without tls or starttls or without authentication is not supported.

```
juju deploy smtp-integrator --channel edge
juju config smtp-integrator host=<smtp host> port=<smtp port> user=<smtp auth user> password=<smtp auth password> auth_type=plain transport_security=tls
```

## Configure email to use in `From`

Configure the "From" mail for Synapse with:
```
juju config synapse notif_from=<email to use in the "From" address>
```

## Integrate with Synapse

You can run it with the legacy integration `smtp-legacy` or with
the new integration using secrets `smtp`. A Juju version
with secrets is required for the `smtp` integration.

With the old integration without using secrets, run:
```
juju integrate smtp-integrator:smtp-legacy synapse:smtp
```
For the new integration with secrets, run:
```
juju integrate smtp-integrator:smtp synapse:smtp
```
2 changes: 1 addition & 1 deletion docs/how-to/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ the registry:
skopeo --insecure-policy copy oci-archive:synapse_1.0_amd64.rock docker-daemon:localhost:32000/synapse:latest
docker push localhost:32000/synapse:latest
cd [project_dir]/nginx_rock && rockcraft pack rockcraft.yaml
skopeo --insecure-policy copy oci-archive:synapse_nginx_1.0_amd64.rock docker-daemon:localhost:32000/synapse-nginx:latest
skopeo --insecure-policy copy oci-archive:synapse-nginx_1.0_amd64.rock docker-daemon:localhost:32000/synapse-nginx:latest
docker push localhost:32000/synapse-nginx:latest

### Deploy
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ If there’s a particular area of documentation that you’d like to see that’
1. [Tutorial](tutorial)
1. [Getting Started](tutorial/getting-started.md)
1. [How to](how-to)
1. [Contribute](how-to/contribute.md)
1. [Configure SMTP](how-to/configure-smtp.md)
2. [Contribute](how-to/contribute.md)
1. [Reference](reference)
1. [Actions](reference/actions.md)
1. [Integrations](reference/integrations.md)
Expand Down
22 changes: 21 additions & 1 deletion docs/reference/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,24 @@ Note that `public_baseurl` configuration set the public-facing base URL that
clients use to access this Homeserver. It's used as `entity_id` if set instead of
https://server_name.

See more information in [Charm Architecture](https://charmhub.io/synapse/docs/explanation-charm-architecture).
See more information in [Charm Architecture](https://charmhub.io/synapse/docs/explanation-charm-architecture).


### smtp

_Interface_: smtp
_Supported charms_: [smtp-integrator](https://charmhub.io/smtp-integrator/)

Integrating Synapse with SMTP Integrator provides SMTP configuration details so
a smtp server can be used in Synapse.

Example smtp integrate command: `juju integrate synapse smtp-integrator:smtp`

Note that the smtp-integrator provides two interfaces, `smtp` and `smtp-legacy`.
Only use the first one if the Juju version used supports secrets. The "From" email
is set with the Synapse configuration option `notif_from`.

For the smtp-integrator, insecure configurations with `transport_security=none` or not
authenticated connections with `auth_type=none` are not supported.

See more information in [Charm Architecture](https://charmhub.io/synapse/docs/explanation-charm-architecture).
Loading
Loading