~bigbes/core-go

ref: 9ad4643973379ffcc65c3f465d6add31c9f37569 core-go/webhooks d---------
50a876e1 — Maxwell G 9 months ago
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.
20be483e — Conrad Hoffmann 9 months ago
Don't uppercase error messages
e22c3e1c — Conrad Hoffmann 9 months ago
Fix a bunch of linter complaints
20bcc757 — Conrad Hoffmann 9 months ago
webhooks: improve usage of slices.Contains

This was (rightfully) suggested by modernize [1], but the result can be
easily improved even further.

[1] https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
39c3fd1e — Conrad Hoffmann 9 months ago
Run modernize

See https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize

It's mostly interface{} -> any, but also two quite useful applications
of slices.Contains.
44cf5e79 — Drew DeVault 11 months ago
auth: remove legacy OAuth support
c3d11991 — Drew DeVault 1 year, 6 months ago
webhooks: fix filter for internal auth
d3f7b91a — Drew DeVault 1 year, 6 months ago
webhooks: implement internal webhook users

AUTH_INTERNAL requests previously could not register webhooks. This
commit adds the necessary changes to allow for this.
465a6f71 — Drew DeVault 1 year, 6 months ago
all: pass errors to panic, not strings

GraphQL's recovery middleware can't handle strings so it just logs a
very not useful <nil>
fea51c61 — Drew DeVault 1 year, 6 months ago
webhooks: add User-Agent to outgoing requests
6eae2199 — Drew DeVault 1 year, 7 months ago
auth: use config.IsInternalIP
17315205 — Robin Jarry 1 year, 8 months ago
config: factorize integer parsing

Add a new GetInt() function to parse an integer value from a parsed
ini.File. Use that function instead of duplicated code.

Signed-off-by: Robin Jarry <robin@jarry.cc>
7457c44b — Robin Jarry 1 year, 8 months ago
treewide: update to new multi worker dowork api

The work.Queue() implementation has changed and now allows scheduling
tasks from multiple goroutines in parallel. Also, it requires a new
argument for limiting the queue buffer size in order to apply back
pressure.

Define new configuration variables to allow tuning the queue sizes and
number of workers per service:

  [mail]
  # Maximum size of the outgoing email queue (default 512).
  egress-queue-size = 512

  [$service_name]
  # Number of parallel workers per queue (default 1).
  # There are multiple queues (for egress email, webhooks, etc.).
  # This setting is applied on a per-queue basis.
  queue-workers = 1

  [webhooks]
  # Maximum size of the webhooks queue (default 512).
  queue-size = 512

Use these new settings to configure the queues and workers accordingly.

Fix unit tests as well.

Link: https://git.sr.ht/~sircmpwn/dowork/commit/95719cfc0118
Signed-off-by: Robin Jarry <robin@jarry.cc>
2624a28a — Robin Jarry 1 year, 8 months ago
webhooks: do not crash when expire is NULL

This is currently not possible to create a webhook without an expiry
date. But the SQL database schema does not forbid it. If in the future
we would like to allow webhooks to be created without an expiry date, we
shouldn't crash when fetching them.

Check for the validity of the Expiry field before checking its value. If
it is nil, assume that the webhooks has no expiry date.

Signed-off-by: Robin Jarry <robin@jarry.cc>
cd878493 — Conrad Hoffmann 2 years ago
webhooks: skip webhooks with expired credentials

The documentation states [1]:

> When the original authentication method becomes invalid (such as the
> expiration of or revocation of an OAuth 2.0 bearer token), the
> webhook is disabled.

However, this is currently not the case. Expired webhooks are indeed
filtered out in virtually all GraphQL queries (by means of core-go's
FilterWebhooks [2]), so users cannot see or delete them. They are _not_
filtered out upon scheduling, however. This commit fixes that.

The symptoms of this are that active webhooks may simply not be run - if
a user has both an expired and a valid, active webhook for some event,
the scheduling will retrieve both, fail on the expired one, and stop
processing, without any feedback to the user who scheduled the hooks.

This is a problem across all services, so core-go seems like the best
place to fix this.

[1]: https://man.sr.ht/graphql.md#webhook-authentication
[2]: https://git.sr.ht/~sircmpwn/core-go/tree/master/item/webhooks/config.go#L74,81
236879ae — Conrad Hoffmann 3 years ago
Run `go fmt`
d0bf1153 — Adnan Maolood 4 years ago
webhooks.FilterWebhooks: Filter by user_id
ebf93be7 — Adnan Maolood 4 years ago
webhooks: Add middleware
7d6b202a — Adnan Maolood 4 years ago
webhooks: Execute GraphQL queries synchronously

Execute GraphQL webhook queries synchronously instead of in a background
task to avoid race conditions.
87de6649 — Adnan Maolood 4 years ago
webhooks: Add FilterWebhooks function
Next