Skip to content

Commit 82b1542

Browse files
authored
Merge branch 'main' into wip-links
2 parents 2d25928 + 5c7e2f4 commit 82b1542

Some content is hidden

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

75 files changed

+557
-402
lines changed

.drone.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ services:
153153
MYSQL_DATABASE: test
154154

155155
- name: mysql8
156-
image: mysql:8.0
156+
image: mysql:8
157157
environment:
158158
MYSQL_ALLOW_EMPTY_PASSWORD: yes
159159
MYSQL_DATABASE: testgitea
@@ -319,7 +319,7 @@ trigger:
319319
services:
320320
- name: pgsql
321321
pull: default
322-
image: postgres:9.5
322+
image: postgres:10
323323
environment:
324324
POSTGRES_DB: test
325325
POSTGRES_PASSWORD: postgres
@@ -503,7 +503,7 @@ steps:
503503
pull: always
504504
image: techknowlogick/xgo:go-1.16.x
505505
commands:
506-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
506+
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
507507
- export PATH=$PATH:$GOPATH/bin
508508
- make release
509509
environment:
@@ -599,7 +599,7 @@ steps:
599599
pull: always
600600
image: techknowlogick/xgo:go-1.16.x
601601
commands:
602-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
602+
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
603603
- export PATH=$PATH:$GOPATH/bin
604604
- make release
605605
environment:

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Please check the following:
22

3-
1. Make sure you are targeting the `master` branch, pull requests on release branches are only allowed for bug fixes.
3+
1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes.
44
2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/master/CONTRIBUTING.md
55
3. Describe what your pull request does and which issue you're targeting (if any)
66

Dockerfile.rootless

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RUN apk --no-cache add \
3535
ca-certificates \
3636
gettext \
3737
git \
38+
curl \
3839
gnupg
3940

4041
RUN addgroup \

cmd/serv.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func fail(userMessage, logMessage string, args ...interface{}) {
8181
}
8282
}
8383

84+
if len(logMessage) > 0 {
85+
_ = private.SSHLog(true, fmt.Sprintf(logMessage+": ", args...))
86+
}
87+
8488
os.Exit(1)
8589
}
8690

contrib/systemd/gitea.service

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@ Description=Gitea (Git with a cup of tea)
33
After=syslog.target
44
After=network.target
55
###
6-
# Don't forget to add the database service requirements
6+
# Don't forget to add the database service dependencies
77
###
88
#
9-
#Requires=mysql.service
10-
#Requires=mariadb.service
11-
#Requires=postgresql.service
12-
#Requires=memcached.service
13-
#Requires=redis.service
9+
#Wants=mysql.service
10+
#After=mysql.service
11+
#
12+
#Wants=mariadb.service
13+
#After=mariadb.service
14+
#
15+
#Wants=postgresql.service
16+
#After=postgresql.service
17+
#
18+
#Wants=memcached.service
19+
#After=memcached.service
20+
#
21+
#Wants=redis.service
22+
#After=redis.service
1423
#
1524
###
1625
# If using socket activation for main http/s

custom/conf/app.example.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ ROUTER = console
444444
;ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
445445
;;
446446
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
447+
;;
448+
;; SSH log (Creates log from ssh git request)
449+
;;
450+
;ENABLE_SSH_LOG = false
451+
;;
447452
;; Other Settings
448453
;;
449454
;; Print Stacktraces with logs. (Rarely helpful.) Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "None"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ Default templates for project boards:
657657
- `ROUTER`: **console**: The mode or name of the log the router should log to. (If you set this to `,` it will log to default gitea logger.)
658658
NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take effect. Configure each mode in per mode log subsections `\[log.modename.router\]`.
659659
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
660+
- `ENABLE_SSH_LOG`: **false**: save ssh log to log file
660661
- `ACCESS`: **file**: Logging mode for the access logger, use a comma to separate values. Configure each mode in per mode log subsections `\[log.modename.access\]`. By default the file mode will log to `$ROOT_PATH/access.log`. (If you set this to `,` it will log to the default gitea logger.)
661662
- `ACCESS_LOG_TEMPLATE`: **`{{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"`**: Sets the template used to create the access log.
662663
- The following variables are available:

docs/content/doc/developers/api-usage.en-us.md

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,42 @@ better understand this by looking at the code -- as of this writing,
4040
Gitea parses queries and headers to find the token in
4141
[modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47).
4242

