Peter Cai
10c2f0da4c
README: switch mailing list to SourceHut
2 years ago
Peter Cai
98a71fcea0
README: update repo and contact information
2 years ago
Peter Cai
c563484a61
add README
2 years ago
Peter Cai
3635cea3f4
add AGPLv3 license
2 years ago
Peter Cai
4a75dfd225
main: set JSON body limit to 50M
...
* This can happen during import of old backups. Customizations should be
done in frontend reverse-proxy.
2 years ago
Peter Cai
c4e489da56
add dockerfile
2 years ago
Peter Cai
31acab5e9d
tests: make sure we test sync_tokens enc/dec algorithm
2 years ago
Peter Cai
a340eb8c4f
encrypt sync_token and cursor_token
2 years ago
Peter Cai
2eaf7d24e0
enable busy_timeout for SQLite
...
although we have a global RwLock for database access, it still can fail
due to disk sync delays. Though unlikely, it has happened once or twice
during testing. Let's just enable busy_timeout to avoid this issue.
Since we have RwLock anyway, a busy_timeout should not be much of a
problem.
Unfortunately this has to be enabled via implementing our own wrapper
trait.
2 years ago
Peter Cai
d4c4be4d63
api: items/sync: explain why we need the per-user lock
2 years ago
Peter Cai
fb7beff3e0
db: create indicies for quicker query
2 years ago
Peter Cai
61f3d0cb52
item: better documentation on our "id"
2 years ago
Peter Cai
236aca3bef
api: items/sync: we don't produce uuid_conflict
...
`uuid_conflict` only exists because the official implementation uses
`uuid` as the primary key for their database, while in ours we use an
internal ID and then use (uuid, user) tuple to fetch items. i.e. in our
implementation, user A and B can have items that have the same UUID.
2 years ago
Peter Cai
09b2f945d2
api: rewrite conflict detection in iterators
2 years ago
Peter Cai
3f266269cc
api: use our shorthand method for returning
2 years ago
Peter Cai
3541ee1d7f
tests: add test for email format
...
TODO: actually test items/sync
2 years ago
Peter Cai
847dfd80dd
main: remove "extern crate"
...
looks like we don't need them anymore in Rust 2018
except for #[macro_use]
2 years ago
Peter Cai
565a6008f8
api: validate email against regex
2 years ago
Peter Cai
a38c13f21c
api: item/sync: use iterators and remove unnecessary mut and clone
2 years ago
Peter Cai
31337b463f
api: items/sync: always set sync_token to latest ID
...
Our convoluted logic was not necessary after all. The only requirement
is that `sync_token` records the latest state of the system after the
last sync. Since we use IDs as sort of a "timestamp", we can just mimic
what the Go implementation does here and always set `sync_token` equal
to the maximum ID (corresponding to the current timestamp in Go impl).
`cursor_token` is only necessary when we are not able to fetch
everything up to the latest. It has nothing to do with `sync_token` and
we should not combine the logic of the two at all.
2 years ago
Peter Cai
8388d73505
only allow one sync per user every time
2 years ago
Peter Cai
915f9893a5
api: item/sync: handle sync_token behind cursor_token
...
this can happen e.g. the client synchronizes new items but have nothing
new to send back to the server.
2 years ago
Peter Cai
908c62b0a1
api: rewrite some comments on synchronization algorithm
3 years ago
Peter Cai
0277d2c122
item: remove TODO (implemented in api.rs)
3 years ago
Peter Cai
3ea20fba9e
api: items/sync: make sure we don't go beyond sync_token
...
when using cursor_token to fetch content
3 years ago
Peter Cai
8cc0ec0266
items/sync: implement conflicts properly
3 years ago
Peter Cai
ecf3998b5a
api: just return error on db failure
...
let's do conflict properly
3 years ago
Peter Cai
7046e51d01
api: always update `updated_at` when inserting
3 years ago
Peter Cai
6e37ed9e62
drop JWT and use database-based session tokens
3 years ago
Peter Cai
5d5e88fcef
api: item/sync: fix cursor_token and sync_token logic
3 years ago
Peter Cai
fd9b1310b0
api: retry twice for insert
3 years ago
Peter Cai
bcde7ca74a
api: return old tokens by default
3 years ago
Peter Cai
9bf4259164
item: stop handling date ourselves
3 years ago
Peter Cai
e29d0883a8
add user uuid and return it in auth response to match official impl
...
why why why
3 years ago
Peter Cai
6729959580
change pw_cost to integer to match official impl
3 years ago
Peter Cai
783873b74d
main: add rocket_cors middleware
3 years ago
Peter Cai
4be4de241f
try to implement items/sync
...
* we need to figure out a way to test this API
3 years ago
Peter Cai
15809cd545
user: auth header should have Bearer prefix
3 years ago
Peter Cai
fea3fb235d
user: implement authorization guard
3 years ago
Peter Cai
c82ed40251
add items table schema
3 years ago
Peter Cai
689b67ca74
tests: add more test cases for auth API
3 years ago
Peter Cai
2893bbd595
add global RwLock for SQLite
...
now tests pass
3 years ago
Peter Cai
f611c5378d
write some tests (they fail)
3 years ago
Peter Cai
b10a50be08
implement server-side scrypt to protect passwords better
3 years ago
Peter Cai
3d7f080751
user: use iat instead of nbf (iat = issued-at)
3 years ago
Peter Cai
92f8a72117
api: implement auth/change_pw
3 years ago
Peter Cai
77517147c8
implement auth/sign_in
3 years ago
Peter Cai
11b2a272b2
api: implement auth/params
3 years ago
Peter Cai
fd2fd263d1
users: add shorthand for UserOpError
3 years ago
Peter Cai
2178b1f833
initial commit
3 years ago