Skip to content

Commit 9a77e66

Browse files
authored
Merge branch 'main' into feature-email-header
2 parents 4c8b905 + be745be commit 9a77e66

37 files changed

+94
-35
lines changed

.drone.yml

+2-2
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

cmd/serv.go

+4
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

custom/conf/app.example.ini

+5
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

+1
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/installation/with-docker-rootless.en-us.md

+2-2
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

+2-2
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

+2-2
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

+2-2
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/avatar.go

+1-1
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/

modules/private/hook.go

+31
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package private
66

77
import (
8+
"encoding/json"
89
"fmt"
910
"net/http"
1011
"net/url"
@@ -57,6 +58,12 @@ type HookOptions struct {
5758
IsDeployKey bool
5859
}
5960

61+
// SSHLogOption ssh log options
62+
type SSHLogOption struct {
63+
IsError bool
64+
Message string
65+
}
66+
6067
// HookPostReceiveResult represents an individual result from PostReceive
6168
type HookPostReceiveResult struct {
6269
Results []HookPostReceiveBranchResult
@@ -146,3 +153,27 @@ func SetDefaultBranch(ownerName, repoName, branch string) error {
146153
}
147154
return nil
148155
}
156+
157+
// SSHLog sends ssh error log response
158+
func SSHLog(isErr bool, msg string) error {
159+
reqURL := setting.LocalURL + "api/internal/ssh/log"
160+
req := newInternalRequest(reqURL, "POST")
161+
req = req.Header("Content-Type", "application/json")
162+
163+
jsonBytes, _ := json.Marshal(&SSHLogOption{
164+
IsError: isErr,
165+
Message: msg,
166+
})
167+
req.Body(jsonBytes)
168+
169+
req.SetTimeout(60*time.Second, 60*time.Second)
170+
resp, err := req.Response()
171+
if err != nil {
172+
return fmt.Errorf("unable to contact gitea: %v", err)
173+
}
174+
defer resp.Body.Close()
175+
if resp.StatusCode != http.StatusOK {
176+
return fmt.Errorf("Error returned from gitea: %v", decodeJSONError(resp).Err)
177+
}
178+
return nil
179+
}

modules/repository/commits_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ func TestPushCommits_AvatarLink(t *testing.T) {
112112
pushCommits.Len = len(pushCommits.Commits)
113113

114114
assert.Equal(t,
115-
"https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=56",
115+
"https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=112",
116116
pushCommits.AvatarLink("user2@example.com"))
117117

118118
assert.Equal(t,
119119
"https://secure.gravatar.com/avatar/"+
120120
fmt.Sprintf("%x", md5.Sum([]byte("nonexistent@example.com")))+
121-
"?d=identicon&s=56",
121+
"?d=identicon&s=112",
122122
pushCommits.AvatarLink("nonexistent@example.com"))
123123
}
124124

modules/setting/log.go

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ func newLogService() {
287287

288288
options := newDefaultLogOptions()
289289
options.bufferLength = Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000)
290+
EnableSSHLog = Cfg.Section("log").Key("ENABLE_SSH_LOG").MustBool(false)
290291

291292
description := LogDescription{
292293
Name: log.DEFAULT,

modules/setting/setting.go

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ var (
319319
DisableRouterLog bool
320320
RouterLogLevel log.Level
321321
EnableAccessLog bool
322+
EnableSSHLog bool
322323
AccessLogTemplate string
323324
EnableXORMLog bool
324325

options/locale/locale_cs-CZ.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,6 @@ auths.host=Server
22252225
auths.port=Port
22262226
auths.bind_dn=Připojení DN
22272227
auths.bind_password=Heslo připojení
2228-
auths.bind_password_helper=Upozornění: Toto heslo je ukládáno v nešifrované podobě. Použijte účet pouze pro čtení, pokud je to možné.
22292228
auths.user_base=Výchozí bod hledání uživatelů
22302229
auths.user_dn=DN uživatele
22312230
auths.attribute_username=Atribut uživatelského jména

options/locale/locale_de-DE.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,6 @@ auths.host=Host
22782278
auths.port=Port
22792279
auths.bind_dn=DN binden
22802280
auths.bind_password=Passwort binden
2281-
auths.bind_password_helper=Achtung: Das Passwort wird im Klartext gespeichert. Benutze, wenn möglich, einen Account, der nur über Lesezugriff verfügt.
22822281
auths.user_base=Basis für Benutzersuche
22832282
auths.user_dn=Benutzer-DN
22842283
auths.attribute_username=Benutzernamens-Attribut

options/locale/locale_es-ES.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,6 @@ auths.host=Servidor
22822282
auths.port=Puerto
22832283
auths.bind_dn=Bind DN
22842284
auths.bind_password=Contraseña Bind
2285-
auths.bind_password_helper=Advertencia: Esta contraseña se almacena en texto plano. Utilice una cuenta de sólo lectura si es posible.
22862285
auths.user_base=Base de búsqueda de usuarios
22872286
auths.user_dn=DN de Usuario
22882287
auths.attribute_username=Atributo nombre de usuario

options/locale/locale_fa-IR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,6 @@ auths.host=میزبان
18961896
auths.port=درگاه (پورت)
18971897
auths.bind_dn=DN متصل شده
18981898
auths.bind_password=اتصال گذرواژه
1899-
auths.bind_password_helper=هشدار: این گذرواژه به صورت متن خام ذخیره می شود. استفاده حساب های کاربری فقط-خواندنی امکان پذیر هست.
19001899
auths.user_base=پایگاه جستجوی کاربر
19011900
auths.user_dn=کاربر DN
19021901
auths.attribute_username=ویژگی نام کاربری

options/locale/locale_fr-FR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,6 @@ auths.host=Hôte
22222222
auths.port=Port
22232223
auths.bind_dn=Bind DN
22242224
auths.bind_password=Bind mot de passe
2225-
auths.bind_password_helper=Attention: ce mot de passe est stocké en clair. Veuillez utiliser, si possible, un compte avec des droits limités en lecture seule.
22262225
auths.user_base=Utilisateur Search Base
22272226
auths.user_dn=Utilisateur DN
22282227
auths.attribute_username=Attribut nom d'utilisateur

options/locale/locale_hu-HU.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,6 @@ auths.host=Kiszolgáló
14951495
auths.port=Port
14961496
auths.bind_dn=Bind DN
14971497
auths.bind_password=Bind Jelszó
1498-
auths.bind_password_helper=Figyelem: Ez a jelszó egyszerű szövegben van tárolva. Ha lehetséges használjon csak olvasható fiókot.
14991498
auths.user_base=Felhasználókeresés alapja (BaseDN)
15001499
auths.user_dn=Felhasználói DN
15011500
auths.attribute_username=Felhasználónév attribútum

options/locale/locale_it-IT.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,6 @@ auths.host=Host
20972097
auths.port=Porta
20982098
auths.bind_dn=Binda DN
20992099
auths.bind_password=Binda Password
2100-
auths.bind_password_helper=Attenzione: La password è memorizzata in testo normale. Se possibile, utilizzare un account di sola lettura.
21012100
auths.user_base=Base ricerca utente
21022101
auths.user_dn=DN dell'utente
21032102
auths.attribute_username=Attributo nome utente

options/locale/locale_ja-JP.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,6 @@ auths.host=ホスト
22822282
auths.port=ポート
22832283
auths.bind_dn=バインドDN
22842284
auths.bind_password=バインドパスワード
2285-
auths.bind_password_helper=警告: このパスワードはプレーンテキストで保存されます。 可能であれば読み取り専用アカウントを使用してください。
22862285
auths.user_base=ユーザー検索ベース
22872286
auths.user_dn=ユーザーDN
22882287
auths.attribute_username=ユーザー名

options/locale/locale_lv-LV.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,6 @@ auths.host=Resursdators
22482248
auths.port=Ports
22492249
auths.bind_dn=Saistīšanas DN
22502250
auths.bind_password=Saistīšanas parole
2251-
auths.bind_password_helper=Brīdinājums: Šī parole tiks glabāta nešifrētā veidā. Ieteicams izmantot kontu ar tikai lasīšanas tiesībām.
22522251
auths.user_base=Lietotāja pamatnosacījumi
22532252
auths.user_dn=Lietotāja DN
22542253
auths.attribute_username=Lietotājvārda atribūts

options/locale/locale_nl-NL.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,6 @@ auths.host=Host
21182118
auths.port=Poort
21192119
auths.bind_dn=Binden DN
21202120
auths.bind_password=Bind wachtwoord
2121-
auths.bind_password_helper=Waarschuwing: Dit wachtwoord wordt opgeslagen in platte tekst. Indien mogelijk gebruik dan een alleen-lezen account.
21222121
auths.user_base=User Search Base
21232122
auths.user_dn=User DN
21242123
auths.attribute_username=Gebruikersnaam attribuut

options/locale/locale_pl-PL.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,6 @@ auths.host=Serwer
20272027
auths.port=Port
20282028
auths.bind_dn=DN powiązania
20292029
auths.bind_password=Hasło Bind
2030-
auths.bind_password_helper=Uwaga: To hasło będzie przechowywane w czystym tekście. Użyj konta "tylko do odczytu", jeśli to możliwe.
20312030
auths.user_base=Baza wyszukiwania
20322031
auths.user_dn=DN użytkownika
20332032
auths.attribute_username=Atrybut nazwy użytkownika

options/locale/locale_pt-BR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,6 @@ auths.host=Servidor
20162016
auths.port=Porta
20172017
auths.bind_dn=Vincular DN
20182018
auths.bind_password=Vincular senha
2019-
auths.bind_password_helper=Atenção: Esta senha é armazenada em texto sem formatação. Se possível, use uma conta de somente leitura.
20202019
auths.user_base=Base de pesquisa do usuário
20212020
auths.user_dn=Usuário do DN
20222021
auths.attribute_username=Atributo nome de usuário

options/locale/locale_pt-PT.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,6 @@ auths.host=Servidor
22692269
auths.port=Porto
22702270
auths.bind_dn=Vincular DN
22712271
auths.bind_password=Vincular senha
2272-
auths.bind_password_helper=Atenção: Esta senha é armazenada em texto simples. Use uma conta só de leitura, se possível.
22732272
auths.user_base=Base de pesquisa de utilizador
22742273
auths.user_dn=DN do utilizador
22752274
auths.attribute_username=Atributo do nome de utilizador

options/locale/locale_ru-RU.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,6 @@ auths.host=Сервер
22502250
auths.port=Порт
22512251
auths.bind_dn=Bind DN
22522252
auths.bind_password=Привязать пароль
2253-
auths.bind_password_helper=Предупреждение: этот пароль хранится в виде простого текста. Используйте учетную запись только для чтения, если это возможно.
22542253
auths.user_base=База для поиска пользователя
22552254
auths.user_dn=DN пользователя
22562255
auths.attribute_username=Атрибут Username

options/locale/locale_sv-SE.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,6 @@ auths.host=Värd
19051905
auths.port=Port
19061906
auths.bind_dn=Bind DN
19071907
auths.bind_password=Bind Lösenord
1908-
auths.bind_password_helper=Varning: Detta lösenord lagras i klartext. Använd ett konto med endast läsrättigheter om möjligt.
19091908
auths.user_base=Användarsökbas
19101909
auths.user_dn=Användarnas DN
19111910
auths.attribute_username=Användarnamnsattribut

options/locale/locale_tr-TR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,6 @@ auths.host=Sunucu
22752275
auths.port=Bağlantı Noktası
22762276
auths.bind_dn=Bağlama DN'i
22772277
auths.bind_password=Bağlama Parolası
2278-
auths.bind_password_helper=Uyarı: Bu parola düz metin olarak saklanır. Mümkünse salt okunur bir hesap kullanın.
22792278
auths.user_base=Kullanıcı Arama Tabanı
22802279
auths.user_dn=Kullanıcı DN'i
22812280
auths.attribute_username=Kullanıcı Adı Özelliği

options/locale/locale_uk-UA.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,6 @@ auths.host=Хост
20352035
auths.port=Порт
20362036
auths.bind_dn=Прив'язати DN
20372037
auths.bind_password=Прив'язати пароль
2038-
auths.bind_password_helper=Попередження: цей пароль зберігається у вигляді простого тексту. Використовуйте обліковий запис тільки для читання, якщо це можливо.
20392038
auths.user_base=База пошуку користувачів
20402039
auths.user_dn=DN користувача
20412040
auths.attribute_username=Атрибут імені користувача

options/locale/locale_zh-CN.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,6 @@ auths.host=主机
22812281
auths.port=端口
22822282
auths.bind_dn=绑定 DN
22832283
auths.bind_password=绑定密码
2284-
auths.bind_password_helper=警告:密码将会被明文存储。如果可能请使用只读账号。
22852284
auths.user_base=用户搜索基准
22862285
auths.user_dn=用户 DN
22872286
auths.attribute_username=用户名属性

options/locale/locale_zh-TW.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,6 @@ auths.host=主機地址
22802280
auths.port=連接埠
22812281
auths.bind_dn=Bind DN
22822282
auths.bind_password=Bind 密碼
2283-
auths.bind_password_helper=警告:此密碼以明文存儲。 請儘可能使用唯讀帳戶。
22842283
auths.user_base=用戶搜尋基準
22852284
auths.user_dn=用戶 DN
22862285
auths.attribute_username=帳號屬性

routers/private/internal.go

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func Routes() *web.Route {
5555

5656
r.Post("/ssh/authorized_keys", AuthorizedPublicKeyByContent)
5757
r.Post("/ssh/{id}/update/{repoid}", UpdatePublicKeyInRepo)
58+
r.Post("/ssh/log", bind(private.SSHLogOption{}), SSHLog)
5859
r.Post("/hook/pre-receive/{owner}/{repo}", bind(private.HookOptions{}), HookPreReceive)
5960
r.Post("/hook/post-receive/{owner}/{repo}", bind(private.HookOptions{}), HookPostReceive)
6061
r.Post("/hook/set-default-branch/{owner}/{repo}/{branch}", SetDefaultBranch)

0 commit comments

Comments
 (0)