Skip to content

Commit 4b22267

Browse files
authored
Merge branch 'main' into ssh-sign
2 parents 72a8d09 + 9296baf commit 4b22267

File tree

229 files changed

+2890
-2033
lines changed

Some content is hidden

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

229 files changed

+2890
-2033
lines changed

.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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,36 @@ var (
299299
Name: "skip-local-2fa",
300300
Usage: "Set to true to skip local 2fa for users authenticated by this source",
301301
},
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+
},
302332
}
303333

304334
microcmdAuthUpdateOauth = cli.Command{
@@ -349,6 +379,10 @@ func runChangePassword(c *cli.Context) error {
349379
if err := initDB(ctx); err != nil {
350380
return err
351381
}
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+
352386
if !pwd.IsComplexEnough(c.String("password")) {
353387
return errors.New("Password does not meet complexity requirements")
354388
}
@@ -649,6 +683,12 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
649683
CustomURLMapping: customURLMapping,
650684
IconURL: c.String("icon-url"),
651685
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"),
652692
}
653693
}
654694

@@ -711,6 +751,28 @@ func runUpdateOauth(c *cli.Context) error {
711751
oAuth2Config.IconURL = c.String("icon-url")
712752
}
713753

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+
714776
// update custom URL mapping
715777
var customURLMapping = &oauth2.CustomURLMapping{}
716778

cmd/dump.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (o outputType) String() string {
8686
}
8787

8888
var outputTypeEnum = &outputType{
89-
Enum: []string{"zip", "tar", "tar.gz", "tar.xz", "tar.bz2"},
89+
Enum: []string{"zip", "rar", "tar", "sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"},
9090
Default: "zip",
9191
}
9292

@@ -152,12 +152,16 @@ func fatal(format string, args ...interface{}) {
152152
func runDump(ctx *cli.Context) error {
153153
var file *os.File
154154
fileName := ctx.String("file")
155+
outType := ctx.String("type")
155156
if fileName == "-" {
156157
file = os.Stdout
157158
err := log.DelLogger("console")
158159
if err != nil {
159160
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
160161
}
162+
} else {
163+
fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
164+
fileName += "." + outType
161165
}
162166
setting.LoadFromExisting()
163167

@@ -200,7 +204,6 @@ func runDump(ctx *cli.Context) error {
200204
}
201205

202206
verbose := ctx.Bool("verbose")
203-
outType := ctx.String("type")
204207
var iface interface{}
205208
if fileName == "-" {
206209
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))

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 *repo_model.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
})

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/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/doc/usage/issue-pull-request-templates.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Inside the directory can be multiple issue templates with the form
6969
name: "Template Name"
7070
about: "This template is for testing!"
7171
title: "[TEST] "
72+
ref: "main"
7273
labels:
7374

7475
- bug
@@ -82,4 +83,4 @@ This is the template!
8283
In the above example, when a user is presented with the list of issues they can submit, this would show as `Template Name` with the description
8384
`This template is for testing!`. When submitting an issue with the above example, the issue title would be pre-populated with
8485
`[TEST] ` while the issue body would be pre-populated with `This is the template!`. The issue would also be assigned two labels,
85-
`bug` and `help needed`.
86+
`bug` and `help needed`, and the issue will have a reference to `main`.

integrations/delete_user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func assertUserDeleted(t *testing.T, userID int64) {
2424
unittest.AssertNotExistsBean(t, &models.OrgUser{UID: userID})
2525
unittest.AssertNotExistsBean(t, &models.IssueUser{UID: userID})
2626
unittest.AssertNotExistsBean(t, &models.TeamUser{UID: userID})
27-
unittest.AssertNotExistsBean(t, &models.Star{UID: userID})
27+
unittest.AssertNotExistsBean(t, &repo_model.Star{UID: userID})
2828
}
2929

3030
func TestUserDeleteAccount(t *testing.T) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3a810dbf6b96afaa8c5f69a8b6ec1dabfca7368b
1+
59e2c41e8f5140bb0182acebec17c8ad9831cc62

