Skip to content

Commit a2dbf1f

Browse files
authored
Merge branch 'main' into speed-up-testpatch
2 parents ffe6a4d + 17be645 commit a2dbf1f

36 files changed

+349
-297
lines changed

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

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:password@gitea.your.host/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:yourpassword@gitea.your.host/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:yourpassword@gitea.your.host/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:yourpassword@gitea.your.host/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

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/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")

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ settings.email_notifications.disable = Disable Email Notifications
15501550
settings.email_notifications.submit = Set Email Preference
15511551
settings.site = Website
15521552
settings.update_settings = Update Settings
1553+
settings.branches.update_default_branch = Update Default Branch
15531554
settings.advanced_settings = Advanced Settings
15541555
settings.wiki_desc = Enable Repository Wiki
15551556
settings.use_internal_wiki = Use Built-In Wiki
@@ -2282,7 +2283,6 @@ auths.host = Host
22822283
auths.port = Port
22832284
auths.bind_dn = Bind DN
22842285
auths.bind_password = Bind Password
2285-
auths.bind_password_helper = Warning: This password is stored in plain text. Use a read-only account if possible.
22862286
auths.user_base = User Search Base
22872287
auths.user_dn = User DN
22882288
auths.attribute_username = Username Attribute

options/locale/locale_es-ES.ini

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ branch=Rama
854854
tree=Árbol
855855
clear_ref=`Borrar referencia actual`
856856
filter_branch_and_tag=Filtrar por rama o etiqueta
857+
find_tag=Buscar etiqueta
857858
branches=Ramas
858859
tags=Etiquetas
859860
issues=Incidencias
@@ -1158,7 +1159,7 @@ issues.label_color=Color etiqueta
11581159
issues.label_count=%d etiquetas
11591160
issues.label_open_issues=%d incidencias abiertas
11601161
issues.label_edit=Editar
1161-
issues.label_delete=Borrar
1162+
issues.label_delete=Eliminar
11621163
issues.label_modify=Editar etiqueta
11631164
issues.label_deletion=Eliminar etiqueta
11641165
issues.label_deletion_desc=Eliminar una etiqueta la elimina de todos las incidencias. ¿Continuar?
@@ -1284,6 +1285,8 @@ issues.review.resolved_by=ha marcado esta conversación como resuelta
12841285
issues.assignee.error=No todos los asignados fueron añadidos debido a un error inesperado.
12851286
issues.reference_issue.body=Cuerpo
12861287

1288+
compare.compare_base=base
1289+
compare.compare_head=comparar
12871290

12881291
pulls.desc=Activar Pull Requests y revisiones de código.
12891292
pulls.new=Nuevo Pull Request
@@ -1546,6 +1549,7 @@ settings.email_notifications.disable=Deshabilitar las notificaciones por correo
15461549
settings.email_notifications.submit=Establecer Preferencia de correo electrónico
15471550
settings.site=Sitio web
15481551
settings.update_settings=Actualizar configuración
1552+
settings.branches.update_default_branch=Actualizar rama por defecto
15491553
settings.advanced_settings=Ajustes avanzados
15501554
settings.wiki_desc=Activar Wiki de repositorio
15511555
settings.use_internal_wiki=Usar Wiki integrada
@@ -1886,6 +1890,7 @@ diff.file_image_width=Anchura
18861890
diff.file_image_height=Altura
18871891
diff.file_byte_size=Tamaño
18881892
diff.file_suppressed=La diferencia del archivo ha sido suprimido porque es demasiado grande
1893+
diff.file_suppressed_line_too_long=Las diferiencias del archivo han sido suprimidas porque una o mas lineas son muy largas
18891894
diff.too_many_files=Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio
18901895
diff.comment.placeholder=Deja un comentario
18911896
diff.comment.markdown_info=Es posible estilizar con markdown.
@@ -1913,6 +1918,7 @@ release.new_release=Nueva Release
19131918
release.draft=Borrador
19141919
release.prerelease=Pre-lanzamiento
19151920
release.stable=Estable
1921+
release.compare=Comparar
19161922
release.edit=editar
19171923
release.ahead.commits=<strong>%d</strong> commits
19181924
release.ahead.target=a %s desde esta versión
@@ -2130,7 +2136,7 @@ dashboard.cron.error=Error en Cron: %s: %[3]s
21302136
dashboard.cron.finished=Cron: %[1]s ha finalizado
21312137
dashboard.delete_inactive_accounts=Eliminar todas las cuentas inactivas
21322138
dashboard.delete_inactive_accounts.started=Se ha iniciado la tarea: "Eliminar todas las cuentas inactivas".
2133-
dashboard.delete_repo_archives=Borrar todos los archivos del repositorio (ZIP, TAR.GZ, etc.)
2139+
dashboard.delete_repo_archives=Eliminar todos los archivos del repositorio (ZIP, TAR.GZ, etc.)
21342140
dashboard.delete_repo_archives.started=Se ha iniciado la tarea: "Eliminar todos los archivos del repositorios".
21352141
dashboard.delete_missing_repos=Eliminar todos los repositorios que faltan sus archivos Git
21362142
dashboard.delete_missing_repos.started=Se ha iniciado la tarea: "Eliminar todos los repositorios que faltan sus archivos Git".
@@ -2179,6 +2185,8 @@ dashboard.total_gc_time=Pausa Total por GC
21792185
dashboard.total_gc_pause=Pausa Total por GC
21802186
dashboard.last_gc_pause=Última Pausa por GC
21812187
dashboard.gc_times=Ejecuciones GC
2188+
dashboard.delete_old_actions=Eliminar todas las acciones antiguas de la base de datos
2189+
dashboard.delete_old_actions.started=Eliminar todas las acciones antiguas de la base de datos inicializada.
21822190

