Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
2d1bf3dd
Commit
2d1bf3dd
authored
Nov 21, 2022
by
Jérome Perrin
Committed by
Alain Takoudjou
Jan 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format code with make fmt
parent
86e880fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
15 deletions
+16
-15
internal/api/auth.go
internal/api/auth.go
+8
-6
internal/git/xblob.go
internal/git/xblob.go
+7
-8
internal/upstream/routes.go
internal/upstream/routes.go
+1
-1
No files found.
internal/api/auth.go
View file @
2d1bf3dd
...
@@ -3,11 +3,6 @@ package api
...
@@ -3,11 +3,6 @@ package api
//"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
//"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
import
(
import
(
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
proxypkg
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/senddata"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/sendfile"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"fmt"
"fmt"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
...
@@ -15,6 +10,13 @@ import (
...
@@ -15,6 +10,13 @@ import (
"strings"
"strings"
"sync"
"sync"
"time"
"time"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
proxypkg
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/senddata"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/sendfile"
)
)
// Reply from auth backend, e.g. for "download from repo" authorization request
// Reply from auth backend, e.g. for "download from repo" authorization request
...
@@ -285,7 +287,7 @@ func (a *API) verifyDownloadAccess(project string, user *url.Userinfo, query str
...
@@ -285,7 +287,7 @@ func (a *API) verifyDownloadAccess(project string, user *url.Userinfo, query str
url
+=
"?"
+
query
url
+=
"?"
+
query
}
}
reqDownloadAccess
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
reqDownloadAccess
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
q
:=
http
.
Request
{
Header
:
header
}
q
:=
http
.
Request
{
Header
:
header
}
if
err
!=
nil
{
if
err
!=
nil
{
helper
.
Fail500
(
authReply
.
RawReply
,
&
q
,
fmt
.
Errorf
(
"GET git-upload-pack: %v"
,
err
))
helper
.
Fail500
(
authReply
.
RawReply
,
&
q
,
fmt
.
Errorf
(
"GET git-upload-pack: %v"
,
err
))
return
authReply
return
authReply
...
...
internal/git/xblob.go
View file @
2d1bf3dd
...
@@ -6,8 +6,6 @@
...
@@ -6,8 +6,6 @@
package
git
package
git
import
(
import
(
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"bufio"
"bufio"
"errors"
"errors"
"fmt"
"fmt"
...
@@ -15,11 +13,14 @@ import (
...
@@ -15,11 +13,14 @@ import (
"log"
"log"
"net/http"
"net/http"
"net/url"
"net/url"
"os"
"os/exec"
"regexp"
"regexp"
"strings"
"strings"
"os/exec"
"syscall"
"syscall"
"os"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
)
// HTTP handler for `.../raw/<ref>/path`
// HTTP handler for `.../raw/<ref>/path`
...
@@ -52,8 +53,8 @@ func handleGetBlobRaw(a *api.API, w http.ResponseWriter, r *http.Request, repoPa
...
@@ -52,8 +53,8 @@ func handleGetBlobRaw(a *api.API, w http.ResponseWriter, r *http.Request, repoPa
// Query download access auth for this project
// Query download access auth for this project
authReply
:=
a
.
VerifyDownloadAccess
(
project
,
user
,
u
.
RawQuery
,
r
.
Header
)
authReply
:=
a
.
VerifyDownloadAccess
(
project
,
user
,
u
.
RawQuery
,
r
.
Header
)
//if authReply.Repository.RelativePath == "" {
//if authReply.Repository.RelativePath == "" {
if
authReply
.
RawReply
.
Code
!=
http
.
StatusOK
{
if
authReply
.
RawReply
.
Code
!=
http
.
StatusOK
{
// access denied - copy auth reply to client in full -
// access denied - copy auth reply to client in full -
// there are HTTP code and other headers / body relevant for
// there are HTTP code and other headers / body relevant for
// about why access was denied.
// about why access was denied.
...
@@ -75,7 +76,6 @@ func handleGetBlobRaw(a *api.API, w http.ResponseWriter, r *http.Request, repoPa
...
@@ -75,7 +76,6 @@ func handleGetBlobRaw(a *api.API, w http.ResponseWriter, r *http.Request, repoPa
emitBlob
(
w
,
p
,
refpath
,
r
)
emitBlob
(
w
,
p
,
refpath
,
r
)
}
}
// Put back gitCommand function which was removed in
// Put back gitCommand function which was removed in
var
execCommand
=
exec
.
Command
var
execCommand
=
exec
.
Command
...
@@ -101,7 +101,6 @@ func gitCommand(glId string, glRepository string, name string, args ...string) *
...
@@ -101,7 +101,6 @@ func gitCommand(glId string, glRepository string, name string, args ...string) *
return
cmd
return
cmd
}
}
// Emit content of blob located at <ref>/path (jointly denoted as 'refpath') to output
// Emit content of blob located at <ref>/path (jointly denoted as 'refpath') to output
func
emitBlob
(
w
http
.
ResponseWriter
,
repopath
string
,
refpath
string
,
r
*
http
.
Request
)
{
func
emitBlob
(
w
http
.
ResponseWriter
,
repopath
string
,
refpath
string
,
r
*
http
.
Request
)
{
// Communicate with `git cat-file --batch` trying refs from longest
// Communicate with `git cat-file --batch` trying refs from longest
...
...
internal/upstream/routes.go
View file @
2d1bf3dd
...
@@ -189,7 +189,7 @@ func (u *upstream) configureRoutes() {
...
@@ -189,7 +189,7 @@ func (u *upstream) configureRoutes() {
route
(
"PUT"
,
gitProjectPattern
+
`gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`
,
lfs
.
PutStore
(
api
,
signingProxy
),
withMatcher
(
isContentType
(
"application/octet-stream"
))),
route
(
"PUT"
,
gitProjectPattern
+
`gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`
,
lfs
.
PutStore
(
api
,
signingProxy
),
withMatcher
(
isContentType
(
"application/octet-stream"
))),
// Raw blobs
// Raw blobs
route
(
"GET"
,
projectPattern
+
`raw/`
,
git
.
GetBlobRaw
(
api
,
u
.
RepoPath
)),
route
(
"GET"
,
projectPattern
+
`raw/`
,
git
.
GetBlobRaw
(
api
,
u
.
RepoPath
)),
// CI Artifacts
// CI Artifacts
route
(
"POST"
,
apiPattern
+
`v4/jobs/[0-9]+/artifacts\z`
,
contentEncodingHandler
(
artifacts
.
UploadArtifacts
(
api
,
signingProxy
))),
route
(
"POST"
,
apiPattern
+
`v4/jobs/[0-9]+/artifacts\z`
,
contentEncodingHandler
(
artifacts
.
UploadArtifacts
(
api
,
signingProxy
))),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment