Skip to content

Commit 8698b11

Browse files
committed
fix
1 parent c69cbb7 commit 8698b11

19 files changed

Lines changed: 293 additions & 477 deletions

File tree

custom/conf/app.example.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ ENABLED = true
592592
;; * https://github.com/git-ecosystem/git-credential-manager
593593
;; * https://gitea.com/gitea/tea
594594
;DEFAULT_APPLICATIONS = git-credential-oauth, git-credential-manager, tea
595+
;;
596+
;; By default, OAuth2 applications can only use "http" and "https" as their redirect URI schemes.
597+
;; If you need to use other schemes (e.g. for desktop applications), you can specify them here as a comma-separated list.
598+
;; For example: set "my-scheme, com.example.app" to support "my-scheme://..." and "com.example.app://..." redirect URIs.
599+
;CUSTOM_SCHEMES =
595600

596601
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
597602
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

models/fixtures/oauth2_application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
name: "Test"
55
client_id: "da7da3ba-9a13-4167-856f-3899de0b0138"
66
client_secret: "$2a$10$UYRgUSgekzBp6hYe8pAdc.cgB4Gn06QRKsORUnIYTYQADs.YR/uvi" # bcrypt of "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=
7-
redirect_uris: '["a", "https://example.com/xyzzy"]'
7+
redirect_uris: '["https://example.com"]'
88
created_unix: 1546869730
99
updated_unix: 1546869730
1010
confidential_client: true
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,2 @@
1-
- id: 1
2-
grant_id: 1
3-
code: "authcode"
4-
code_challenge: "CjvyTLSdR47G5zYenDA-eDWW4lRrO8yvjcWwbD_deOg" # Code Verifier: N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt
5-
code_challenge_method: "S256"
6-
redirect_uri: "a"
7-
valid_until: 3546869730
8-
9-
- id: 2
10-
grant_id: 4
11-
code: "authcodepublic"
12-
code_challenge: "CjvyTLSdR47G5zYenDA-eDWW4lRrO8yvjcWwbD_deOg" # Code Verifier: N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt
13-
code_challenge_method: "S256"
14-
redirect_uri: "http://127.0.0.1/"
15-
valid_until: 3546869730
16-
1+
[]
172
# DO NOT add more test data in the fixtures, test case should prepare their own test data separately and clearly

modules/setting/oauth2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ var OAuth2 = struct {
9999
JWTClaimIssuer string `ini:"JWT_CLAIM_ISSUER"`
100100
MaxTokenLength int
101101
DefaultApplications []string
102+
CustomSchemes []string
102103
}{
103104
Enabled: true,
104105
AccessTokenExpirationTime: 3600,

modules/validation/binding.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"code.gitea.io/gitea/modules/git"
1414
"code.gitea.io/gitea/modules/glob"
1515
"code.gitea.io/gitea/modules/json"
16-
"code.gitea.io/gitea/modules/util"
1716

1817
"gitea.com/go-chi/binding"
1918
)
@@ -51,7 +50,6 @@ func (j jsonProvider) NewEncoder(writer io.Writer) binding.JSONEncoder {
5150
func AddBindingRules() {
5251
binding.JSONProvider = jsonProvider{}
5352
addGitRefNameBindingRule()
54-
addValidURLListBindingRule()
5553
addValidURLBindingRule()
5654
addValidSiteURLBindingRule()
5755
addGlobPatternRule()
@@ -80,33 +78,6 @@ func addGitRefNameBindingRule() {
8078
})
8179
}
8280

83-
func addValidURLListBindingRule() {
84-
// URL validation rule
85-
binding.AddRule(&binding.Rule{
86-
IsMatch: func(rule string) bool {
87-
return rule == "ValidUrlList"
88-
},
89-
IsValid: func(errs binding.Errors, name string, val any) (bool, binding.Errors) {
90-
str := fmt.Sprintf("%v", val)
91-
if len(str) == 0 {
92-
errs.Add([]string{name}, binding.ERR_URL, "Url")
93-
return false, errs
94-
}
95-
96-
ok := true
97-
urls := util.SplitTrimSpace(str, "\n")
98-
for _, u := range urls {
99-
if !IsValidURL(u) {
100-
ok = false
101-
errs.Add([]string{name}, binding.ERR_URL, u)
102-
}
103-
}
104-
105-
return ok, errs
106-
},
107-
})
108-
}
109-
11081
func addValidURLBindingRule() {
11182
// URL validation rule
11283
binding.AddRule(&binding.Rule{

modules/validation/binding_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type (
2727
TestForm struct {
2828
BranchName string `form:"BranchName" binding:"GitRefName"`
2929
URL string `form:"ValidUrl" binding:"ValidUrl"`
30-
URLs string `form:"ValidUrls" binding:"ValidUrlList"`
3130
GlobPattern string `form:"GlobPattern" binding:"GlobPattern"`
3231
RegexPattern string `form:"RegexPattern" binding:"RegexPattern"`
3332
}

modules/validation/validurllist_test.go

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)