~bigbes/core-go

ref: cfae7baecb8910cf4b28b3b9ab4df8e0b50dc2b3 core-go/server d---------
65b1657b — Simon Ser 3 years ago
auth: add AuthContext.Access

Same logic as server.Access, but lower-level. Useful to check for
a permission not covered by the GraphQL schema @access directives
(such as builds.sr.ht secrets).
a941162e — Simon Ser 3 years ago
server/email: don't panic in EmailRecover

A panic in here is not great, because this function is supposed to
be the panic handler. Let's just log the error instead.
1fd2476d — Simon Ser 3 years ago
server/email: log missing mail::error-to, treat empty string as unset

Log a message when mail::error-to is unset, just in case the admin
forgot to set it. Don't try to parse an email address if error-to
is set to the empty string (the default value in the default config
file).
2f239415 — Simon Ser 3 years ago
server/email: simplify and cleanup

- Only print the error once
- Remove unnecessary var
- Use debug.Stack instead of hand-rolled logic
- Ignore json.Marshal errors in a simpler way
30cea5cc — Simon Ser 3 years ago
server: fix error message on missing grant in Access

The error returned when a token is missing a required grant would
be "Access denied for invalid auth method" which is confusing.
Fix this with a more accurate error message.
ca47b9fe — Simon Ser 3 years ago
server/directives: handle auth.AUTH_ANON_INTERNAL in Access
144fc447 — Drew DeVault 3 years ago
server: register SQL collector

Missed this step
fa27910a — Drew DeVault 3 years ago
Add prometheus SQL connection stats

Also updates the prometheus client_go library
0b2fef24 — Conrad Hoffmann 4 years ago
Normalize remote address before saving to context

One cause for https://todo.sr.ht/~sircmpwn/meta.sr.ht/193 was that code
performing this sanitization was in multiple places, and a fix was not
applied in all places. There is no reasonable expectation for the port
to be present anyways, e.g. if the address is taken from a trusted
reverse proxy's header. Hence, perform the normalization here, so that
the code doing this in applications can be simplified.

Note that this does not yet fix the below ticket, it will just make the
fix easier.

References: https://todo.sr.ht/~sircmpwn/meta.sr.ht/193
8c2729f4 — Adnan Maolood 4 years ago
email.EnqueueStd: Don't overwrite headers

Sometimes we need to specify the Message-Id, From, and Reply-To headers
(e.g. for todo.sr.ht ticket notifications). Don't overwrite these
headers if they are present.
e28d47cf — Adnan Maolood 4 years ago
go fmt
d5f650da — Simon Ser 4 years ago
Allow AUTH_COOKIE to access @private fields
378fedbc — Drew DeVault 4 years ago
Add @anoninternal support code

This is a slightly better approach to the previous commit.
9f634ce0 — Drew DeVault 4 years ago
server/email: handle errors out of GQL context
d74ae98e — Drew DeVault 4 years ago
server/email: include variables
dea4ef29 — Drew DeVault 4 years ago
server: move auth middlware ahead of RealIP

So that @internal auth can correctly test against internal-ipnet.
f44afb10 — Simon Ser 4 years ago
go fmt
48250772 — Simon Ser 4 years ago
Remove %e formatting verbs

%e is not valid for formatting error values:

> %e	scientific notation, e.g. -1.234456e+78

Instead, use %w when using fmt.Errorf (for error wrapping) and
%v when using log.Printf (%w is not valid in that context).
2d9a547c — Drew DeVault 4 years ago
auth: harden grants structure

This replaces the Access map with a data type whose default value does
not grant any permissions, so that it's more difficult to create an
insecure auth context by mistake.
590c9c42 — Drew DeVault 4 years ago
server: add @private directive glue code
Next