Skip to content

Commit cc3a227

Browse files
authored
Merge branch 'main' into ref-issue-template
2 parents 3d7b309 + a6d4a85 commit cc3a227

File tree

529 files changed

+7991
-6289
lines changed

Some content is hidden

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

529 files changed

+7991
-6289
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ steps:
537537

538538
- name: static
539539
pull: always
540-
image: techknowlogick/xgo:go-1.16.x
540+
image: techknowlogick/xgo:go-1.17.x
541541
commands:
542542
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
543543
- export PATH=$PATH:$GOPATH/bin
@@ -633,7 +633,7 @@ steps:
633633

634634
- name: static
635635
pull: always
636-
image: techknowlogick/xgo:go-1.16.x
636+
image: techknowlogick/xgo:go-1.17.x
637637
commands:
638638
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
639639
- export PATH=$PATH:$GOPATH/bin

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/.eslintrc linguist-language=YAML
66
/.stylelintrc linguist-language=YAML
77
/web_src/fomantic/build/** linguist-generated
8+
Dockerfile.* linguist-language=Dockerfile

cmd/admin.go

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"text/tabwriter"
1515

1616
"code.gitea.io/gitea/models"
17+
asymkey_model "code.gitea.io/gitea/models/asymkey"
1718
"code.gitea.io/gitea/models/db"
1819
"code.gitea.io/gitea/models/login"
1920
user_model "code.gitea.io/gitea/models/user"
@@ -298,6 +299,36 @@ var (
298299
Name: "skip-local-2fa",
299300
Usage: "Set to true to skip local 2fa for users authenticated by this source",
300301
},
302+
cli.StringSliceFlag{
303+
Name: "scopes",
304+
Value: nil,
305+
Usage: "Scopes to request when to authenticate against this OAuth2 source",
306+
},
307+
cli.StringFlag{
308+
Name: "required-claim-name",
309+
Value: "",
310+
Usage: "Claim name that has to be set to allow users to login with this source",
311+
},
312+
cli.StringFlag{
313+
Name: "required-claim-value",
314+
Value: "",
315+
Usage: "Claim value that has to be set to allow users to login with this source",
316+
},
317+
cli.StringFlag{
318+
Name: "group-claim-name",
319+
Value: "",
320+
Usage: "Claim name providing group names for this source",
321+
},
322+
cli.StringFlag{
323+
Name: "admin-group",
324+
Value: "",
325+
Usage: "Group Claim value for administrator users",
326+
},
327+
cli.StringFlag{
328+
Name: "restricted-group",
329+
Value: "",
330+
Usage: "Group Claim value for restricted users",
331+
},
301332
}
302333

303334
microcmdAuthUpdateOauth = cli.Command{
@@ -348,6 +379,10 @@ func runChangePassword(c *cli.Context) error {
348379
if err := initDB(ctx); err != nil {
349380
return err
350381
}
382+
if len(c.String("password")) < setting.MinPasswordLength {
383+
return fmt.Errorf("Password is not long enough. Needs to be at least %d", setting.MinPasswordLength)
384+
}
385+
351386
if !pwd.IsComplexEnough(c.String("password")) {
352387
return errors.New("Password does not meet complexity requirements")
353388
}
@@ -625,7 +660,7 @@ func runRegenerateKeys(_ *cli.Context) error {
625660
if err := initDB(ctx); err != nil {
626661
return err
627662
}
628-
return models.RewriteAllPublicKeys()
663+
return asymkey_model.RewriteAllPublicKeys()
629664
}
630665

631666
func parseOAuth2Config(c *cli.Context) *oauth2.Source {
@@ -648,6 +683,12 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
648683
CustomURLMapping: customURLMapping,
649684
IconURL: c.String("icon-url"),
650685
SkipLocalTwoFA: c.Bool("skip-local-2fa"),
686+
Scopes: c.StringSlice("scopes"),
687+
RequiredClaimName: c.String("required-claim-name"),
688+
RequiredClaimValue: c.String("required-claim-value"),
689+
GroupClaimName: c.String("group-claim-name"),
690+
AdminGroup: c.String("admin-group"),
691+
RestrictedGroup: c.String("restricted-group"),
651692
}
652693
}
653694

@@ -710,6 +751,28 @@ func runUpdateOauth(c *cli.Context) error {
710751
oAuth2Config.IconURL = c.String("icon-url")
711752
}
712753

754+
if c.IsSet("scopes") {
755+
oAuth2Config.Scopes = c.StringSlice("scopes")
756+
}
757+
758+
if c.IsSet("required-claim-name") {
759+
oAuth2Config.RequiredClaimName = c.String("required-claim-name")
760+
761+
}
762+
if c.IsSet("required-claim-value") {
763+
oAuth2Config.RequiredClaimValue = c.String("required-claim-value")
764+
}
765+
766+
if c.IsSet("group-claim-name") {
767+
oAuth2Config.GroupClaimName = c.String("group-claim-name")
768+
}
769+
if c.IsSet("admin-group") {
770+
oAuth2Config.AdminGroup = c.String("admin-group")
771+
}
772+
if c.IsSet("restricted-group") {
773+
oAuth2Config.RestrictedGroup = c.String("restricted-group")
774+
}
775+
713776
// update custom URL mapping
714777
var customURLMapping = &oauth2.CustomURLMapping{}
715778

cmd/migrate_storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func migrateAvatars(dstStorage storage.ObjectStorage) error {
102102
}
103103

104104
func migrateRepoAvatars(dstStorage storage.ObjectStorage) error {
105-
return models.IterateRepository(func(repo *models.Repository) error {
105+
return repo_model.IterateRepository(func(repo *repo_model.Repository) error {
106106
_, err := storage.Copy(dstStorage, repo.CustomAvatarRelativePath(), storage.RepoAvatars, repo.CustomAvatarRelativePath())
107107
return err
108108
})

cmd/serv.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"time"
1818

1919
"code.gitea.io/gitea/models"
20+
asymkey_model "code.gitea.io/gitea/models/asymkey"
2021
"code.gitea.io/gitea/models/perm"
2122
"code.gitea.io/gitea/modules/git"
2223
"code.gitea.io/gitea/modules/json"
@@ -129,9 +130,9 @@ func runServ(c *cli.Context) error {
129130
return fail("Internal error", "Failed to check provided key: %v", err)
130131
}
131132
switch key.Type {
132-
case models.KeyTypeDeploy:
133+
case asymkey_model.KeyTypeDeploy:
133134
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
134-
case models.KeyTypePrincipal:
135+
case asymkey_model.KeyTypePrincipal:
135136
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Gitea does not provide shell access.")
136137
default:
137138
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")

cmd/web.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func setPort(port string) error {
180180
setting.HTTPPort = port
181181

182182
switch setting.Protocol {
183-
case setting.UnixSocket:
183+
case setting.HTTPUnix:
184184
case setting.FCGI:
185185
case setting.FCGIUnix:
186186
default:
@@ -202,7 +202,7 @@ func setPort(port string) error {
202202

203203
func listen(m http.Handler, handleRedirector bool) error {
204204
listenAddr := setting.HTTPAddr
205-
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
205+
if setting.Protocol != setting.HTTPUnix && setting.Protocol != setting.FCGIUnix {
206206
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)
207207
}
208208
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
@@ -240,7 +240,7 @@ func listen(m http.Handler, handleRedirector bool) error {
240240
NoHTTPRedirector()
241241
}
242242
err = runFCGI("tcp", listenAddr, "FCGI Web", m)
243-
case setting.UnixSocket:
243+
case setting.HTTPUnix:
244244
if handleRedirector {
245245
NoHTTPRedirector()
246246
}

custom/conf/app.example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,10 @@ PATH =
15871587
;AVATAR_MAX_WIDTH = 4096
15881588
;AVATAR_MAX_HEIGHT = 3072
15891589
;;
1590+
;; The multiplication factor for rendered avatar images.
1591+
;; Larger values result in finer rendering on HiDPI devices.
1592+
;AVATAR_RENDERED_SIZE_FACTOR = 3
1593+
;;
15901594
;; Maximum allowed file size for uploaded avatars.
15911595
;; This is to limit the amount of RAM used when resizing the image.
15921596
;AVATAR_MAX_FILE_SIZE = 1048576

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
233233

234234
## Server (`server`)
235235

236-
- `PROTOCOL`: **http**: \[http, https, fcgi, unix, fcgi+unix\]
236+
- `PROTOCOL`: **http**: \[http, https, fcgi, http+unix, fcgi+unix\]
237237
- `DOMAIN`: **localhost**: Domain name of this server.
238238
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
239239
Overwrite the automatically generated public URL.
@@ -248,7 +248,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
248248
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
249249
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
250250
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
251-
- If `PROTOCOL` is set to `unix` or `fcgi+unix`, this should be the name of the Unix socket file to use. Relative paths will be made absolute against the AppWorkPath.
251+
- If `PROTOCOL` is set to `http+unix` or `fcgi+unix`, this should be the name of the Unix socket file to use. Relative paths will be made absolute against the AppWorkPath.
252252
- `HTTP_PORT`: **3000**: HTTP listen port.
253253
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
254254
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
@@ -257,7 +257,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
257257
(DMZ) URL for Gitea workers (such as SSH update) accessing web service. In
258258
most cases you do not need to change the default value. Alter it only if
259259
your SSH server node is not the same as HTTP node. Do not set this variable
260-
if `PROTOCOL` is set to `unix`.
260+
if `PROTOCOL` is set to `http+unix`.
261261
- `PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the connection. (Set to 0 to
262262
disable all timeouts.)
263263
- `PER_WRITE_PER_KB_TIMEOUT`: **10s**: Timeout per Kb written to connections.
@@ -277,7 +277,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
277277
- `SSH_AUTHORIZED_PRINCIPALS_ALLOW`: **off** or **username, email**: \[off, username, email, anything\]: Specify the principals values that users are allowed to use as principal. When set to `anything` no checks are done on the principal string. When set to `off` authorized principal are not allowed to be set.
278278
- `SSH_CREATE_AUTHORIZED_PRINCIPALS_FILE`: **false/true**: Gitea will create a authorized_principals file by default when it is not using the internal ssh server and `SSH_AUTHORIZED_PRINCIPALS_ALLOW` is not `off`.
279279
- `SSH_AUTHORIZED_PRINCIPALS_BACKUP`: **false/true**: Enable SSH Authorized Principals Backup when rewriting all keys, default is true if `SSH_AUTHORIZED_PRINCIPALS_ALLOW` is not `off`.
280-
- `SSH_AUTHORIZED_KEYS_COMMAND_TEMPLATE`: **{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}**: Set the template for the command to passed on authorized keys. Possible keys are: AppPath, AppWorkPath, CustomConf, CustomPath, Key - where Key is a `models.PublicKey` and the others are strings which are shellquoted.
280+
- `SSH_AUTHORIZED_KEYS_COMMAND_TEMPLATE`: **{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}**: Set the template for the command to passed on authorized keys. Possible keys are: AppPath, AppWorkPath, CustomConf, CustomPath, Key - where Key is a `models/asymkey.PublicKey` and the others are strings which are shellquoted.
281281
- `SSH_SERVER_CIPHERS`: **aes128-ctr, aes192-ctr, aes256-ctr, [email protected], arcfour256, arcfour128**: For the built-in SSH server, choose the ciphers to support for SSH connections, for system SSH this setting has no effect.
282282
- `SSH_SERVER_KEY_EXCHANGES`: **diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, [email protected]**: For the built-in SSH server, choose the key exchange algorithms to support for SSH connections, for system SSH this setting has no effect.
283283
- `SSH_SERVER_MACS`: **[email protected], hmac-sha2-256, hmac-sha1, hmac-sha1-96**: For the built-in SSH server, choose the MACs to support for SSH connections, for system SSH this setting has no effect
@@ -710,6 +710,7 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type
710710
- `AVATAR_MAX_WIDTH`: **4096**: Maximum avatar image width in pixels.
711711
- `AVATAR_MAX_HEIGHT`: **3072**: Maximum avatar image height in pixels.
712712
- `AVATAR_MAX_FILE_SIZE`: **1048576** (1Mb): Maximum avatar image file size in bytes.
713+
- `AVATAR_RENDERED_SIZE_FACTOR`: **3**: The multiplication factor for rendered avatar images. Larger values result in finer rendering on HiDPI devices.
713714

714715
- `REPOSITORY_AVATAR_STORAGE_TYPE`: **default**: Storage type defined in `[storage.xxx]`. Default is `default` which will read `[storage]` if no section `[storage]` will be a type `local`.
715716
- `REPOSITORY_AVATAR_UPLOAD_PATH`: **data/repo-avatars**: Path to store repository avatar image files.

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ menu:
8484

8585
## Database (`database`)
8686

87-
- `DB_TYPE`: 数据库类型,可选 `mysql`, `postgres`, `mssql`, `tidb``sqlite3`
87+
- `DB_TYPE`: 数据库类型,可选 `mysql`, `postgres`, `mssql``sqlite3`
8888
- `HOST`: 数据库服务器地址和端口。
8989
- `NAME`: 数据库名称。
9090
- `USER`: 数据库用户名。
9191
- `PASSWD`: 数据库用户密码。
9292
- `SSL_MODE`: MySQL 或 PostgreSQL数据库是否启用SSL模式。
9393
- `CHARSET`: **utf8mb4**: 仅当数据库为 MySQL 时有效, 可以为 "utf8" 或 "utf8mb4"。注意:如果使用 "utf8mb4",你的 MySQL InnoDB 版本必须在 5.6 以上。
94-
- `PATH`: Tidb 或者 SQLite3 数据文件存放路径。
94+
- `PATH`: SQLite3 数据文件存放路径。
9595
- `LOG_SQL`: **true**: 显示生成的SQL,默认为真。
9696
- `MAX_IDLE_CONNS` **0**: 最大空闲数据库连接
9797
- `CONN_MAX_LIFETIME` **3s**: 数据库连接最大存活时间

docs/content/doc/usage/command-line.en-us.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ Admin operations:
129129
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
130130
- `--custom-email-url`: Use a custom Email URL (option for GitHub).
131131
- `--icon-url`: Custom icon URL for OAuth2 login source.
132+
- `--override-local-2fa`: Allow source to override local 2fa. (Optional)
133+
- `--scopes`: Addtional scopes to request for this OAuth2 source. (Optional)
134+
- `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional)
135+
- `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional)
136+
- `--group-claim-name`: Claim name providing group names for this source. (Optional)
137+
- `--admin-group`: Group Claim value for administrator users. (Optional)
138+
- `--restricted-group`: Group Claim value for restricted users. (Optional)
132139
- Examples:
133140
- `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
134141
- `update-oauth`:
@@ -145,6 +152,13 @@ Admin operations:
145152
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
146153
- `--custom-email-url`: Use a custom Email URL (option for GitHub).
147154
- `--icon-url`: Custom icon URL for OAuth2 login source.
155+
- `--override-local-2fa`: Allow source to override local 2fa. (Optional)
156+
- `--scopes`: Addtional scopes to request for this OAuth2 source.
157+
- `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional)
158+
- `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional)
159+
- `--group-claim-name`: Claim name providing group names for this source. (Optional)
160+
- `--admin-group`: Group Claim value for administrator users. (Optional)
161+
- `--restricted-group`: Group Claim value for restricted users. (Optional)
148162
- Examples:
149163
- `gitea admin auth update-oauth --id 1 --name external-github-updated`
150164
- `add-ldap`: Add new LDAP (via Bind DN) authentication source

docs/content/page/index.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.
7373
- PostgreSQL (>=10)
7474
- SQLite3
7575
- MSSQL (>=2008R2 SP3)
76-
- TiDB (experimental, not recommended)
76+
- TiDB (MySQL protocol)
7777
- Configuration file
7878
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)
7979
- Admin panel

docs/content/page/index.fr-fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Le but de ce projet est de fournir de la manière la plus simple, la plus rapide
6868
- PostgreSQL
6969
- SQLite3
7070
- MSSQL
71-
- [TiDB](https://github.com/pingcap/tidb) (expérimental)
71+
- [TiDB](https://github.com/pingcap/tidb) (MySQL protocol)
7272
- Fichier de configuration
7373
- Voir [ici](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)
7474
- Panel d'administration

docs/content/page/index.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Gitea的首要目标是创建一个极易安装,运行非常快速,安装和
3232
- 支持自定义源的 Gravatar 和 Federated Avatar
3333
- 支持邮件服务
3434
- 支持后台管理面板
35-
- 支持 MySQL、PostgreSQL、SQLite3, MSSQL 和 TiDB(实验性支持) 数据库
35+
- 支持 MySQL、PostgreSQL、SQLite3MSSQL 和 TiDB(MySQL) 数据库
3636
- 支持多语言本地化(21 种语言)
3737

3838
## 系统要求

docs/content/page/index.zh-tw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Gitea 是從 [Gogs](http://gogs.io) Fork 出來的,請閱讀部落格文章 [G
6969
- PostgreSQL
7070
- SQLite3
7171
- MSSQL
72-
- TiDB(實驗中, 不建議使用
72+
- TiDB(MySQL 協議
7373
- 設定檔
7474
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)
7575
- 管理員面板

integrations/api_admin_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"testing"
1111

12-
"code.gitea.io/gitea/models"
12+
asymkey_model "code.gitea.io/gitea/models/asymkey"
1313
"code.gitea.io/gitea/models/unittest"
1414
user_model "code.gitea.io/gitea/models/user"
1515
"code.gitea.io/gitea/modules/json"
@@ -34,7 +34,7 @@ func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) {
3434

3535
var newPublicKey api.PublicKey
3636
DecodeJSON(t, resp, &newPublicKey)
37-
unittest.AssertExistsAndLoadBean(t, &models.PublicKey{
37+
unittest.AssertExistsAndLoadBean(t, &asymkey_model.PublicKey{
3838
ID: newPublicKey.ID,
3939
Name: newPublicKey.Title,
4040
Content: newPublicKey.Key,
@@ -45,7 +45,7 @@ func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) {
4545
req = NewRequestf(t, "DELETE", "/api/v1/admin/users/%s/keys/%d?token=%s",
4646
keyOwner.Name, newPublicKey.ID, token)
4747
session.MakeRequest(t, req, http.StatusNoContent)
48-
unittest.AssertNotExistsBean(t, &models.PublicKey{ID: newPublicKey.ID})
48+
unittest.AssertNotExistsBean(t, &asymkey_model.PublicKey{ID: newPublicKey.ID})
4949
}
5050

5151
func TestAPIAdminDeleteMissingSSHKey(t *testing.T) {

0 commit comments

Comments
 (0)