Skip to content

Commit 249b86d

Browse files
GustedAbdulrhmnGhanem
Gusted
authored andcommitted
Disable federation by default (go-gitea#20045)
1 parent f806bcb commit 249b86d

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

custom/conf/app.example.ini

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,27 +2249,27 @@ PATH =
22492249
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22502250
;;
22512251
;; Enable/Disable federation capabilities
2252-
; ENABLED = true
2252+
;ENABLED = false
22532253
;;
22542254
;; Enable/Disable user statistics for nodeinfo if federation is enabled
2255-
; SHARE_USER_STATISTICS = true
2255+
;SHARE_USER_STATISTICS = true
22562256
;;
22572257
;; Maximum federation request and response size (MB)
2258-
; MAX_SIZE = 4
2258+
;MAX_SIZE = 4
22592259
;;
22602260
;; WARNING: Changing the settings below can break federation.
22612261
;;
22622262
;; HTTP signature algorithms
2263-
; ALGORITHMS = rsa-sha256, rsa-sha512, ed25519
2263+
;ALGORITHMS = rsa-sha256, rsa-sha512, ed25519
22642264
;;
22652265
;; HTTP signature digest algorithm
2266-
; DIGEST_ALGORITHM = SHA-256
2266+
;DIGEST_ALGORITHM = SHA-256
22672267
;;
22682268
;; GET headers for federation requests
2269-
; GET_HEADERS = (request-target), Date
2269+
;GET_HEADERS = (request-target), Date
22702270
;;
22712271
;; POST headers for federation requests
2272-
; POST_HEADERS = (request-target), Date, Digest
2272+
;POST_HEADERS = (request-target), Date, Digest
22732273

22742274
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22752275
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
10881088

10891089
## Federation (`federation`)
10901090

1091-
- `ENABLED`: **true**: Enable/Disable federation capabilities
1091+
- `ENABLED`: **false**: Enable/Disable federation capabilities
10921092
- `SHARE_USER_STATISTICS`: **true**: Enable/Disable user statistics for nodeinfo if federation is enabled
10931093
- `MAX_SIZE`: **4**: Maximum federation request and response size (MB)
10941094

integrations/api_activitypub_person_test.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ import (
1515
user_model "code.gitea.io/gitea/models/user"
1616
"code.gitea.io/gitea/modules/activitypub"
1717
"code.gitea.io/gitea/modules/setting"
18+
"code.gitea.io/gitea/routers"
1819

1920
ap "github.com/go-ap/activitypub"
2021
"github.com/stretchr/testify/assert"
2122
)
2223

2324
func TestActivityPubPerson(t *testing.T) {
24-
onGiteaRun(t, func(*testing.T, *url.URL) {
25-
setting.Federation.Enabled = true
26-
defer func() {
27-
setting.Federation.Enabled = false
28-
}()
25+
setting.Federation.Enabled = true
26+
c = routers.NormalRoutes()
27+
defer func() {
28+
setting.Federation.Enabled = false
29+
c = routers.NormalRoutes()
30+
}()
2931

32+
onGiteaRun(t, func(*testing.T, *url.URL) {
3033
username := "user2"
3134
req := NewRequestf(t, "GET", fmt.Sprintf("/api/v1/activitypub/user/%s", username))
3235
resp := MakeRequest(t, req, http.StatusOK)
@@ -56,28 +59,35 @@ func TestActivityPubPerson(t *testing.T) {
5659
}
5760

5861
func TestActivityPubMissingPerson(t *testing.T) {
59-
onGiteaRun(t, func(*testing.T, *url.URL) {
60-
setting.Federation.Enabled = true
61-
defer func() {
62-
setting.Federation.Enabled = false
63-
}()
62+
setting.Federation.Enabled = true
63+
c = routers.NormalRoutes()
64+
defer func() {
65+
setting.Federation.Enabled = false
66+
c = routers.NormalRoutes()
67+
}()
6468

69+
onGiteaRun(t, func(*testing.T, *url.URL) {
6570
req := NewRequestf(t, "GET", "/api/v1/activitypub/user/nonexistentuser")
6671
resp := MakeRequest(t, req, http.StatusNotFound)
6772
assert.Contains(t, resp.Body.String(), "user redirect does not exist")
6873
})
6974
}
7075

7176
func TestActivityPubPersonInbox(t *testing.T) {
77+
setting.Federation.Enabled = true
78+
c = routers.NormalRoutes()
79+
defer func() {
80+
setting.Federation.Enabled = false
81+
c = routers.NormalRoutes()
82+
}()
83+
7284
srv := httptest.NewServer(c)
7385
defer srv.Close()
7486

7587
onGiteaRun(t, func(*testing.T, *url.URL) {
7688
appURL := setting.AppURL
77-
setting.Federation.Enabled = true
7889
setting.AppURL = srv.URL
7990
defer func() {
80-
setting.Federation.Enabled = false
8191
setting.Database.LogSQL = false
8292
setting.AppURL = appURL
8393
}()

integrations/api_nodeinfo_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ import (
1111

1212
"code.gitea.io/gitea/modules/setting"
1313
api "code.gitea.io/gitea/modules/structs"
14+
"code.gitea.io/gitea/routers"
1415

1516
"github.com/stretchr/testify/assert"
1617
)
1718

1819
func TestNodeinfo(t *testing.T) {
19-
onGiteaRun(t, func(*testing.T, *url.URL) {
20-
setting.Federation.Enabled = true
21-
defer func() {
22-
setting.Federation.Enabled = false
23-
}()
20+
setting.Federation.Enabled = true
21+
c = routers.NormalRoutes()
22+
defer func() {
23+
setting.Federation.Enabled = false
24+
c = routers.NormalRoutes()
25+
}()
2426

27+
onGiteaRun(t, func(*testing.T, *url.URL) {
2528
req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
2629
resp := MakeRequest(t, req, http.StatusOK)
2730
var nodeinfo api.NodeInfo

modules/setting/federation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121
GetHeaders []string
2222
PostHeaders []string
2323
}{
24-
Enabled: true,
24+
Enabled: false,
2525
ShareUserStatistics: true,
2626
MaxSize: 4,
2727
Algorithms: []string{"rsa-sha256", "rsa-sha512", "ed25519"},

0 commit comments

Comments
 (0)