1
0
mirror of https://github.com/etesync/server synced 2024-11-21 16:28:08 +00:00
Commit Graph

48 Commits

Author SHA1 Message Date
Tom Hacohen
cc54a136f1 Fix server error when passing null collection types. 2024-06-29 14:55:48 -04:00
Tom Hacohen
f35b4b94e5 Make more fields truely optional (behavior change in pydantic v2). 2024-06-13 13:50:38 -04:00
Craeckie
19aba5345a
added CSRF_TRUSTED_ORIGINS (#183)
Since some recent upgrade, I'm not able to login to the admin page of etesync (`/admin/login/`), because the CSRF check fails.


After adding `CSRF_TRUSTED_ORIGINS = ['https://my-domain.com']`, it works.
According to the [docs](https://docs.djangoproject.com/en/4.2/ref/settings/#csrf-trusted-origins), this setting is required in addition to `ALLOWED_HOSTS`.
2024-06-09 23:27:49 +03:00
Tom Hacohen
c9b8f43845 Set default auto field to appease django warning. 2024-06-09 11:15:41 -04:00
Tom Hacohen
f1c072bd0a Fix issue with how we render binary 422 errors
json_encoder assumes it's not binary, but our error messages may include
some binary stuff.
2024-06-08 22:54:02 -04:00
Tom Hacohen
d7075c0169 Mark optional field as optional. 2024-06-08 20:49:13 -04:00
Tom Hacohen
a27ce2f4d0 Also handle 422 as msgpack. 2024-06-08 20:41:01 -04:00
Tom Hacohen
138d99dd7f Update code to adjust to most recent python/fastapi. 2024-06-08 20:27:33 -04:00
Tom Hacohen
0be14a7b0e Fixes for fastapi. 2024-06-08 20:17:02 -04:00
Tom Hacohen
57e676baa1 Adjust to fastapi changes. 2024-06-08 19:52:10 -04:00
Tom Hacohen
b9f2cea951 more 2024-06-08 19:29:56 -04:00
Tom Hacohen
0d9c9f153d Type fix. 2024-06-08 19:29:56 -04:00
Tom Hacohen
fb9cc701d0 Adjust pydantic code to v2. 2024-06-08 18:10:34 -04:00
Tom Hacohen
0cdab19308 Fix rust complaints. 2024-06-08 18:04:59 -04:00
Tom Hacohen
79d28586c5 Run ruff format. 2024-06-08 17:51:44 -04:00
Tom Hacohen
62152ce52b
Merge pull request #147 from Xiretza/settings-env-override
fix(settings): ensure environment variables always override config
2024-06-02 21:13:14 -04:00
Tom Hacohen
a54afd5210 Optimize stoken-using functions to only account for current revisions.
No need to account for revisions that are not current when calculating stokens
because those, by definition, are not the latest ones, and therefore won't have
the most recent stokens.

This becomes a problem when collections have many associated revisions.
2023-08-15 20:21:23 -04:00
Alejandro
4293acb3a3 fix: Python files 2023-07-24 22:06:22 -04:00
Tom Hacohen
8c6d04e8d3 Replace aioredis with redis-py
aioredis has been merged into redis-py and will no longer be maintained
as a separate project.
2022-09-04 19:57:27 +02:00
Xiretza
c4475535ea fix(settings): ensure environment variables always override config
DJANGO_STATIC_ROOT is required in order to run `collectstatic` in
a packaging environment - manually specifying it as an environment
variable should always override any config files that may exist.
2022-07-21 12:37:43 +02:00
Tom Hacohen
2f1f95fea9 Optimize how we fetch the latest (current) revision
The way were were doing it was implicitly sorting the query items and it
was causing millions of items to be sorted (even though the result should
only have one) making it slow.

By switching away from `get()` and `first()` we are telling django to
not try to sort.
2022-06-19 22:25:49 +03:00
PapaTutuWawa
fac36aae11
Implement checking the username against LDAP (#64)
This commit adds code to allow users that prefer to do user management
via LDAP to do so. Since Etebase does not store the password (proof) in
a LDAP compatible fashion, we compromise and instead two checks: One while
registering an account to see if the username is the LDAP directory and
one whenever the API is accessed. To prevent too many LDAP requests, the
result of the request is cached for an configurable amount of hours.

Make sure you have python-ldap installed and can successfully import
ldap. Then, if you use the easy config, add the following to your
config:

```
; [...]
; Regular etesync configuration

[ldap]
bind_dn = <Your LDAP "user" to bind as. See Note 1>
bind_pw = <The password to authenticate as your bind user>
; Or if you have the password in a file:
; bind_pw_file = /path/to/the/file.txt
server = <The URL to your LDAP server>
search_base = <Your search base>
filter = <Your LDAP filter query. See Note 2>
; In case a cache TTL of 1 hour is too short for you, set `cache_ttl` to
the preferred
; amount of hours a cache entry should be viewed as valid:
; cache_ttl = 5
```

With this config, I am able to make the EteSync server check with my
LDAP server if a user should be able to login or register.
Note that if a user is allowed to login or register, the password of the
LDAP user will be ignored. This LDAP patch is nothing more than an
additional check before the actual authentication.

A successful LDAP check will be cached, if not configured (correctly),
for one hour, after which the LDAP query will be performed again.

Note 1: This commit only works with a bind user
Note 2: The query must be specified. If an LDAP query returns more than
one or no result, then the authentication fails. If your query needs to
include the username that currently tries to perform a login or
registration, you can use %%s, which will be subsituted for the used
username.
2022-06-13 13:29:43 +03:00
Tom Hacohen
3a4da142dc Fix import of sendfile backend due to python package changes.
Broke in c7d1de31a1.
2022-06-04 18:05:13 +03:00
Xiretza
791de952f4 fix: move template directory into source directory
This is in preparation for creating a python package.
2022-05-09 17:41:16 +02:00
Xiretza
ada5181a7e fix: move django_etebase module from toplevel to under etebase_server
This is in preparation for creating a python package, which should only
occupy the "etebase_server" name in the global module namespace.
2022-05-09 17:41:16 +02:00
Xiretza
9d6e0ae60a fix: move myauth module from toplevel to under etebase_server
This is in preparation for creating a python package, which should only
occupy the "etebase_server" name in the global module namespace.
2022-05-09 17:41:16 +02:00
Xiretza
163f7766f1 fix: move etebase_fastapi module from toplevel to under etebase_server
This is in preparation for creating a python package, which should only
occupy the "etebase_server" name in the global module namespace.
2022-05-09 17:41:16 +02:00
Xiretza
13a137a128 fix: remove obsolete static file handler 2022-05-09 10:40:38 -05:00
Xiretza
e635e081c7 fix: use django.urls.path instead of deprecated django.conf.urls.url 2022-05-09 10:40:38 -05:00
Xiretza
04ca0ae5db
feat(config): allow specifying engine-specific database options (#135)
These are required to e.g. use PostgreSQL client certificates using
sslcert=/sslkey=.
2022-05-09 17:32:35 +03:00
Xiretza
70b753cd31
fix: don't create secrets file as world-readable (#136) 2022-05-09 17:17:56 +03:00
Victor R. Santos
7bb1bf9d22 Fix Django 3.2 warnings models.W042 2022-03-20 14:22:05 +02:00
Dustin J. Mitchell
43d5af32d7 Fix sendfile settings
* set SENDFILE_ROOT to the filesystem path for media, not the URL
  component
* use the correct import path to the sendfile backend
2021-04-17 19:03:35 +03:00
Tom Hacohen
8485806046 Easy config: add support for setting redis URI. 2021-01-28 17:55:37 +02:00
Tom Hacohen
c1f171bde0 Change how we create applications. 2020-12-28 16:42:39 +02:00
Tom Hacohen
4ceb42780e Remove unused django_etebase code. 2020-12-28 16:42:39 +02:00
Tom Hacohen
0fa2f2da3b Make the fastapi application the main asgi one. 2020-12-28 16:42:39 +02:00
Tom Hacohen
b081d0129f Add support for read/write permissions. 2020-12-28 16:42:39 +02:00
Tom Hacohen
9559a0fd35 Chunk download: use the new sendfile to serve files. 2020-12-14 16:47:47 +02:00
Tom Hacohen
070abfcdd8 Format using black. 2020-12-14 16:47:47 +02:00
Tal Leibman
d8e5c37db1
Use black for code formatting and format the code
Merge #65
2020-11-14 17:04:41 +02:00
Victor R. Santos
e9de8f1adb Add env variable to change configuration file path.
ETEBASE_EASY_CONFIG_PATH is optional, the server serches for the
configurations files in this order:
- "ETEBASE_EASY_CONFIG_PATH"
- etebase-server.ini
- /etc/etebase-server/etebase-server.ini
2020-11-08 08:58:19 +02:00
Tom Hacohen
8a557ff82c Disable signups by default.
The next commit includes README instructions on how to create users
and enable signups.
2020-09-27 09:42:01 +03:00
Tom Hacohen
5c803d8a51 Only expose drf's auth in debug mode. 2020-09-22 18:00:28 +03:00
Tom Hacohen
38e0700ac0 Update django and remove unused deps. 2020-09-10 19:19:19 +03:00
Pierre-Alain TORET
5785f803ac Port over easyconfig from the etesync server code.
Migrated by Tom, but kept the credit to daftaupe
2020-09-10 19:18:51 +03:00
Tom Hacohen
cc163d27af Add settings and configuration to run the etebase app. 2020-07-08 17:58:28 +03:00
Tom Hacohen
4aa3daaa97 Create a new django project. 2020-07-08 17:57:57 +03:00