Skip to content

Commit

Permalink
Merge branch 'main' into feature/sort_issue_by_milestone_deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored May 22, 2021
2 parents 4960924 + be745be commit e33c531
Show file tree
Hide file tree
Showing 34 changed files with 91 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ services:
MYSQL_DATABASE: test

- name: mysql8
image: mysql:8.0
image: mysql:8
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: testgitea
Expand Down Expand Up @@ -319,7 +319,7 @@ trigger:
services:
- name: pgsql
pull: default
image: postgres:9.5
image: postgres:10
environment:
POSTGRES_DB: test
POSTGRES_PASSWORD: postgres
Expand Down
4 changes: 4 additions & 0 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func fail(userMessage, logMessage string, args ...interface{}) {
}
}

if len(logMessage) > 0 {
_ = private.SSHLog(true, fmt.Sprintf(logMessage+": ", args...))
}

os.Exit(1)
}

Expand Down
5 changes: 5 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,11 @@ ROUTER = console
;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}}"
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; SSH log (Creates log from ssh git request)
;;
;ENABLE_SSH_LOG = false
;;
;; Other Settings
;;
;; Print Stacktraces with logs. (Rarely helpful.) Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "None"
Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ Default templates for project boards:
- `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.)
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\]`.
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
- `ENABLE_SSH_LOG`: **false**: save ssh log to log file
- `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.)
- `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.
- The following variables are available:
Expand Down
4 changes: 2 additions & 2 deletions docs/content/doc/installation/with-docker-rootless.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ services:
+ - db
+
+ db:
+ image: mysql:5.7
+ image: mysql:8
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD=gitea
Expand Down Expand Up @@ -148,7 +148,7 @@ services:
+ - db
+
+ db:
+ image: postgres:9.6
+ image: postgres:13
+ restart: always
+ environment:
+ - POSTGRES_USER=gitea
Expand Down
4 changes: 2 additions & 2 deletions docs/content/doc/installation/with-docker.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ services:
+ - db
+
+ db:
+ image: mysql:5.7
+ image: mysql:8
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD=gitea
Expand Down Expand Up @@ -188,7 +188,7 @@ services:
+ - db
+
+ db:
+ image: postgres:9.6
+ image: postgres:13
+ restart: always
+ environment:
+ - POSTGRES_USER=gitea
Expand Down
4 changes: 2 additions & 2 deletions docs/content/doc/installation/with-docker.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ services:
+ - db
+
+ db:
+ image: mysql:5.7
+ image: mysql:8
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD=gitea
Expand Down Expand Up @@ -172,7 +172,7 @@ services:
+ - db
+
+ db:
+ image: postgres:9.6
+ image: postgres:13
+ restart: always
+ environment:
+ - POSTGRES_USER=gitea
Expand Down
4 changes: 2 additions & 2 deletions integrations/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ make test-sqlite
## 如何使用 mysql 数据库进行集成测试
首先在docker容器里部署一个 mysql 数据库
```
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)
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)
```
之后便可以基于这个数据库进行集成测试
```
Expand All @@ -36,7 +36,7 @@ TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root T
## 如何使用 pgsql 数据库进行集成测试
同上,首先在 docker 容器里部署一个 pgsql 数据库
```
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)
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:13 #(just ctrl-c to stop db and clean the container)
```
之后便可以基于这个数据库进行集成测试
```
Expand Down
2 changes: 1 addition & 1 deletion models/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const DefaultAvatarSize = -1
const DefaultAvatarPixelSize = 28

// AvatarRenderedSizeFactor is the factor by which the default size is increased for finer rendering
const AvatarRenderedSizeFactor = 2
const AvatarRenderedSizeFactor = 4

// HashEmail hashes email address to MD5 string.
// https://en.gravatar.com/site/implement/hash/
Expand Down
31 changes: 31 additions & 0 deletions modules/private/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package private

