sncf/README.md

83 lines
4.9 KiB
Markdown
Raw Permalink Normal View History

2020-08-19 01:12:15 +02:00
# sncf
2022-02-24 10:56:02 +01:00
**Warning: Breaking changes introduced on a minor Nextcloud release (>= 22.3.0) broke sncf. Please do not update until it is fixed. It seems easy to fix (use `/login` instead of `/csrftoken`) but I need time, feel free to try to fix it.**
2020-08-19 02:31:03 +02:00
Simple Nextcloud Forms (sncf) is a lightweight proxy written in Rust with the [Actix](https://actix.rs) framework.
It is meant to make form creation easier, through the use of the [Nextcloud Forms](https://github.com/nextcloud/forms) application, by generating administration links for forms: **users do not need to log in or register**, they just need to keep a link (in the form of `https://your-instance.com/admin/<45-byte base64 key>`) to log them in and give them access to their forms.
### How ?
I really used black voodoo magic on this one.
2020-08-29 21:49:24 +02:00
This software acts as a **proxy** between the client and the Nextcloud instance. Here are some of its features :
2020-08-31 11:20:49 +02:00
- When a link is created from the main page, sncf connects to the Nextcloud API and creates an account with a random username and password. Those credentials are stored in its SQLite database, along with a randomly-generated token (used in the administration link).
2020-08-19 02:31:03 +02:00
- When an administration link is used, sncf uses its database to find the associated username and password, then fills the login form on the Nextcloud instance (taking in account its CSRF token) and proxies the generated `Set-Cookie` headers to the client (to log the user in), then redirects it to the Forms app.
- When a form is created, sncf automatically forges a request to update some fields in the form (set isAnonymous to true, for instance). Those parameters can't be changed by the client.
2020-08-29 21:49:24 +02:00
- When a form is updated, sncf parses the requests before proxying it in order to prevent the client to edit some specific fields (isAnonymous or form access policy, which must not set to allow the users of the same instance to see the form). If an unwanted request is made, sncf does not proxy it.
2020-08-19 02:31:03 +02:00
- A lot of routes are restricted (settings, API) to prevent the instance from being used for anything else than the Forms app.
Those tweaks are completed by server-side CSS edits (using an application) to hide unwanted fields.
2020-08-29 21:49:24 +02:00
### Setup
2020-08-19 02:31:03 +02:00
2020-08-29 22:25:43 +02:00
See the [dedicated wiki page](https://git.42l.fr/neil/sncf/wiki/Setting-up-Nextcloud-and-sncf).
2020-08-19 02:31:03 +02:00
2020-08-29 21:49:24 +02:00
Note: There is currently no script to make the installation easier (see #12).
2020-08-19 02:31:03 +02:00
2020-08-29 21:49:24 +02:00
### Compatibility table
2020-08-19 02:31:03 +02:00
2020-08-29 21:49:24 +02:00
Compatibility with sncf has been tested for the following Nextcloud and Nextcloud Forms versions.
| sncf | Nextcloud | Nextcloud Forms |
|--------------|------------|------------------|
| 1.0.0 | 19.0.1, 19.0.2 | 2.0.2, 2.0.3 |
2020-11-05 16:20:14 +01:00
| 1.0.1, 1.0.2, 1.1.0, 1.2.0 | 19.0.1, 19.0.2, 20.0.0\*, 20.0.1 | 2.0.4 |
2021-09-28 21:26:20 +02:00
| **Unsupported** \*\* | above 20.0.1, below 21.x | above 2.0.4, below 2.2.2
2021-10-11 17:56:24 +02:00
| 1.3.0, 1.4.0 | 21.0.0 | 2.2.2, 2.2.3, 2.2.4 |
| 1.5.0 | 22.2.0 | 2.3.0 |
2020-10-07 16:39:24 +02:00
2021-03-24 20:48:42 +01:00
\* Breaking changes, please check [the wiki](https://git.42l.fr/neil/sncf/wiki/Upgrade-from-a-previous-version) if you need to upgrade from a previous version.
\*\* Untested versions, use at your own risk.
2020-08-29 21:49:24 +02:00
If your NC or NC Forms version isn't in this list, sncf **may** or **may not** work. We **do not** ensure backwards compatibility with older versions.
Avoid upgrading software without checking its compatibility with sncf.
If you upgrade anyway and notice a breaking change, please file an issue.
### Contribute
#### Donations
If you like this work, please donate to the [42l association](https://42l.fr) (maintaining sncf) or [Nextcloud](https://nextcloud.com/include/) (maintaining Nextcloud and Nextcloud Forms).
2020-08-29 21:49:24 +02:00
#### Translating
2021-03-16 18:27:46 +01:00
Currently, this software is translated in French, English and German (thanks [alpcentaur](https://git.42l.fr/alpcentaur)!)
2020-08-29 21:49:24 +02:00
Feel free to take a look at the [lang.json](https://git.42l.fr/neil/sncf/src/branch/root/lang.json) file and send a pull request.
#### Code
Check the opened issues. Feel free to take a look at the code (it's really small). There's yet a lot of place for improvement. If you need info, you can create an issue with the `question` tag on it.
### FAQ
#### What is the CPU/RAM consumption of this setup?
The "setup" we're talking about is the main instance's, [forms.42l.fr](https://forms.42l.fr).
- sncf consumes between 20 and 60 MB of RAM and isn't CPU-hungry.
2020-08-29 21:50:27 +02:00
- Nextcloud consumes between 60 MB and 120 MB of RAM. It's quite lightweight compared to other Nextcloud instances since the usual apps are disabled. It's eating some CPU like any regular PHP application.
2020-08-29 21:49:24 +02:00
#### Why didn't you write a Nextcloud application instead ?
That sounds appropriate, but I don't feel like writing PHP and I don't know Nextcloud internals. Feel free to write it, though.
#### Are you crazy? This tweak is gonna break at every single update.
2020-11-05 16:20:14 +01:00
Yeah, well, you're probably right. A Nextcloud app would be more suitable, I guess. But anyway, feel free to use something else if this is too much tweaking for you. But I'd prefer some pull requests to help me keep this software up-to-date with Nextcloud and Nextcloud Forms updates.