mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	Backport #27486 by @lunny Fix #27204 This PR allows `/<username>/<reponame>/attachments/<uuid>` access with personal access token and also changed attachments API download url to it so it can be download correctly. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		| @@ -36,12 +36,16 @@ func isContainerPath(req *http.Request) bool { | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	gitRawReleasePathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/))`) | ||||
| 	lfsPathRe           = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`) | ||||
| 	gitRawOrAttachPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/)|(?:attachments/))`) | ||||
| 	lfsPathRe            = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`) | ||||
| ) | ||||
|  | ||||
| func isGitRawReleaseOrLFSPath(req *http.Request) bool { | ||||
| 	if gitRawReleasePathRe.MatchString(req.URL.Path) { | ||||
| func isGitRawOrAttachPath(req *http.Request) bool { | ||||
| 	return gitRawOrAttachPathRe.MatchString(req.URL.Path) | ||||
| } | ||||
|  | ||||
| func isGitRawOrAttachOrLFSPath(req *http.Request) bool { | ||||
| 	if isGitRawOrAttachPath(req) { | ||||
| 		return true | ||||
| 	} | ||||
| 	if setting.LFS.StartServer { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user