Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DockerFileSSH
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ RUN mkdir -p /var/cache/nginx && chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /etc/nginx && \
chmod -R 777 /etc/nginx/conf.d && \
sed -i 's/user nginx;/#user nginx;/g' /etc/nginx/nginx.conf
RUN sed -i 's/listen 80;/listen 8080;/g' /etc/nginx/conf.d/default.conf
RUN sed -i 's/listen [::]:80;/listen [::]:8080;/g' /etc/nginx/conf.d/default.conf


USER nginx

Expand Down
4 changes: 2 additions & 2 deletions auth/gitee.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func verifyUserDownload(giteeUser *giteeUser, userInRepo UserInRepo) error {

func VerifySSHAuthToken(auth string, userInRepo UserInRepo) error {
batchCheckRequest := batch.Request{
Operation: "upload",
Operation: userInRepo.Operation,
Transfers: []string{
"lfs-standalone-file",
"basic",
Expand All @@ -255,7 +255,7 @@ func VerifySSHAuthToken(auth string, userInRepo UserInRepo) error {
return generateError(err, msg)
}
bodyReader := bytes.NewReader(jsonData)
path := fmt.Sprintf("https://gitee.com/%s/%s.git/info/lfs/objects/batch", userInRepo.Owner, userInRepo.Repo)
path := fmt.Sprintf("https://gitee.com/%s/%s/info/lfs/objects/batch", userInRepo.Owner, userInRepo.Repo)
headers := http.Header{
accept: []string{"application/vnd.git-lfs+json"},
userAgent: []string{"git-lfs/3.5.1 (GitHub; linux amd64; go 1.21.8)"},
Expand Down
13 changes: 8 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (s *server) handleBatch(w http.ResponseWriter, r *http.Request) {
userInRepo.Operation = req.Operation
userInRepo.Owner = chi.URLParam(r, "owner")
userInRepo.Repo = chi.URLParam(r, "repo")

userInRepo.Repo = strings.TrimSuffix(userInRepo.Repo, ".git")
if !validatecfg.ownerRegexp.MatchString(userInRepo.Owner) || !validatecfg.reponameRegexp.MatchString(userInRepo.Repo) {
w.WriteHeader(http.StatusBadRequest)
must(json.NewEncoder(w).Encode(batch.ErrorResponse{
Expand All @@ -142,15 +142,18 @@ func (s *server) handleBatch(w http.ResponseWriter, r *http.Request) {
return
}

if err = auth.CheckRepoOwner(userInRepo); req.Operation == "upload" || err != nil {
if err = auth.CheckRepoOwner(userInRepo); req.Operation == "upload" ||
(err != nil && strings.HasPrefix(err.Error(), "not_found")) {
err := s.dealWithAuthError(userInRepo, w, r)
if err != nil {
return
}
} else if err != nil {
return
} else {
resp := s.handleRequestObject(req)
must(json.NewEncoder(w).Encode(resp))
}

resp := s.handleRequestObject(req)
must(json.NewEncoder(w).Encode(resp))
}

func (s *server) handleRequestObject(req batch.Request) batch.Response {
Expand Down
Loading