import (
"encoding/json"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -57,6 +58,12 @@ type HookOptions struct {
IsDeployKey bool
}

// SSHLogOption ssh log options
type SSHLogOption struct {
IsError bool
Message string
}

// HookPostReceiveResult represents an individual result from PostReceive
type HookPostReceiveResult struct {
Results []HookPostReceiveBranchResult
Expand Down Expand Up @@ -146,3 +153,27 @@ func SetDefaultBranch(ownerName, repoName, branch string) error {
}
return nil
}

// SSHLog sends ssh error log response
func SSHLog(isErr bool, msg string) error {
reqURL := setting.LocalURL + "api/internal/ssh/log"
req := newInternalRequest(reqURL, "POST")
req = req.Header("Content-Type", "application/json")

jsonBytes, _ := json.Marshal(&SSHLogOption{
IsError: isErr,
Message: msg,
})
req.Body(jsonBytes)

req.SetTimeout(60*time.Second, 60*time.Second)
resp, err := req.Response()
if err != nil {
return fmt.Errorf("unable to contact gitea: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Error returned from gitea: %v", decodeJSONError(resp).Err)
}
return nil
}
4 changes: 2 additions & 2 deletions modules/repository/commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ func TestPushCommits_AvatarLink(t *testing.T) {
pushCommits.Len = len(pushCommits.Commits)

assert.Equal(t,
"https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=56",
"https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=112",
pushCommits.AvatarLink("[email protected]"))

assert.Equal(t,
"https://secure.gravatar.com/avatar/"+
fmt.Sprintf("%x", md5.Sum([]byte("[email protected]")))+
"?d=identicon&s=56",
"?d=identicon&s=112",
pushCommits.AvatarLink("[email protected]"))
}

Expand Down
1 change: 1 addition & 0 deletions modules/setting/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func newLogService() {

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

description := LogDescription{
Name: log.DEFAULT,
Expand Down
1 change: 1 addition & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ var (
DisableRouterLog bool
RouterLogLevel log.Level
EnableAccessLog bool
EnableSSHLog bool
AccessLogTemplate string
EnableXORMLog bool

Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_cs-CZ.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,6 @@ auths.host=Server
auths.port=Port
auths.bind_dn=Připojení DN
auths.bind_password=Heslo připojení
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é.
auths.user_base=Výchozí bod hledání uživatelů
auths.user_dn=DN uživatele
auths.attribute_username=Atribut uživatelského jména
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_de-DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,6 @@ auths.host=Host
auths.port=Port
auths.bind_dn=DN binden
auths.bind_password=Passwort binden
auths.bind_password_helper=Achtung: Das Passwort wird im Klartext gespeichert. Benutze, wenn möglich, einen Account, der nur über Lesezugriff verfügt.
auths.user_base=Basis für Benutzersuche
auths.user_dn=Benutzer-DN
auths.attribute_username=Benutzernamens-Attribut
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_es-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,6 @@ auths.host=Servidor
auths.port=Puerto
auths.bind_dn=Bind DN
auths.bind_password=Contraseña Bind
auths.bind_password_helper=Advertencia: Esta contraseña se almacena en texto plano. Utilice una cuenta de sólo lectura si es posible.
auths.user_base=Base de búsqueda de usuarios
auths.user_dn=DN de Usuario
auths.attribute_username=Atributo nombre de usuario
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_fa-IR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,6 @@ auths.host=میزبان
auths.port=درگاه (پورت)
auths.bind_dn=DN متصل شده
auths.bind_password=اتصال گذرواژه
auths.bind_password_helper=هشدار: این گذرواژه به صورت متن خام ذخیره می شود. استفاده حساب های کاربری فقط-خواندنی امکان پذیر هست.
auths.user_base=پایگاه جستجوی کاربر
auths.user_dn=کاربر DN
auths.attribute_username=ویژگی نام کاربری
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,6 @@ auths.host=Hôte
auths.port=Port
auths.bind_dn=Bind DN
auths.bind_password=Bind mot de passe
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.
auths.user_base=Utilisateur Search Base
auths.user_dn=Utilisateur DN
auths.attribute_username=Attribut nom d'utilisateur
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_hu-HU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@ auths.host=Kiszolgáló
auths.port=Port
auths.bind_dn=Bind DN
auths.bind_password=Bind Jelszó
auths.bind_password_helper=Figyelem: Ez a jelszó egyszerű szövegben van tárolva. Ha lehetséges használjon csak olvasható fiókot.
auths.user_base=Felhasználókeresés alapja (BaseDN)
auths.user_dn=Felhasználói DN
auths.attribute_username=Felhasználónév attribútum
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_it-IT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,6 @@ auths.host=Host
auths.port=Porta
auths.bind_dn=Binda DN
auths.bind_password=Binda Password
auths.bind_password_helper=Attenzione: La password è memorizzata in testo normale. Se possibile, utilizzare un account di sola lettura.
auths.user_base=Base ricerca utente
auths.user_dn=DN dell'utente
auths.attribute_username=Attributo nome utente
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,6 @@ auths.host=ホスト
auths.port=ポート
auths.bind_dn=バインドDN
auths.bind_password=バインドパスワード
auths.bind_password_helper=警告: このパスワードはプレーンテキストで保存されます。 可能であれば読み取り専用アカウントを使用してください。
auths.user_base=ユーザー検索ベース
auths.user_dn=ユーザーDN
auths.attribute_username=ユーザー名
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_lv-LV.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,6 @@ auths.host=Resursdators
auths.port=Ports
auths.bind_dn=Saistīšanas DN
auths.bind_password=Saistīšanas parole
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.
auths.user_base=Lietotāja pamatnosacījumi
auths.user_dn=Lietotāja DN
auths.attribute_username=Lietotājvārda atribūts
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_nl-NL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,6 @@ auths.host=Host
auths.port=Poort
auths.bind_dn=Binden DN
auths.bind_password=Bind wachtwoord
auths.bind_password_helper=Waarschuwing: Dit wachtwoord wordt opgeslagen in platte tekst. Indien mogelijk gebruik dan een alleen-lezen account.
auths.user_base=User Search Base
auths.user_dn=User DN
auths.attribute_username=Gebruikersnaam attribuut
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_pl-PL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,6 @@ auths.host=Serwer
auths.port=Port
auths.bind_dn=DN powiązania
auths.bind_password=Hasło Bind
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.
auths.user_base=Baza wyszukiwania
auths.user_dn=DN użytkownika
auths.attribute_username=Atrybut nazwy użytkownika
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_pt-BR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,6 @@ auths.host=Servidor
auths.port=Porta
auths.bind_dn=Vincular DN
auths.bind_password=Vincular senha
auths.bind_password_helper=Atenção: Esta senha é armazenada em texto sem formatação. Se possível, use uma conta de somente leitura.
auths.user_base=Base de pesquisa do usuário
auths.user_dn=Usuário do DN
auths.attribute_username=Atributo nome de usuário
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,6 @@ auths.host=Servidor
auths.port=Porto
auths.bind_dn=Vincular DN
auths.bind_password=Vincular senha
auths.bind_password_helper=Atenção: Esta senha é armazenada em texto simples. Use uma conta só de leitura, se possível.
auths.user_base=Base de pesquisa de utilizador
auths.user_dn=DN do utilizador
auths.attribute_username=Atributo do nome de utilizador
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_ru-RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,6 @@ auths.host=Сервер
auths.port=Порт
auths.bind_dn=Bind DN
auths.bind_password=Привязать пароль
auths.bind_password_helper=Предупреждение: этот пароль хранится в виде простого текста. Используйте учетную запись только для чтения, если это возможно.
auths.user_base=База для поиска пользователя
auths.user_dn=DN пользователя
auths.attribute_username=Атрибут Username
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_sv-SE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,6 @@ auths.host=Värd
auths.port=Port
auths.bind_dn=Bind DN
auths.bind_password=Bind Lösenord
auths.bind_password_helper=Varning: Detta lösenord lagras i klartext. Använd ett konto med endast läsrättigheter om möjligt.
auths.user_base=Användarsökbas
auths.user_dn=Användarnas DN
auths.attribute_username=Användarnamnsattribut
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_tr-TR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,6 @@ auths.host=Sunucu
auths.port=Bağlantı Noktası
auths.bind_dn=Bağlama DN'i
auths.bind_password=Bağlama Parolası
auths.bind_password_helper=Uyarı: Bu parola düz metin olarak saklanır. Mümkünse salt okunur bir hesap kullanın.
auths.user_base=Kullanıcı Arama Tabanı
auths.user_dn=Kullanıcı DN'i
auths.attribute_username=Kullanıcı Adı Özelliği
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_uk-UA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,6 @@ auths.host=Хост
auths.port=Порт
auths.bind_dn=Прив'язати DN
auths.bind_password=Прив'язати пароль
auths.bind_password_helper=Попередження: цей пароль зберігається у вигляді простого тексту. Використовуйте обліковий запис тільки для читання, якщо це можливо.
auths.user_base=База пошуку користувачів
auths.user_dn=DN користувача
auths.attribute_username=Атрибут імені користувача
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,6 @@ auths.host=主机
auths.port=端口
auths.bind_dn=绑定 DN
auths.bind_password=绑定密码
auths.bind_password_helper=警告:密码将会被明文存储。如果可能请使用只读账号。
auths.user_base=用户搜索基准
auths.user_dn=用户 DN
auths.attribute_username=用户名属性
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2280,7 +2280,6 @@ auths.host=主機地址
auths.port=連接埠
auths.bind_dn=Bind DN
auths.bind_password=Bind 密碼
auths.bind_password_helper=警告:此密碼以明文存儲。 請儘可能使用唯讀帳戶。
auths.user_base=用戶搜尋基準
auths.user_dn=用戶 DN
auths.attribute_username=帳號屬性
Expand Down
1 change: 1 addition & 0 deletions routers/private/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func Routes() *web.Route {

r.Post("/ssh/authorized_keys", AuthorizedPublicKeyByContent)
r.Post("/ssh/{id}/update/{repoid}", UpdatePublicKeyInRepo)
r.Post("/ssh/log", bind(private.SSHLogOption{}), SSHLog)
r.Post("/hook/pre-receive/{owner}/{repo}", bind(private.HookOptions{}), HookPreReceive)
r.Post("/hook/post-receive/{owner}/{repo}", bind(private.HookOptions{}), HookPostReceive)
r.Post("/hook/set-default-branch/{owner}/{repo}/{branch}", SetDefaultBranch)
Expand Down
Loading

0 comments on commit e33c531

Please sign in to comment.