Commit graph

994 commits

Author SHA1 Message Date
f602958f3c
Use ctx.ServerError in reqsignature.go 2022-06-18 17:04:02 -05:00
4ffb6b64bc
Use ctx.ServerError and remove all remote interaction code from webfinger.go 2022-06-18 16:30:30 -05:00
7c10ab9fde
Change Gitea user agent from the default to Gitea/Version 2022-06-18 13:08:00 -05:00
37d2d01f8f
Use go-ap/jsonld to add @context and marshal JSON 2022-06-18 12:27:11 -05:00
8e6f3fbf46
Update go-ap to fix empty liked collection and removed unneeded HTTP headers 2022-06-17 11:10:51 -05:00
6543
7e1784fd3f
Merge branch 'main' into feature-activitypub 2022-06-16 22:09:41 +02:00
a1012112796
e3e06d13af
fix permission check for delete tag (#19985)
fix #19970

by the way, fix some error response about protected tags.

Signed-off-by: a1012112796 <1012112796@qq.com>
2022-06-16 22:03:03 +02:00
c118dacde7
Move getting the RFC 2616 time to a separate function 2022-06-16 11:17:05 -05:00
0c49fea641
Don't multiply Federation.MaxSize by 1<<20 twice 2022-06-16 11:00:24 -05:00
6336ba2e83
Add better comments 2022-06-16 10:59:36 -05:00
a2d5202d4e
Limit maximum ActivityPub request and response sizes to a configurable setting 2022-06-15 20:43:19 -05:00
e9e8a03e08
Use activitypub.ActivityStreamsContentType for Person response Content Type 2022-06-15 20:29:01 -05:00
3fe44596de
Revert "Use ctx.JSON in Person response to make code cleaner"
This doesn't work because the ctx.JSON() function already sends the response out and it's too late to edit the headers.

This reverts commit 95aad98897.
2022-06-15 20:26:47 -05:00
95aad98897
Use ctx.JSON in Person response to make code cleaner 2022-06-15 20:22:05 -05:00
f48115f5f0
Go back to using ap.IRI to generate inbox and outbox IRIs 2022-06-14 21:34:37 -05:00
1da4849ad7
Merge remote-tracking branch 'github/feature-activitypub' into feature-activitypub 2022-06-14 21:33:31 -05:00
14cfd8de23
Revert "If httpsig verification fails, fix Host header and try again"
This reverts commit f53e46c721.

The bug was actually caused by nginx messing up the Host header when reverse-proxying since I didn't have the line `proxy_set_header Host $host;` in my nginx config for Gitea.
2022-06-14 21:11:55 -05:00
6543
f8ad1a832f
Apply suggestions from code review
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-06-15 03:19:34 +02:00
f53e46c721
If httpsig verification fails, fix Host header and try again
This fixes a very rare bug when Gitea and another AP server (confirmed to happen with Mastodon) are running on the same machine, Gitea fails to verify incoming HTTP signatures. This is because the other AP server creates the sig with the public Gitea domain as the Host. However, when Gitea receives the request, the Host header is instead localhost, so the signature verification fails. Manually changing the host header to the correct value and trying the verification again fixes the bug.
2022-06-14 16:23:08 -05:00
a3120079a5
Make sure Person IRIs are generated correctly
This commit ensures that if the setting.AppURL is something like "http://127.0.0.1:42567" (like in the integration tests), a trailing slash will be added after that URL.
2022-06-14 12:30:36 -05:00
d06772b376
Return if marshalling error 2022-06-14 12:26:06 -05:00
e60158c70b
Make sure API responses always refer to username in original case
Copied from what I wrote on #19133 discussion: Handling username case is a very tricky issue and I've already encountered a Mastodon <-> Gitea federation bug due to Gitea considering Ta180m and ta180m to be the same user while Mastodon thinks they are two different users. I think the best way forward is for Gitea to only use the original case version of the username for federation so other AP software don't get confused.
2022-06-14 12:01:41 -05:00
add8469813
Merge branch 'feature-activitypub' of github.com:Ta180m/Gitea into feature-activitypub 2022-06-14 10:54:19 -05:00
6543
3f2d8b015f
dont drop err 2022-06-14 14:26:41 +02:00
6543
900ceb2dfd
make fmt 2022-06-14 14:12:00 +02:00
08eebffb0e
Make sure HTTP request Date in GMT 2022-06-13 23:10:36 -05:00
d749f8ff4f
Rename pkey to pubKey 2022-06-13 20:51:49 -05:00
f88979326c
Make sure Person endpoint has Content-Type application/activity+json and includes PreferredUsername, URL, and Icon
Setting the correct Content-Type is essential for federating with Mastodon
2022-06-13 17:14:41 -05:00
718f35aab6
Merge remote-tracking branch 'upstream/main' into feature-activitypub 2022-06-13 16:49:36 -05:00
Lunny Xiao
1a9821f57a
Move issues related files into models/issues (#19931)
* Move access and repo permission to models/perm/access

* fix test

* fix git test

* Move functions sequence

* Some improvements per @KN4CK3R and @delvh

* Move issues related code to models/issues

* Move some issues related sub package

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

* Rename some files
2022-06-13 17:37:59 +08:00
yutotnh
3708ca8e28
fix: some typos (#19956) 2022-06-13 15:34:46 +08:00
191919e7fa
Merge remote-tracking branch 'upstream/main' into feature-activitypub 2022-06-12 14:25:41 -05:00
Lunny Xiao
110fc57cbc
Move some code into models/git (#19879)
* Move access and repo permission to models/perm/access

* fix test

* Move some git related files into sub package models/git

* Fix build

* fix git test

* move lfs to sub package

* move more git related functions to models/git

* Move functions sequence

* Some improvements per @KN4CK3R and @delvh
2022-06-12 23:51:54 +08:00
6074222377
Code cleanup 2022-06-11 21:15:45 -05:00
528c282d68
Correctly add inbox/outbox IRIs to person 2022-06-11 12:40:10 -05:00
cf6aed386d
Use @mariusor's suggestions for idiomatic go-ap usage 2022-06-11 11:00:45 -05:00
86a3221563
Fix CI errors by adding @context to Person() and making sure types match 2022-06-10 11:04:07 -05:00
46cab80ef4
Fix JSON unmarshall error 2022-06-10 10:37:55 -05:00
a8cb4a80bf
Convert remaining code to go-ap 2022-06-09 17:59:43 -05:00
57e6b67095
make fmt 2022-06-09 17:43:54 -05:00
1e57f01001
Merge remote-tracking branch 'github/main' into feature-activitypub 2022-06-09 17:18:33 -05:00
Lunny Xiao
26095115f4
Move some repository related code into sub package (#19711)
* Move some repository related code into sub package

* Move more repository functions out of models

* Fix lint

* Some performance optimization for webhooks and others

* some refactors

* Fix lint

* Fix

* Update modules/repository/delete.go

Co-authored-by: delvh <dev.lh@web.de>

* Fix test

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

Co-authored-by: delvh <dev.lh@web.de>
2022-06-06 16:01:49 +08:00
Wim
e528e2b435
Implement http signatures support for the API (#17565)
Fixes #12338

This allows use to talk to the API with our ssh certificate (and/or ssh-agent) without needing to fetch an API key or tokens.
It will just automatically work when users have added their ssh principal in gitea.

This needs client code in tea
Update: also support normal pubkeys

ref: https://tools.ietf.org/html/draft-cavage-http-signatures

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-05 08:16:14 +01:00
qwerty287
df9612bb53
Add API to serve blob or LFS file content (#19689)
* Add LFS API

* Update routers/api/v1/repo/file.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Apply suggestions

* Apply suggestions

* Update routers/api/v1/repo/file.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Report errors

* ADd test

* Use own repo for test

* Use different repo name

* Improve handling

* Slight restructures

1. Avoid reading the blob data multiple times
2. Ensure that caching is only checked when about to serve the blob/lfs
3. Avoid nesting by returning early
4. Make log message a bit more clear
5. Ensure that the dataRc is closed by defer when passed to ServeData

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-04 21:17:53 +08:00
Lunny Xiao
e09fb30d34
improvement some release related code (#19867) 2022-06-03 02:13:58 -04:00
becdf5e1f1
Use go-ap instead of go-fed 2022-05-23 11:43:59 -05:00
Lunny Xiao
fd7d83ace6
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context
* remove some unnecessary wrap functions
2022-05-20 22:08:52 +08:00
KN4CK3R
9ea9206406
ContainerRegistry - removed Basic Auth header (#19735)
* Removed Basic Auth header.

* Fixed test.
2022-05-17 19:58:42 +08:00
zeripath
d494cc3356
Fix nodeinfo caching and prevent NPE if cache non-existent (#19721)
Extract from #19703

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-05-16 15:36:57 +08:00
6543
b135313c47
[Refactor] convert team(s) to apiTeam(s) (#13745)
* Refactor: teams to api convert

* make org load optional

* more info in tests
2022-05-13 19:27:58 +02:00