~bigbes/core-go

3686f7e2 — Drew DeVault 1 year, 17 days ago
objects: improve support for our s3 deployment

Not sure how well this generalizes but we can improve it when someone
complains.
42a4b67b — Drew DeVault 1 year, 18 days ago
Switch from minio to AWS SDK S3 client

Moves s3 => objects to avoid conflicting with the AWS module.
e5f2298c — Drew DeVault 1 year, 18 days ago
server: log GraphQL queries if running in debug mode
1c4d7007 — Conrad Hoffmann 1 year, 21 days ago
auth: fix remote IP determination for audit log

This is probably isolated to dev or other small environments, but I had
two issues with the remote IP determination, breaking the audit log
display in my dev env after fairly standard usage.

The gist is that the audit log is designed to contain clean IP addresses
only. However, the algorithm starts out with `r.RemoteAddr`, which may
contain a port (usually 127.0.0.1:xxxxx). The port removal is already
performed at the beginning of the function, so simply re-use the result
of this.

Furthermore, the initial value (containing the port leading to breakage)
landed in the audit log because I was using a private IP (it's my dev
evn). We correctly trust private IPs, but that means if no public IP
ever shows up in the X-Forwarded-For header, the last private IP was the
one that actually made the request.

I am not entirely sure why this showed up now. I already had a bunch of
oder audit log entries that had the correct private-but-not-localhost
addresses. But in the current state, e.g. simply updating my profile
would cause the bad IP:port notation to be written to the audit log.
a8516055 — Conrad Hoffmann 1 year, 26 days ago
server: handle CORS in server

Currently CORS is handled in nginx in front of the API. That setup is
not very suitable for Kubernetes. Instead, handle CORS here, so we do
not need any intermediaries between the ingress and the APIs.

The CORS settings are taken from sr.ht-nginx/graphql.conf [1]

[1] https://git.sr.ht/~sircmpwn/sr.ht-nginx/tree/master/item/graphql.conf
00133fa6 — Conrad Hoffmann 1 year, 25 days ago
Remove sourcehut-migrate

It now lives in its own repo [1], so it can be tagged and packaged
independently of core-go.

[1] https://git.sr.ht/~sircmpwn/sourcehut-migrate
8400925c — Drew DeVault 1 year, 25 days ago
.builds/alpine.yml: upgrade to 3.22
ba01be84 — Conrad Hoffmann 1 year, 1 month ago
server: replace deprecated gqlgen code

Most of the gqlgen/handler package, specifically also
`handler.GraphQL()`, has been deprecated [1]. The documentation of the
new package [2] is a bit lacking, but some stuff is covered in the
reference docs [3] [4], and some in the examples [5].

[1] https://pkg.go.dev/github.com/99designs/gqlgen@v0.17.36/handler#GraphQL
[2] https://pkg.go.dev/github.com/99designs/gqlgen@v0.17.36/graphql/handler
[3] https://gqlgen.com/reference/errors/#the-panic-handler
[4] https://gqlgen.com/reference/complexity/#limiting-query-complexity
[5] https://github.com/99designs/gqlgen/blob/master/_examples/fileupload/server/server.go
e36951da — Conrad Hoffmann 1 year, 1 month ago
Update ProtonMail/go-crypto to v1.3.0
f0b0e702 — Conrad Hoffmann 1 year, 2 months ago
Add sourcehut-migrate, a unified DB migration tool

This tool will replace both the old `srht-migrate` as well as all
`<SERVICE>-migrate` tools, but services need to be migrated over to it
one by one. This tool is based on brant [1].

Invocation in both production and development can be as simple as:

    sourcehut-migrate <SERVICE> up

The tool will read a config like a regular service (first in ., then
/etc/sr.ht, etc.). The database connection details are taken from the
config. To facilitate development, the tool will check if a folder
./migrations exists; if it does, migrations will be loaded from there.
If no ./migrations folder was found, it will look for migrations in
`<ASSETS>/migrations/<SERVICE>`, where <ASSETS> is also taken from the
config, with a default of `/usr/share/sourcehut`.

For an explanation of the available commands, see brant [1].

This tool also supports a simple command to initialize a newly created
database to the current version (much like the `<SERVICE>-initdb` tools
used to):

    sourcehut-migrate <SERVICE> stamp head

will automatically set the database version to whatever the latest
available migration version is.

[1]: https://git.sr.ht/~bitfehler/brant
bdb0f7e8 — Drew DeVault 1 year, 1 month ago
server: disable logging for release mode

This was partially implemented a while ago but we missed the main point
where it matters.
c1d572b5 — Conrad Hoffmann 1 year, 3 months ago
config: add GetBool convenience method

It's the boolean equivalent of `GetInt()`. The value handling is taken
from the Python version (`srht.config.cfgb()`).
55ab6c4b — Simon Martin 1 year, 4 months ago
config: add missing private ip ranges

I noticed that 172.16.0.0/12 is missing from the default private IP
address space; following a quick discussion in [1], this patches adds
it, as well as link local ranges.

[1] https://lists.sr.ht/~sircmpwn/sr.ht-dev/%3C20241218140750.2393901-1-robin@jarry.cc%3E

Fixes: deb699c9d01a ("add global internal-ipnet setting")
Signed-off-by: Simon Martin <simon@nasilyan.com>
29a3ebfe — Taavi Väänänen 1 year, 4 months ago
errors: Fix ErrUnsupported error code
d89f65e8 — Drew DeVault 1 year, 4 months ago
errors.Field: return the error
79dad627 — Drew DeVault 1 year, 4 months ago
server: add pprof endpoint

This adds a pprof endpoint to all SourceHut APIs. It picks an
OS-assigned port on localhost to run it on and prints this port to
stdout. This ensures a unique port is selected even if several APIs are
running on a single host.
Allow unix scheme for redis url

Recently, the logic for creating redis client
has been changed and mistakenly unix scheme
has been removed from supported schemes.
1e3cd785 — Drew DeVault 1 year, 5 months ago
errors: add ERR_UNSUPPORTED
0bea6849 — Drew DeVault 1 year, 5 months ago
server: enable request logging only in debug mode

To improve the signal:noise ratio in the production logs.
Next