21832191
users.user_manage_panel=Gestión de cuentas de usuario
21842192
users.new_account=Crear Cuenta de Usuario
@@ -2305,6 +2313,7 @@ auths.allowed_domains_helper=Dejar vacío para permitir todos los dominios. Sepa
23052313
auths.enable_tls=Habilitar cifrado TLS
23062314
auths.skip_tls_verify=Omitir la verificación TLS
23072315
auths.pam_service_name=Nombre del Servicio PAM
2316+
auths.pam_email_domain=Dominio de correo de PAM (opcional)
23082317
auths.oauth2_provider=Proveedor OAuth2
23092318
auths.oauth2_icon_url=URL de icono
23102319
auths.oauth2_clientID=ID de cliente (clave)
@@ -2404,6 +2413,7 @@ config.db_path=Ruta
24042413
config.service_config=Configuración del servicio
24052414
config.register_email_confirm=Requerir confirmación de correo electrónico para registrarse
24062415
config.disable_register=Deshabilitar auto-registro
2416+
config.allow_only_internal_registration=Permitir el registro solo desde Gitea
24072417
config.allow_only_external_registration=Permitir el registro únicamente a través de servicios externos
24082418
config.enable_openid_signup=Habilitar el auto-registro con OpenID
24092419
config.enable_openid_signin=Habilitar el inicio de sesión con OpenID

options/locale/locale_ja-JP.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,8 @@ issues.review.resolved_by=がこの会話を解決済みにしました
12851285
issues.assignee.error=予期しないエラーにより、一部の担当者を追加できませんでした。
12861286
issues.reference_issue.body=内容
12871287

1288+
compare.compare_base=基準
1289+
compare.compare_head=比較
12881290

12891291
pulls.desc=プルリクエストとコードレビューの有効化。
12901292
pulls.new=新しいプルリクエスト
@@ -1547,6 +1549,7 @@ settings.email_notifications.disable=メール通知無効
15471549
settings.email_notifications.submit=メール設定を保存
15481550
settings.site=Webサイト
15491551
settings.update_settings=設定を更新
1552+
settings.branches.update_default_branch=デフォルトブランチを更新
15501553
settings.advanced_settings=拡張設定
15511554
settings.wiki_desc=Wikiを有効にする
15521555
settings.use_internal_wiki=ビルトインのWikiを使用する
@@ -1887,6 +1890,7 @@ diff.file_image_width=幅
18871890
diff.file_image_height=高さ
18881891
diff.file_byte_size=サイズ
18891892
diff.file_suppressed=ファイル差分が大きすぎるため省略します
1893+
diff.file_suppressed_line_too_long=長すぎる行があるためファイル差分は表示されません
18901894
diff.too_many_files=変更されたファイルが多すぎるため、一部のファイルは表示されません
18911895
diff.comment.placeholder=コメントを残す
18921896
diff.comment.markdown_info=Markdownによる書式設定をサポートしています。
@@ -2309,6 +2313,7 @@ auths.allowed_domains_helper=すべてのドメインを許可する場合は空
23092313
auths.enable_tls=TLS暗号化を有効にする
23102314
auths.skip_tls_verify=TLS検証を省略
23112315
auths.pam_service_name=PAMサービス名
2316+
auths.pam_email_domain=PAM メールドメイン名 (オプション)
23122317
auths.oauth2_provider=OAuth2プロバイダー
23132318
auths.oauth2_icon_url=アイコンのURL
23142319
auths.oauth2_clientID=クライアントID (キー)
@@ -2408,6 +2413,7 @@ config.db_path=パス
24082413
config.service_config=サービス設定
24092414
config.register_email_confirm=登録にはメールによる確認が必要
24102415
config.disable_register=セルフ登録無効
2416+
config.allow_only_internal_registration=Gitea上での登録のみを許可
24112417
config.allow_only_external_registration=外部サービスを使用した登録のみを許可
24122418
config.enable_openid_signup=OpenIDを使ったセルフ登録有効
24132419
config.enable_openid_signin=OpenIDを使ったサインイン有効

0 commit comments

Comments
 (0)