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

v1.68, add administration API protection, various fixes #336

Merged
merged 28 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e3b992c
Fix change_url's ynh_permission_url parameters
Feb 21, 2022
678dea3
Add /_synapse path permission for administration API
Mar 5, 2022
918fe60
Add documentation on admin API
Sep 18, 2022
8e3f7d9
Handle /_synapse permission in change_url too
Apr 8, 2022
d34d6e9
Auto-update README
yunohost-bot Sep 18, 2022
64fa071
Readd missing disclaimer items
Sep 20, 2022
b29f96f
Auto-update README
yunohost-bot Sep 20, 2022
dbb80b4
Typo in disclaimer
Sep 20, 2022
b6108b7
Auto-update README
yunohost-bot Sep 20, 2022
b9c53ea
Merge pull request #301 from YunoHost-Apps/add-_synapse-perm
Sep 20, 2022
752f2d3
No need to change permissions
Sep 20, 2022
2e06f53
Merge branch 'testing' into fix-changeurl
Sep 20, 2022
49adc33
Merge pull request #300 from YunoHost-Apps/fix-changeurl
Josue-T Sep 21, 2022
224bac0
Bump package version
Sep 26, 2022
823f98a
Auto-update README
yunohost-bot Sep 26, 2022
de222c2
Merge remote-tracking branch 'origin/testing' into fix-ldap
yalh76 Sep 26, 2022
63b5955
fix bind_dn
yalh76 Sep 26, 2022
421c9f5
Merge pull request #337 from YunoHost-Apps/fix-ldap
Josue-T Sep 28, 2022
f759771
Upgrade synapse to 1.68.0
Josue-T Sep 28, 2022
9688c7c
Auto-update README
yunohost-bot Sep 28, 2022
48dcabb
Merge pull request #338 from YunoHost-Apps/v1.68
Josue-T Sep 28, 2022
620a645
Upgrade synapse to 1.69.0
Josue-T Oct 18, 2022
3edf8f1
Auto-update README
yunohost-bot Oct 18, 2022
20910ed
turnserver.conf: remove no-loopback-peers
MayeulC Oct 19, 2022
478f81f
Merge pull request #342 from MayeulC/patch-2
Josue-T Oct 20, 2022
caedb3f
Fix requirement
Josue-T Oct 24, 2022
334d100
Update scripts/upgrade
Josue-T Oct 24, 2022
4c9ff8d
Update scripts/install
Josue-T Oct 24, 2022
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
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Instant messaging server matrix network.
Yunohost chatroom with matrix : [https://matrix.to/#/#yunohost:matrix.org](https://matrix.to/#/#yunohost:matrix.org)


**Shipped version:** 1.67.0~ynh1
**Shipped version:** 1.67.0~ynh2

## Disclaimers / important information

Expand Down Expand Up @@ -131,6 +131,70 @@ This app doesn't provide any real good web interface. So it's recommended to use

## Additional information

## Administration

**All documentation of this section is not warranted. A bad use of command could break the app and all the data. So use these commands at your own risk.**

Before any manipulation it's recommended to do a backup by this following command :

`sudo yunohost backup create --apps synapse`

### Set user as admin

Actually there are no functions in the client interface to set a user as admin. So it's possible to enable it manually in the database.

The following command will grant admin privilege to the specified user:
```
su --command="psql matrix_synapse" postgres <<< "UPDATE users SET admin = 1 WHERE name = '@user_to_be_admin:domain.tld'"
```

### Administration API

Synapse's administration API endpoints are under `/_synapse` path and protected with the `admin_api` permission.
By default, no one has access to this path.

If you wish to access it, for example to use [Synapse Admin](https://github.com/YunoHost-Apps/synapse-admin_ynh),
you need to give this permission to visitors.

Then, to log in the API with your credentials, you need to set your user as admin (cf. precedent section).

### Upgrade

By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
- Call the command with the `-b` flag: `yunohost app upgrade synapse -b`
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:

`yunohost app setting synapse disable_backup_before_upgrade -v 1`

After this settings will be applied for **all** next upgrade.

From command line:

`yunohost app upgrade synapse`

### Backup

This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this:

- Stop synapse service with theses following command:

`systemctl stop synapse.service`

- Launch the backup of synapse with this following command:

`yunohost backup create --app synapse`

- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/yunohost.app/matrix-synapse`.
- Restart the synapse service with these command:

`systemctl start synapse.service`

### Remove

Due of the backup core only feature the data directory in `/home/yunohost.app/matrix-synapse` **is not removed**.

Use the `--purge` flag with the command, or remove it manually to purge app user data.

### Multi instance support

To give a possibility to have multiple domains you can use multiple instances of synapse. In this case all instances will run on different ports so it's really important to put a SRV record in your domain. You can get the port that you need to put in your SRV record with this following command:
Expand Down
66 changes: 65 additions & 1 deletion README_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Instant messaging server matrix network.
Yunohost chatroom with matrix : [https://matrix.to/#/#yunohost:matrix.org](https://matrix.to/#/#yunohost:matrix.org)


**Version incluse :** 1.67.0~ynh1
**Version incluse :** 1.67.0~ynh2

## Avertissements / informations importantes

Expand Down Expand Up @@ -131,6 +131,70 @@ This app doesn't provide any real good web interface. So it's recommended to use

## Additional information

## Administration

**All documentation of this section is not warranted. A bad use of command could break the app and all the data. So use these commands at your own risk.**

Before any manipulation it's recommended to do a backup by this following command :

`sudo yunohost backup create --apps synapse`

### Set user as admin

Actually there are no functions in the client interface to set a user as admin. So it's possible to enable it manually in the database.

The following command will grant admin privilege to the specified user:
```
su --command="psql matrix_synapse" postgres <<< "UPDATE users SET admin = 1 WHERE name = '@user_to_be_admin:domain.tld'"
```

### Administration API

Synapse's administration API endpoints are under `/_synapse` path and protected with the `admin_api` permission.
By default, no one has access to this path.

If you wish to access it, for example to use [Synapse Admin](https://github.com/YunoHost-Apps/synapse-admin_ynh),
you need to give this permission to visitors.

Then, to log in the API with your credentials, you need to set your user as admin (cf. precedent section).

### Upgrade

By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
- Call the command with the `-b` flag: `yunohost app upgrade synapse -b`
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:

`yunohost app setting synapse disable_backup_before_upgrade -v 1`

After this settings will be applied for **all** next upgrade.

From command line:

`yunohost app upgrade synapse`

### Backup

This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this:

- Stop synapse service with theses following command:

`systemctl stop synapse.service`

- Launch the backup of synapse with this following command:

`yunohost backup create --app synapse`

- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/yunohost.app/matrix-synapse`.
- Restart the synapse service with these command:

`systemctl start synapse.service`

### Remove

Due of the backup core only feature the data directory in `/home/yunohost.app/matrix-synapse` **is not removed**.

Use the `--purge` flag with the command, or remove it manually to purge app user data.

### Multi instance support

To give a possibility to have multiple domains you can use multiple instances of synapse. In this case all instances will run on different ports so it's really important to put a SRV record in your domain. You can get the port that you need to put in your SRV record with this following command:
Expand Down
64 changes: 64 additions & 0 deletions doc/DISCLAIMER.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,70 @@ This app doesn't provide any real good web interface. So it's recommended to use

## Additional information

## Administration

**All documentation of this section is not warranted. A bad use of command could break the app and all the data. So use these commands at your own risk.**

Before any manipulation it's recommended to do a backup by this following command :

`sudo yunohost backup create --apps synapse`

### Set user as admin

Actually there are no functions in the client interface to set a user as admin. So it's possible to enable it manually in the database.

The following command will grant admin privilege to the specified user:
```
su --command="psql matrix_synapse" postgres <<< "UPDATE users SET admin = 1 WHERE name = '@user_to_be_admin:domain.tld'"
```

### Administration API

Synapse's administration API endpoints are under `/_synapse` path and protected with the `admin_api` permission.
By default, no one has access to this path.

If you wish to access it, for example to use [Synapse Admin](https://github.com/YunoHost-Apps/synapse-admin_ynh),
you need to give this permission to visitors.

Then, to log in the API with your credentials, you need to set your user as admin (cf. precedent section).

### Upgrade

By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
- Call the command with the `-b` flag: `yunohost app upgrade synapse -b`
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:

`yunohost app setting synapse disable_backup_before_upgrade -v 1`

After this settings will be applied for **all** next upgrade.

From command line:

`yunohost app upgrade synapse`

### Backup

This app use now the core-only feature of the backup. To keep the integrity of the data and to have a better guarantee of the restoration is recommended to proceed like this:

- Stop synapse service with theses following command:

`systemctl stop synapse.service`

- Launch the backup of synapse with this following command:

`yunohost backup create --app synapse`

- Do a backup of your data with your specific strategy (could be with rsync, borg backup or just cp). The data is generally stored in `/home/yunohost.app/matrix-synapse`.
- Restart the synapse service with these command:

`systemctl start synapse.service`

### Remove

Due of the backup core only feature the data directory in `/home/yunohost.app/matrix-synapse` **is not removed**.

Use the `--purge` flag with the command, or remove it manually to purge app user data.

### Multi instance support

To give a possibility to have multiple domains you can use multiple instances of synapse. In this case all instances will run on different ports so it's really important to put a SRV record in your domain. You can get the port that you need to put in your SRV record with this following command:
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"en": "Instant messaging server which uses Matrix",
"fr": "Un serveur de messagerie instantané basé sur Matrix"
},
"version": "1.67.0~ynh1",
"version": "1.67.0~ynh2",
"url": "http://matrix.org",
"license": "Apache-2.0",
"maintainer": {
Expand Down
8 changes: 4 additions & 4 deletions scripts/change_url
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ ynh_add_config --template="homeserver.yaml" --destination="/etc/matrix-$app/home
ynh_add_config --template="log.yaml" --destination="/etc/matrix-$app/log.yaml"

#=================================================
# SETUP PERMISSIONS
# SECURE FILES AND DIRECTORIES
#=================================================

ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_url --permission=server_api --clear_urls
ynh_permission_url --permission=server_api --url=$domain/_matrix --additional_urls=$server_name/.well-known/matrix \
# Only setting permissions for the two config files updated above
chown $synapse_user:root -R /etc/matrix-$app
chmod u=rwX,g=rX,o= -R /etc/matrix-$app

#=================================================
# RELOAD SERVICES
Expand Down
3 changes: 3 additions & 0 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ ynh_permission_update --permission=main --show_tile=false --protected=true
ynh_permission_create --permission=server_api --url=$domain/_matrix \
--label="Server access for client apps." --show_tile=false --allowed=visitors \
--auth_header=false --protected=true
ynh_permission_create --permission=admin_api --url=$domain/_synapse \
--label="Server administration API." --show_tile=false \
--auth_header=false
Josue-T marked this conversation as resolved.
Show resolved Hide resolved
if yunohost --output-as plain domain list | grep -q "^$server_name$"; then
ynh_permission_create --permission=server_client_infos --url=$server_name/.well-known/matrix \
--label="Server info for clients. (well-known)" --show_tile=false --allowed=visitors \
Expand Down
6 changes: 6 additions & 0 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ elif yunohost --output-as plain domain list | grep -q "^$server_name"'$'; then
--protected=true
fi

if ! ynh_permission_exists --permission=admin_api; then
ynh_permission_create --permission=admin_api --url=$domain/_synapse \
--label="Server administration API." --show_tile=false \
--auth_header=false
Josue-T marked this conversation as resolved.
Show resolved Hide resolved
fi

#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
Expand Down