Commit Graph

909 Commits

Author SHA1 Message Date
Simon Ser 19c2c6ab13 api/graph: add sshKeyByFingerprintInternal query
Allow anonymous internal auth to query a SSH key (with username)
from a fingerprint. To be used by gitsrht-keys.
2024-04-11 16:59:16 +02:00
Jackson e7008c3ef2 apply PGP key box changes to registration page
placeholder changes and make command copyable. the command always uses
an example email address as the email address, because the email address
is unknown unless you fill in the email address field and mess up the
PGP key field.
2024-04-11 16:37:57 +02:00
Conrad Hoffmann 4b37dc6df4 api: fix handling of NULL confirmation hash 2024-04-08 16:00:43 +02:00
Drew DeVault 7825992147 Add admin feature to re-send confirmation email
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-04-08 15:06:37 +02:00
Conrad Hoffmann 598e52d8b9 api: check abused only for successful registration
Currently, the abused check (and with it, the counter increase for rate
limits) for registration happens before the check if a username is
already taken. This causes legitimate users who are trying to find an
available username to run into the rate limit.

Instead, do the check last thing before commiting the transaction, and
rollback if it fails.
2024-04-05 11:55:22 +02:00
Drew DeVault cdabb81c38 .builds/alpine.yml: add -a to apk upgrade 2024-03-20 13:37:32 +01:00
Drew DeVault 83d0699f46 .builds/alpine: upgrade to alpine 3.19 2024-03-20 13:05:12 +01:00
Drew DeVault 9b73cd28c2 Makefile: update python path 2024-03-20 13:04:58 +01:00
Drew DeVault 69b07a6bff go mod tidy 2024-03-18 16:30:35 +01:00
Drew DeVault a3a1908e3e Fix leap day bug on user admin interface
Whelp.
2024-02-29 14:39:14 +01:00
Drew DeVault a633ed1ca2 go.*: update sums 2024-02-18 12:54:05 +01:00
Drew DeVault acedbaf9c2 go.*: rollback go shit 2024-02-18 12:51:56 +01:00
Drew DeVault 5dee0b6a52 API: consult with abused on user registration 2024-02-18 12:44:43 +01:00
Drew DeVault 05b19df466 .builds: drop debian, arch 2024-02-09 10:17:32 +01:00
Conrad Hoffmann ce92a1344b Fix typo in 2FA recovery code handling
This lead to an internal server error when attempting to use recovery
codes.
2024-02-02 07:38:16 +01:00
Simon Ser 8d8964ab95 makefile: add loaders to gqlgen deps
Without the loaders, gqlgen fails with:

    validation failed: packages.Load: /home/simon/src/todo.sr.ht/api/loaders/middleware.go:34:26: undefined: EntitiesByParticipantIDLoader
2024-01-31 12:02:41 +01:00
Simon Ser a4f42982d4 makefile: use grouped target for loaders
That way make will only run it once for the whole group.
2024-01-31 11:52:25 +01:00
Simon Ser 342874ec62 makefile: don't re-generate if unchanged
Use make targets to skip "go generate" invocations when unnecessary.

