Skip to content

Commit 8ae1fd6

Browse files
authored
Merge branch 'main' into develop
2 parents 7669ff8 + 3dba75f commit 8ae1fd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1704
-892
lines changed

.drone.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ steps:
717717

718718
- name: publish
719719
pull: always
720-
image: plugins/docker:linux-amd64
720+
image: techknowlogick/drone-docker:latest
721721
settings:
722722
auto_tag: true
723723
auto_tag_suffix: linux-amd64
@@ -734,7 +734,7 @@ steps:
734734
- pull_request
735735

736736
- name: publish-rootless
737-
image: plugins/docker:linux-amd64
737+
image: techknowlogick/drone-docker:latest
738738
settings:
739739
dockerfile: Dockerfile.rootless
740740
auto_tag: true
@@ -772,7 +772,7 @@ trigger:
772772
steps:
773773
- name: dryrun
774774
pull: always
775-
image: plugins/docker:linux-arm64
775+
image: techknowlogick/drone-docker:latest
776776
settings:
777777
dry_run: true
778778
repo: gitea/gitea
@@ -814,7 +814,7 @@ steps:
814814

815815
- name: publish
816816
pull: always
817-
image: plugins/docker:linux-arm64
817+
image: techknowlogick/drone-docker:latest
818818
settings:
819819
auto_tag: true
820820
auto_tag_suffix: linux-arm64
@@ -834,7 +834,7 @@ steps:
834834
- pull_request
835835

836836
- name: publish-rootless
837-
image: plugins/docker:linux-arm64
837+
image: techknowlogick/drone-docker:latest
838838
settings:
839839
dockerfile: Dockerfile.rootless
840840
auto_tag: true

cmd/web_letsencrypt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
5454
}
5555

5656
tlsConfig := magic.TLSConfig()
57+
tlsConfig.NextProtos = append(tlsConfig.NextProtos, "h2")
5758

