Skip to content

Commit 3021d3a

Browse files
committed
Merge remote-tracking branch 'origin/main' into migration-credentials
2 parents c076113 + 1da0d15 commit 3021d3a

File tree

19 files changed

+213
-162
lines changed

19 files changed

+213
-162
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:[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.

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)

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 & 0 deletions
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

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)