Contrary to the prior iteration in d95f464128 ("makefile: don't
re-generate if unchanged"), this version uses api/graph/api/generated.go
instead of api/graph/schema.resolvers.go to track the freshness of
the GraphQL codegen. This fixes the situation where the GraphQL codegen
is skipped because api/graph/schema.resolvers.go exists and is newer
than its dependencies.
2024-01-26 17:21:14 +01:00
Simon Ser 818761a476 Upgrade chi to v5 2024-01-24 15:16:50 +01:00
Drew DeVault b59ddadb0e api: log error on /query/invoice 2024-01-24 15:08:43 +01:00
Simon Ser 168efaa0cc Upgrade core-go 2024-01-24 12:18:26 +01:00
Jackson 22f41d18d1 add PGP public key placeholder in text box 2024-01-24 09:52:09 +01:00
Jackson 43f7c66830 make gpg command copyable & include email address
also deletes the gpg command from the placeholder
2024-01-24 09:51:51 +01:00
Conrad Hoffmann 89a4881d83 api: use same PGP key ID in emails and database
As explained in the comment a few lines above, what is being used here
for the email is the fingerprint of the encryption subkey, which will be
surprising to most users. Only use it if no main key could be
determined. This was already determined, so just use the same
fingerprint as was written to the database.
2024-01-19 15:55:05 +01:00
Conrad Hoffmann a364cdd1da Revert "pgp keys: allow updates in-place (#151)"
This reverts commit e8ea0241dc.

The update path does not update the actual key material. Also, the error
handling depends on UI strings, which are not guaranteed to be stable.
2024-01-19 14:56:00 +01:00
Simon Ser 9a5aa02c86 Drop gqlparser v1 dependency
We are pulling in v2 already.
2024-01-17 23:19:26 +01:00
Adam House e8ea0241dc pgp keys: allow updates in-place (#151) 2024-01-09 10:32:10 +01:00
Conrad Hoffmann 1af2096b5d Move welcome-emails setting to correct section
The code that uses it has alway looked for it in [meta.sr.ht::settings],
it was apparently put in the wrong section by accident when it was first
added to the example config.
2024-01-09 10:28:38 +01:00
Conrad Hoffmann d5e8e1c6bc metasrht-daily: support for key expiration emails
Adds a new setting key-expiration-emails to [meta.sr.ht::settings],
which, when enabled, will make metasrht-daily send out reminders for PGP
keys that are about to expire (for now, in a month). Assuming
metasrht-daily is not run more than once day, only a single email will
be sent for each key.
2024-01-09 10:28:38 +01:00
Simon Ser e34350b3a2 contrib/key-expiration: fix invalid Printf format specifier
contrib/key-expiration/main.go:94:4: log.Printf format %s has arg id of wrong type int64
2024-01-09 10:25:09 +01:00
Simon Ser dbf0515685 contrib/key-expiration: drop go.mod
We can use the toplevel go.mod instead.
2024-01-09 10:25:09 +01:00
Simon Ser 38ac43f863 Fix OAuth 2.0 expiration time
There is a clash between the GQL API implementation and the RFC:
the GQL API will invalidate the refresh token on expiration, but
the RFC says that the refresh token should remain valid some time
after the access token expires.
2024-01-09 10:25:09 +01:00
Conrad Hoffmann 2b01e164fa api: update core-go dependency
To avoid the build breaking due to sourceware taking one of their repos
offline.
2023-12-11 13:25:13 +01:00
Conrad Hoffmann e5e8717908 api: fix & rename UpdateSSHKey mutation
It currently updates the key creation date. Instead, have it update the
last_used date. Rename it, to make its purposes more clear, and make it
internal, as its only intended use-case is to let the login scripts
update the last_used date. There is no reason to let users mess with
this.
2023-12-04 10:27:48 +01:00
Simon Ser 65272cc3af Add support for OAuth 2 refresh tokens 2023-12-04 10:27:36 +01:00
Simon Ser 3a1d75a5cb Return scope in OAuth token introspection endpoint 2023-11-16 12:15:21 +01:00
Simon Ser ea6b6e2115 Store OAuth grants in DB
See [1] for the motivation. Will allow us to improve OAuth token
introspection support, show the grants for each token in the web
UI, and support refresh tokens.

[1]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/%3Ctb6PWx3aEmUULLfrhprb2AhmfLioLUbSxGnpxAT4qAiSPCuAC_WNCInfJ3b4Aqnp2tonl_FVsnh4bMgKkJ7CLOeQ4iHhLJA1Hv0CLcEt5eg%3D%40emersion.fr%3E
2023-11-16 12:15:21 +01:00
Simon Ser f34b451929 Fix missing variable in issueOAuthGrant GraphQL request 2023-10-30 12:10:10 +01:00
Conrad Hoffmann 9da83dfafb Suggest a different app for TOTP
The current suggestion has been removed from F-Droid. Suggest Aegis
instead, which Does The Job(TM), has some decent features, and seems
reasonable well-maintained.
2023-10-24 15:15:10 +02:00
Conrad Hoffmann a50364359a TOTP recovery: fix misleading error message
Currently, when entering a wrong TOTP recovery code, the user will see
an error message claiming their TOTP was created before the introduction
of recovery codes, even when that's not the case (otherwise they
wouldn't have gotten to enter on in the first place).

This commit fixes that by rendering the template with `supported=true`,
as only users with recovery codes can get to this step (or folks messing
around, but then you don't get to complain about misleading UI).

This makes the template render correctly and display the actual error
message again.

Signed-off-by: Conrad Hoffmann <ch@bitfehler.net>
2023-10-24 15:14:56 +02:00
Simon Ser 673a3aa319 Check client ID in OAuth 2 access token endpoint 2023-10-24 15:14:53 +02:00
Simon Ser 4b89874e56 Use access_token_error() for missing token error in introspection
This sends the error in the standard OAuth 2 format, instead of
using a plain-text response.
2023-10-24 15:14:32 +02:00
Simon Ser e49eba9ec8 api/graph: drop @access from enum values
The expectation with the @access directive is that permission
checks are automatically performed by core-go. However this is
actually a no-op for enum values.

Drop the enum value directives to make it clearer that permission
checks must be performed manually.
2023-10-24 15:14:28 +02:00
Drew DeVault 1eefae9f9e Revert "makefile: don't re-generate if unchanged"
This reverts commit d95f464128.
2023-09-14 14:29:04 +02:00
Conrad Hoffmann cd6c29b5a4 api: return error on client ID lookup failure 2023-09-14 13:49:24 +02:00
Simon Ser d95f464128 makefile: don't re-generate if unchanged
Use make targets to skip "go generate" invocations when unnecessary.
2023-08-31 22:51:53 +02:00
Kim Alvefur 4a080c40c0 Implement OAuth 2.0 Issuer Identification
Ref RFC 9207

Helps OAuth clients distinguish between multiple authorization servers
in cases where they deal with more than one.
2023-08-16 11:58:40 +02:00
Conrad Hoffmann 92b5f7ae0f api: remove obsolete internal sendEmailX mutations
As of todo.sr.ht 0.74.6 there are no longer any users of these initial
attempts to provided internal email sending services. Everything has
been consolidated in the `sendEmail` mutation.

Signed-off-by: Conrad Hoffmann <ch@bitfehler.net>
2023-06-01 12:31:53 +02:00
Conrad Hoffmann 49d589c00d billing: don't try to charge admins
If you were once a paying customer, metasrht-daily will call
`charge_user` on you. Adapt its filter to exclude admin accounts. For
good measure, also always return `ChargeResult.account_current` for
admins to avoid any actual charge attempts.
2023-04-11 14:50:30 +02:00
Thorben Günther 3f27ff66b1 api: Make deleteWebhook non-nullable
This matches with all the other services.
2023-04-11 14:50:27 +02:00