errors: add ERR_REDIRECT
This error is meant to be returned if a resource is requested that does
not exist under the requested name anymore but was moved to a different
resource.
server: support multiple bind addresses
model: support unmarshalling RIDs from string
hub stores list/repo/tracker RIDs as strings in its database, and I want
to return those as GQL IDs, not strings, in the upcoming GQL API. This
is not possible without this patch since those strings are not UUIDs but
marshalled ones.
Signed-off-by: Simon Martin <simon@nasilyan.com>
model: rename ID => RID, implement sql Valuer
As in "Resource" ID. I also changed the base32 alphabet to lowercase,
because I subjectively think it looks nicer.
objects: make `URL()` respect `s3-insecure`
Helpful in development environments where a local S3 instance is used
without HTTPS.
server: support setting build version and date information
This is a pre-requisite to the effort to make this information available
via the GraphQL API.
Co-authored-by: Conrad Hoffmann <ch@bitfehler.net>
Signed-off-by: Simon Martin <simon@nasilyan.com>
config: add GetOwner and GetString
These patterns are used often enough to justify a little convenience.
Also fixes a few godoc comments while at it.
auth: update user type constants
Those need to be kept in sync with the database/GraphQL values. The ones
not in sync are not currently used, though.
server: let AUTH_INTERNAL access @anoninternal
Both methods enforce the internal aspect, but @anoninternal really just
means the resolver does not require an "authenticated user" context,
which means it's still perfectly safe if there is one.
With this in place, any resolver that may have to be called from an
anonymous context can be switched from @internal to @anoninternal
without breaking existing users. Of course it can only be switched if it
really does not require a user context.
webhooks: do not limit webhooks by token_hash
When a user re-authenticates with an OAuth2 app, the app would not be
able to query or delete webhooks it created with a previous session.
This was a problem for a tool I am developing and removing this
constraint fixes the issue.
server: allow setting ports for metrics, pprof
With an eye towards Kubernetes, it is desirable to avoid having the API
pick random ports for anything. This commit introduces additional flags
for the API server to specify the metrics and pprof ports. This change
is backwards-compatible insofar as the default behavior is preserved if
the flags are not used.
The log output is changed to include the full address that the
respective listeners are listening on.
Note that using "0.0.0.0:1234" might not quite work as expected, because
Go [1]. But that does not change the default behavior, so I guess it's
fine.
[1] https://github.com/golang/go/issues/48723
Run golangci-lint in CI
See https://golangci-lint.run
This has already helped uncover some issues, and we should make more use
of it. Currently we have to disable one of the default lints, as we have
a lot of issues it complains about. I plan to address those one by one
and enable it. Until then, put this in place to make sure we don't
re-introduce any of the issues we've eliminated so far.
Don't uppercase error messages
Fix a bunch of linter complaints
auth/middleware: return semantic errors on auth failure
This time with a much simpler approach than the last one that caused
some authentication issues for chat.sr.ht.