5859
if enableHTTPChallenge {
5960
go func() {

docs/content/doc/usage/email-setup.en-us.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ menu:
1919

2020
{{< toc >}}
2121

22-
To use Gitea's built-in Email support, update the `app.ini` config file [mailer] section:
22+
Gitea has mailer functionality for sending transactional emails (such as registration confirmation). It can be configured to either use Sendmail (or compatible MTAs like Postfix and msmtp) or directly use SMTP server.
2323

24-
## Sendmail version
24+
## Using Sendmail
2525

26-
Use the operating system’s sendmail command instead of SMTP. This is common on Linux servers.
27-
Note: For use in the official Gitea Docker image, please configure with the SMTP version.
26+
Use `sendmail` command as mailer.
27+
28+
Note: For use in the official Gitea Docker image, please configure with the SMTP version (see the following section).
29+
30+
Note: For Internet-facing sites consult documentation of your MTA for instructions to send emails over TLS. Also set up SPF, DMARC, and DKIM DNS records to make emails sent be accepted as legitimate by various email providers.
2831

2932
```ini
3033
[mailer]
@@ -34,7 +37,9 @@ MAILER_TYPE = sendmail
3437
SENDMAIL_PATH = /usr/sbin/sendmail
3538
```
3639

37-
## SMTP version
40+
## Using SMTP
41+
42+
Directly use SMTP server as relay. This option is useful if you don't want to set up MTA on your instance but you have an account at email provider.
3843

3944
```ini
4045
[mailer]
@@ -47,17 +52,19 @@ USER = [email protected]
4752
PASSWD = `password`
4853
```
4954

50-
- Restart Gitea for the configuration changes to take effect.
55+
Restart Gitea for the configuration changes to take effect.
5156

52-
- To send a test email to validate the settings, go to Gitea > Site Administration > Configuration > SMTP Mailer Configuration.
57+
To send a test email to validate the settings, go to Gitea > Site Administration > Configuration > SMTP Mailer Configuration.
5358

5459
For the full list of options check the [Config Cheat Sheet]({{< relref "doc/advanced/config-cheat-sheet.en-us.md" >}})
5560

56-
- Please note: authentication is only supported when the SMTP server communication is encrypted with TLS or `HOST=localhost`. TLS encryption can be through:
57-
- Via the server supporting TLS through STARTTLS - usually provided on port 587. (Also known as Opportunistic TLS.)
58-
- SMTPS connection (SMTP over transport layer security) via the default port 465.
61+
Please note: authentication is only supported when the SMTP server communication is encrypted with TLS or `HOST=localhost`. TLS encryption can be through:
62+
- STARTTLS (also known as Opportunistic TLS) via port 587. Initial connection is done over cleartext, but then be upgraded over TLS if the server supports it.
63+
- SMTPS connection (SMTP over TLS) via the default port 465. Connection to the server use TLS from the beginning.
5964
- Forced SMTPS connection with `IS_TLS_ENABLED=true`. (These are both known as Implicit TLS.)
60-
- This is due to protections imposed by the Go internal libraries against STRIPTLS attacks.
65+
This is due to protections imposed by the Go internal libraries against STRIPTLS attacks.
66+
67+
Note that Implicit TLS is recommended by [RFC8314](https://tools.ietf.org/html/rfc8314#section-3) since 2018.
6168

6269
### Gmail
6370

@@ -74,3 +81,4 @@ MAILER_TYPE = smtp
7481
IS_TLS_ENABLED = true
7582
HELO_HOSTNAME = example.com
7683
```
84+

integrations/api_gpg_keys_test.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ func TestGPGKeys(t *testing.T) {
2929
results []int
3030
}{
3131
{name: "NoLogin", makeRequest: MakeRequest, token: "",
32-
results: []int{http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized},
32+
results: []int{http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized, http.StatusUnauthorized},
3333
},
3434
{name: "LoggedAsUser2", makeRequest: session.MakeRequest, token: token,
35-
results: []int{http.StatusOK, http.StatusOK, http.StatusNotFound, http.StatusNoContent, http.StatusUnprocessableEntity, http.StatusNotFound, http.StatusCreated, http.StatusCreated}},
35+
results: []int{http.StatusOK, http.StatusOK, http.StatusNotFound, http.StatusNoContent, http.StatusUnprocessableEntity, http.StatusNotFound, http.StatusCreated, http.StatusNotFound, http.StatusCreated}},
3636
}
3737

3838
for _, tc := range tt {
@@ -60,7 +60,7 @@ func TestGPGKeys(t *testing.T) {
6060
t.Run("CreateValidGPGKey", func(t *testing.T) {
6161
testCreateValidGPGKey(t, tc.makeRequest, tc.token, tc.results[6])
6262
})
63-
t.Run("CreateValidSecondaryEmailGPGKey", func(t *testing.T) {
63+
t.Run("CreateValidSecondaryEmailGPGKeyNotActivated", func(t *testing.T) {
6464
testCreateValidSecondaryEmailGPGKey(t, tc.makeRequest, tc.token, tc.results[7])
6565
})
6666
})
@@ -74,6 +74,7 @@ func TestGPGKeys(t *testing.T) {
7474
req := NewRequest(t, "GET", "/api/v1/user/gpg_keys?token="+token) //GET all keys
7575
resp := session.MakeRequest(t, req, http.StatusOK)
7676
DecodeJSON(t, resp, &keys)
77+
assert.Len(t, keys, 1)
7778

7879
primaryKey1 := keys[0] //Primary key 1
7980
assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID)
@@ -85,12 +86,6 @@ func TestGPGKeys(t *testing.T) {
8586
assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID)
8687
assert.Empty(t, subKey.Emails)
8788

88-
primaryKey2 := keys[1] //Primary key 2
89-
assert.EqualValues(t, "3CEF46EF40BEFC3E", primaryKey2.KeyID)
90-
assert.Len(t, primaryKey2.Emails, 1)
91-
assert.EqualValues(t, "[email protected]", primaryKey2.Emails[0].Email)
92-
assert.False(t, primaryKey2.Emails[0].Verified)
93-
9489
var key api.GPGKey
9590
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey1.ID, 10)+"?token="+token) //Primary key 1
9691
resp = session.MakeRequest(t, req, http.StatusOK)
@@ -105,15 +100,6 @@ func TestGPGKeys(t *testing.T) {
105100
DecodeJSON(t, resp, &key)
106101
assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID)
107102
assert.Empty(t, key.Emails)
108-
109-
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(primaryKey2.ID, 10)+"?token="+token) //Primary key 2
110-
resp = session.MakeRequest(t, req, http.StatusOK)
111-
DecodeJSON(t, resp, &key)
112-
assert.EqualValues(t, "3CEF46EF40BEFC3E", key.KeyID)
113-
assert.Len(t, key.Emails, 1)
114-
assert.EqualValues(t, "[email protected]", key.Emails[0].Email)
115-
assert.False(t, key.Emails[0].Verified)
116-
117103
})
118104

119105
//Check state after basic add

integrations/repo_commits_test.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,36 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
7373

7474
//By SHA
7575
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)+"/statuses")
76-
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
76+
reqOne := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)+"/status")
77+
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
78+
7779
//By Ref
7880
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/master/statuses")
79-
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
81+
reqOne = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/master/status")
82+
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
8083
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/v1.1/statuses")
81-
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), state)
84+
reqOne = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/v1.1/status")
85+
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
8286
}
8387

84-
func testRepoCommitsWithStatus(t *testing.T, resp *httptest.ResponseRecorder, state string) {
88+
func testRepoCommitsWithStatus(t *testing.T, resp, respOne *httptest.ResponseRecorder, state string) {
8589
json := jsoniter.ConfigCompatibleWithStandardLibrary
86-
decoder := json.NewDecoder(resp.Body)
87-
statuses := []*api.CommitStatus{}
88-
assert.NoError(t, decoder.Decode(&statuses))
89-
assert.Len(t, statuses, 1)
90-
for _, s := range statuses {
91-
assert.Equal(t, api.CommitStatusState(state), s.State)
92-
assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", s.URL)
93-
assert.Equal(t, "http://test.ci/", s.TargetURL)
94-
assert.Equal(t, "", s.Description)
95-
assert.Equal(t, "testci", s.Context)
90+
var statuses []*api.CommitStatus
91+
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), &statuses))
92+
var status api.CombinedStatus
93+
assert.NoError(t, json.Unmarshal(respOne.Body.Bytes(), &status))
94+
assert.NotNil(t, status)
95+
96+
if assert.Len(t, statuses, 1) {
97+
assert.Equal(t, api.CommitStatusState(state), statuses[0].State)
98+
assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", statuses[0].URL)
99+
assert.Equal(t, "http://test.ci/", statuses[0].TargetURL)
100+
assert.Equal(t, "", statuses[0].Description)
101+
assert.Equal(t, "testci", statuses[0].Context)
102+
103+
assert.Len(t, status.Statuses, 1)
104+
assert.Equal(t, statuses[0], status.Statuses[0])
105+
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.SHA)
96106
}
97107
}
98108

models/error.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ func (err ErrKeyNameAlreadyUsed) Error() string {
451451
// ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
452452
type ErrGPGNoEmailFound struct {
453453
FailedEmails []string
454+
ID string
454455
}
455456

456457
// IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.
@@ -463,6 +464,22 @@ func (err ErrGPGNoEmailFound) Error() string {
463464
return fmt.Sprintf("none of the emails attached to the GPG key could be found: %v", err.FailedEmails)
464465
}
465466

467+
// ErrGPGInvalidTokenSignature represents a "ErrGPGInvalidTokenSignature" kind of error.
468+
type ErrGPGInvalidTokenSignature struct {
469+
Wrapped error
470+
ID string
471+
}
472+
473+
// IsErrGPGInvalidTokenSignature checks if an error is a ErrGPGInvalidTokenSignature.
474+
func IsErrGPGInvalidTokenSignature(err error) bool {
475+
_, ok := err.(ErrGPGInvalidTokenSignature)
476+
return ok
477+
}
478+
479+
func (err ErrGPGInvalidTokenSignature) Error() string {
480+
return "the provided signature does not sign the token with the provided key"
481+
}
482+
466483
// ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.
467484
type ErrGPGKeyParsing struct {
468485
ParseError error

0 commit comments

Comments
 (0)