43-
You can create an API key token via your Gitea installation's web interface:
44-
`Settings | Applications | Generate New Token`.
43+
## Generating and listing API tokens
44+
45+
A new token can be generated with a `POST` request to
46+
`/users/:name/tokens`.
47+
48+
Note that `/users/:name/tokens` is a special endpoint and requires you
49+
to authenticate using `BasicAuth` and a password, as follows:
50+
51+
52+
```sh
53+
$ curl -XPOST -H "Content-Type: application/json" -k -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens
54+
{"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"}
55+
```
56+
57+
The ``sha1`` (the token) is only returned once and is not stored in
58+
plain-text. It will not be displayed when listing tokens with a `GET`
59+
request; e.g.
60+
61+
```sh
62+
$ curl --request GET --url https://yourusername:[email protected]/api/v1/users/<username>/tokens
63+
[{"name":"test","sha1":"","token_last_eight:"........":},{"name":"dev","sha1":"","token_last_eight":"........"}]
64+
```
65+
66+
To use the API with basic authentication with two factor authentication
67+
enabled, you'll need to send an additional header that contains the one
68+
time password (6 digitrotating token).
69+
An example of the header is `X-Gitea-OTP: 123456` where `123456`
70+
is where you'd place the code from your authenticator.
71+
Here is how the request would look like in curl:
72+
73+
```sh
74+
$ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:[email protected]/api/v1/users/yourusername/tokens
75+
```
76+
77+
You can also create an API key token via your Gitea installation's web
78+
interface: `Settings | Applications | Generate New Token`.
4579
4680
## OAuth2 Provider
4781
@@ -82,26 +116,6 @@ or on
82116
The OpenAPI document is at:
83117
`https://gitea.your.host/swagger.v1.json`
84118
85-
## Listing your issued tokens via the API
86-
87-
As mentioned in
88-
[#3842](https://github.com/go-gitea/gitea/issues/3842#issuecomment-397743346),
89-
`/users/:name/tokens` is special and requires you to authenticate
90-
using BasicAuth, as follows:
91-
92-
### Using basic authentication:
93-
94-
```sh
95-
$ curl --request GET --url https://yourusername:[email protected]/api/v1/users/yourusername/tokens
96-
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}]
97-
```
98-
99-
As of v1.8.0 of Gitea, if using basic authentication with the API and your user has two factor authentication enabled, you'll need to send an additional header that contains the one time password (6 digit rotating token). An example of the header is `X-Gitea-OTP: 123456` where `123456` is where you'd place the code from your authenticator. Here is how the request would look like in curl:
100-
101-
```sh
102-
$ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:[email protected]/api/v1/users/yourusername/tokens
103-
```
104-
105119
## Sudo
106120
107121
The API allows admin users to sudo API requests as another user. Simply add either a `sudo=` parameter or `Sudo:` request header with the username of the user to sudo.

docs/content/doc/developers/hacking-on-gitea.en-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ See `make help` for all available `make` targets. Also see [`.drone.yml`](https:
127127

128128
## Building continuously
129129

130-
To run and continously rebuild when source files change:
130+
To run and continuously rebuild when source files change:
131131

132132
```bash
133133
make watch
@@ -216,7 +216,7 @@ You should validate your generated Swagger file and spell-check it with:
216216
make swagger-validate misspell-check
217217
```
218218

219-
You should commit the changed swagger JSON file. The continous integration
219+
You should commit the changed swagger JSON file. The continuous integration
220220
server will check that this has been done using:
221221

222222
```bash
@@ -315,7 +315,7 @@ branches as we will need to update it to main before merging and/or may be
315315
able to help fix issues directly.
316316

317317
Any PR requires two approvals from the Gitea maintainers and needs to pass the
318-
continous integration. Take a look at our
318+
continuous integration. Take a look at our
319319
[`CONTRIBUTING.md`](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md)
320320
document.
321321

docs/content/doc/features/authentication.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ Adds the following fields:
8888
- Bind Password (optional)
8989

9090
- The password for the Bind DN specified above, if any. _Note: The password
91-
is stored in plaintext at the server. As such, ensure that the Bind DN
92-
has as few privileges as possible._
91+
is stored encrypted with the SECRET_KEY on the server. It is still recommended
92+
to ensure that the Bind DN has as few privileges as possible._
9393

9494
- User Search Base **(required)**
9595

docs/content/doc/installation/with-docker-rootless.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ services:
107107
+ - db
108108
+
109109
+ db:
110-
+ image: mysql:5.7
110+
+ image: mysql:8
111111
+ restart: always
112112
+ environment:
113113
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -148,7 +148,7 @@ services:
148148
+ - db
149149
+
150150
+ db:
151-
+ image: postgres:9.6
151+
+ image: postgres:13
152152
+ restart: always
153153
+ environment:
154154
+ - POSTGRES_USER=gitea

docs/content/doc/installation/with-docker.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ services:
137137
+ - db
138138
+
139139
+ db:
140-
+ image: mysql:5.7
140+
+ image: mysql:8
141141
+ restart: always
142142
+ environment:
143143
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -188,7 +188,7 @@ services:
188188
+ - db
189189
+
190190
+ db:
191-
+ image: postgres:9.6
191+
+ image: postgres:13
192192
+ restart: always
193193
+ environment:
194194
+ - POSTGRES_USER=gitea

docs/content/doc/installation/with-docker.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ services:
122122
+ - db
123123
+
124124
+ db:
125-
+ image: mysql:5.7
125+
+ image: mysql:8
126126
+ restart: always
127127
+ environment:
128128
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -172,7 +172,7 @@ services:
172172
+ - db
173173
+
174174
+ db:
175-
+ image: postgres:9.6
175+
+ image: postgres:13
176176
+ restart: always
177177
+ environment:
178178
+ - POSTGRES_USER=gitea

integrations/README_ZH.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ make test-sqlite
2626
## 如何使用 mysql 数据库进行集成测试
2727
首先在docker容器里部署一个 mysql 数据库
2828
```
29-
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:5.7 #(just ctrl-c to stop db and clean the container)
29+
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:8 #(just ctrl-c to stop db and clean the container)
3030
```
3131
之后便可以基于这个数据库进行集成测试
3232
```
@@ -36,7 +36,7 @@ TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root T
3636
## 如何使用 pgsql 数据库进行集成测试
3737
同上,首先在 docker 容器里部署一个 pgsql 数据库
3838
```
39-
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
39+
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:13 #(just ctrl-c to stop db and clean the container)
4040
```
4141
之后便可以基于这个数据库进行集成测试
4242
```

models/admin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ func DeleteNotice(id int64) error {
114114

115115
// DeleteNotices deletes all notices with ID from start to end (inclusive).
116116
func DeleteNotices(start, end int64) error {
117+
if start == 0 && end == 0 {
118+
_, err := x.Exec("DELETE FROM notice")
119+
return err
120+
}
121+
117122
sess := x.Where("id >= ?", start)
118123
if end > 0 {
119124
sess.And("id <= ?", end)

models/avatar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const DefaultAvatarSize = -1
4444
const DefaultAvatarPixelSize = 28
4545

4646
// AvatarRenderedSizeFactor is the factor by which the default size is increased for finer rendering
47-
const AvatarRenderedSizeFactor = 2
47+
const AvatarRenderedSizeFactor = 4
4848

4949
// HashEmail hashes email address to MD5 string.
5050
// https://en.gravatar.com/site/implement/hash/

models/login_source.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"code.gitea.io/gitea/modules/auth/oauth2"
1919
"code.gitea.io/gitea/modules/auth/pam"
2020
"code.gitea.io/gitea/modules/log"
21+
"code.gitea.io/gitea/modules/secret"
2122
"code.gitea.io/gitea/modules/setting"
2223
"code.gitea.io/gitea/modules/timeutil"
2324
"code.gitea.io/gitea/modules/util"
@@ -77,11 +78,25 @@ type LDAPConfig struct {
7778
// FromDB fills up a LDAPConfig from serialized format.
7879
func (cfg *LDAPConfig) FromDB(bs []byte) error {
7980
json := jsoniter.ConfigCompatibleWithStandardLibrary
80-
return json.Unmarshal(bs, &cfg)
81+
err := json.Unmarshal(bs, &cfg)
82+
if err != nil {
83+
return err
84+
}
85+
if cfg.BindPasswordEncrypt != "" {
86+
cfg.BindPassword, err = secret.DecryptSecret(setting.SecretKey, cfg.BindPasswordEncrypt)
87+
cfg.BindPasswordEncrypt = ""
88+
}
89+
return err
8190
}
8291

8392
// ToDB exports a LDAPConfig to a serialized format.
8493
func (cfg *LDAPConfig) ToDB() ([]byte, error) {
94+
var err error
95+
cfg.BindPasswordEncrypt, err = secret.EncryptSecret(setting.SecretKey, cfg.BindPassword)
96+
if err != nil {
97+
return nil, err
98+
}
99+
cfg.BindPassword = ""
85100
json := jsoniter.ConfigCompatibleWithStandardLibrary
86101
return json.Marshal(cfg)
87102
}

modules/auth/ldap/ldap.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Source struct {
3535
SecurityProtocol SecurityProtocol
3636
SkipVerify bool
3737
BindDN string // DN to bind with
38+
BindPasswordEncrypt string // Encrypted Bind BN password
3839
BindPassword string // Bind DN password
3940
UserBase string // Base search path for users
4041
UserDN string // Template for the DN of the user for simple auth

modules/git/command.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.
124124

125125
cmd := exec.CommandContext(ctx, c.name, c.args...)
126126
if env == nil {
127-
cmd.Env = append(os.Environ(), fmt.Sprintf("LC_ALL=%s", DefaultLocale))
127+
cmd.Env = os.Environ()
128128
} else {
129129
cmd.Env = env
130-
cmd.Env = append(cmd.Env, fmt.Sprintf("LC_ALL=%s", DefaultLocale))
131130
}
132131

132+
cmd.Env = append(
133+
cmd.Env,
134+
fmt.Sprintf("LC_ALL=%s", DefaultLocale),
135+
// avoid prompting for credentials interactively, supported since git v2.3
136+
"GIT_TERMINAL_PROMPT=0",
137+
)
138+
133139
// TODO: verify if this is still needed in golang 1.15
134140
if goVersionLessThan115 {
135141
cmd.Env = append(cmd.Env, "GODEBUG=asyncpreemptoff=1")

0 commit comments

Comments
 (0)