5 Commits

Author SHA1 Message Date
Eva
081e78c711 Merge 90cc0b3d59 into 376f687c38 2025-02-20 21:47:06 +03:00
376f687c38 chore: questionable is not a recognized rating 2025-02-11 21:50:27 +01:00
4fd848abf2 doc: use docker compose instead of docker-compose
The minimum version requirements are rough guesses, in practice any decently modern docker installation should work.
2025-02-11 21:25:10 +01:00
Eva
90cc0b3d59 client/posts: remove cache buster query string on post file change
Since filenames now use the new file's sha1.
2023-05-22 11:54:39 +02:00
Eva
a2d8454880 server/posts: file sha1 in filenames and prevent offline secret cracking
Imagine if we had a bunch of simple strings encrypted with the same key
we use to salt passwords, publicly accessible, which would undermine
our salting model by removing the requirement of filesystem access to
crack our users' passwords, requiring only database access and offline
cracking of our secret.
Wouldn't that be fun?
2023-05-22 11:54:39 +02:00
6 changed files with 17 additions and 35 deletions

View File

@ -88,7 +88,6 @@ class PostContentControl {
_evtPostContentChange(e) {
this._post = e.detail.post;
this._post.mutateContentUrl();
this._reinstall();
}

View File

@ -454,13 +454,6 @@ class Post extends events.EventTarget {
});
}
mutateContentUrl() {
this._contentUrl =
this._orig._contentUrl +
"?bypass-cache=" +
Math.round(Math.random() * 1000);
}
_updateFromResponse(response) {
const map = () => ({
_version: response.version,

View File

@ -789,7 +789,7 @@ data.
| `fav-time` | alias of `fav-date` |
| `feature-date` | featured at given date |
| `feature-time` | alias of `feature-time` |
| `safety` | having given safety. `<value>` can be either `safe`, `sketchy` (or `questionable`) or `unsafe`. |
| `safety` | having given safety. `<value>` can be either `safe`, `sketchy` or `unsafe`. |
| `rating` | alias of `safety` |
**Sort style tokens**

View File

@ -1,5 +1,5 @@
This assumes that you have Docker (version 17.05 or greater)
and Docker Compose (version 1.6.0 or greater) already installed.
This assumes that you have Docker (version 19.03 or greater)
and the Docker Compose CLI (version 1.27.0 or greater) already installed.
### Prepare things
@ -38,7 +38,7 @@ and Docker Compose (version 1.6.0 or greater) already installed.
This pulls the latest containers from docker.io:
```console
user@host:szuru$ docker-compose pull
user@host:szuru$ docker compose pull
```
If you have modified the application's source and would like to manually
@ -49,17 +49,17 @@ and Docker Compose (version 1.6.0 or greater) already installed.
For first run, it is recommended to start the database separately:
```console
user@host:szuru$ docker-compose up -d sql
user@host:szuru$ docker compose up -d sql
```
To start all containers:
```console
user@host:szuru$ docker-compose up -d
user@host:szuru$ docker compose up -d
```
To view/monitor the application logs:
```console
user@host:szuru$ docker-compose logs -f
user@host:szuru$ docker compose logs -f
# (CTRL+C to exit)
```
@ -84,13 +84,13 @@ and Docker Compose (version 1.6.0 or greater) already installed.
2. Build the containers:
```console
user@host:szuru$ docker-compose build
user@host:szuru$ docker compose build
```
That will attempt to build both containers, but you can specify `client`
or `server` to make it build only one.
If `docker-compose build` spits out:
If `docker compose build` spits out:
```
ERROR: Service 'server' failed to build: failed to parse platform : "" is an invalid component of "": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument
@ -102,7 +102,7 @@ and Docker Compose (version 1.6.0 or greater) already installed.
user@host:szuru$ export DOCKER_BUILDKIT=1; export COMPOSE_DOCKER_CLI_BUILD=1
```
...and run `docker-compose build` again.
...and run `docker compose build` again.
*Note: If your changes are not taking effect in your builds, consider building
with `--no-cache`.*
@ -117,7 +117,7 @@ with `--no-cache`.*
run from docker:
```console
user@host:szuru$ docker-compose run server ./szuru-admin --help
user@host:szuru$ docker compose run server ./szuru-admin --help
```
will give you a breakdown on all available commands.

View File

@ -1,9 +1,7 @@
## Example Docker Compose configuration
##
## Use this as a template to set up docker-compose, or as guide to set up other
## Use this as a template to set up docker compose, or as guide to set up other
## orchestration services
version: '2'
services:
server:

View File

@ -97,20 +97,12 @@ FLAG_MAP = {
}
def get_post_security_hash(id: int) -> str:
return hmac.new(
config.config["secret"].encode("utf8"),
msg=str(id).encode("utf-8"),
digestmod="md5",
).hexdigest()[0:16]
def get_post_content_url(post: model.Post) -> str:
assert post
return "%s/posts/%d_%s.%s" % (
config.config["data_url"].rstrip("/"),
post.post_id,
get_post_security_hash(post.post_id),
post.checksum,
mime.get_extension(post.mime_type) or "dat",
)
@ -120,7 +112,7 @@ def get_post_thumbnail_url(post: model.Post) -> str:
return "%s/generated-thumbnails/%d_%s.jpg" % (
config.config["data_url"].rstrip("/"),
post.post_id,
get_post_security_hash(post.post_id),
post.checksum,
)
@ -129,7 +121,7 @@ def get_post_content_path(post: model.Post) -> str:
assert post.post_id
return "posts/%d_%s.%s" % (
post.post_id,
get_post_security_hash(post.post_id),
post.checksum,
mime.get_extension(post.mime_type) or "dat",
)
@ -138,7 +130,7 @@ def get_post_thumbnail_path(post: model.Post) -> str:
assert post
return "generated-thumbnails/%d_%s.jpg" % (
post.post_id,
get_post_security_hash(post.post_id),
post.checksum,
)
@ -146,7 +138,7 @@ def get_post_thumbnail_backup_path(post: model.Post) -> str:
assert post
return "posts/custom-thumbnails/%d_%s.dat" % (
post.post_id,
get_post_security_hash(post.post_id),
post.checksum,
)