integrations/integration_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,25 @@ func prepareTestEnv(t testing.TB, skip ...int) func() {
255255
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
256256

257257
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
258+
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
259+
if err != nil {
260+
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
261+
}
262+
for _, ownerDir := range ownerDirs {
263+
if !ownerDir.Type().IsDir() {
264+
continue
265+
}
266+
repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
267+
if err != nil {
268+
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
269+
}
270+
for _, repoDir := range repoDirs {
271+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
272+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
273+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
274+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
275+
}
276+
}
258277

259278
return deferFn
260279
}
@@ -532,4 +551,23 @@ func resetFixtures(t *testing.T) {
532551
assert.NoError(t, unittest.LoadFixtures())
533552
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
534553
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
554+
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
555+
if err != nil {
556+
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
557+
}
558+
for _, ownerDir := range ownerDirs {
559+
if !ownerDir.Type().IsDir() {
560+
continue
561+
}
562+
repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
563+
if err != nil {
564+
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
565+
}
566+
for _, repoDir := range repoDirs {
567+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
568+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
569+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
570+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
571+
}
572+
}
535573
}

integrations/migration-test/migration_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ func initMigrationTest(t *testing.T) func() {
6161
assert.True(t, len(setting.RepoRootPath) != 0)
6262
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
6363
assert.NoError(t, util.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
64+
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
65+
if err != nil {
66+
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
67+
}
68+
for _, ownerDir := range ownerDirs {
69+
if !ownerDir.Type().IsDir() {
70+
continue
71+
}
72+
repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
73+
if err != nil {
74+
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
75+
}
76+
for _, repoDir := range repoDirs {
77+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
78+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
79+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
80+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
81+
}
82+
}
6483

6584
git.CheckLFSVersion()
6685
setting.InitDBConfig()

integrations/nonascii_branches_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package integrations
66

77
import (
88
"net/http"
9+
"net/url"
910
"path"
1011
"testing"
1112

@@ -159,6 +160,41 @@ func TestNonasciiBranches(t *testing.T) {
159160
to: "tag/%D0%81/%E4%BA%BA",
160161
status: http.StatusOK,
161162
},
163+
{
164+
from: "Plus+Is+Not+Space/%25%252525mightnotplaywell",
165+
to: "branch/Plus+Is+Not+Space/%25%252525mightnotplaywell",
166+
status: http.StatusOK,
167+
},
168+
{
169+
from: "Plus+Is+Not+Space/%25253Fisnotaquestion%25253F",
170+
to: "branch/Plus+Is+Not+Space/%25253Fisnotaquestion%25253F",
171+
status: http.StatusOK,
172+
},
173+
{
174+
from: "Plus+Is+Not+Space/" + url.PathEscape("%3Fis?and#afile"),
175+
to: "branch/Plus+Is+Not+Space/" + url.PathEscape("%3Fis?and#afile"),
176+
status: http.StatusOK,
177+
},
178+
{
179+
from: "Plus+Is+Not+Space/10%25.md",
180+
to: "branch/Plus+Is+Not+Space/10%25.md",
181+
status: http.StatusOK,
182+
},
183+
{
184+
from: "Plus+Is+Not+Space/" + url.PathEscape("This+file%20has 1space"),
185+
to: "branch/Plus+Is+Not+Space/" + url.PathEscape("This+file%20has 1space"),
186+
status: http.StatusOK,
187+
},
188+
{
189+
from: "Plus+Is+Not+Space/" + url.PathEscape("This+file%2520has 2 spaces"),
190+
to: "branch/Plus+Is+Not+Space/" + url.PathEscape("This+file%2520has 2 spaces"),
191+
status: http.StatusOK,
192+
},
193+
{
194+
from: "Plus+Is+Not+Space/" + url.PathEscape("£15&$6.txt"),
195+
to: "branch/Plus+Is+Not+Space/" + url.PathEscape("£15&$6.txt"),
196+
status: http.StatusOK,
197+
},
162198
}
163199

164200
defer prepareTestEnv(t)()

0 commit comments

Comments
 (0)