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
744e2875
Commit
744e2875
authored
Mar 16, 2020
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup: NXD blob/auth: Teach it to handle HTTP Basic Auth
parent
58e7dc3c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
internal/git/xblob.go
internal/git/xblob.go
+33
-2
No files found.
internal/git/xblob.go
View file @
744e2875
...
...
@@ -17,6 +17,9 @@ import (
"net/url"
"regexp"
"strings"
"os/exec"
"syscall"
"os"
)
// HTTP handler for `.../raw/<ref>/path`
...
...
@@ -49,7 +52,8 @@ func handleGetBlobRaw(a *api.API, w http.ResponseWriter, r *http.Request) {
// Query download access auth for this project
authReply
:=
a
.
VerifyDownloadAccess
(
project
,
user
,
u
.
RawQuery
,
r
.
Header
)
if
authReply
.
RepoPath
==
""
{
//if authReply.RepoPath == "" {
if
authReply
.
Repository
.
RelativePath
==
""
{
// access denied - copy auth reply to client in full -
// there are HTTP code and other headers / body relevant for
// about why access was denied.
...
...
@@ -67,9 +71,36 @@ func handleGetBlobRaw(a *api.API, w http.ResponseWriter, r *http.Request) {
}
// Access granted - we can emit the blob
emitBlob
(
w
,
authReply
.
RepoPath
,
refpath
,
r
)
emitBlob
(
w
,
authReply
.
Repo
sitory
.
Relative
Path
,
refpath
,
r
)
}
// Put back gitCommand function which was removed in
var
execCommand
=
exec
.
Command
// Git subprocess helpers
func
gitCommand
(
glId
string
,
glRepository
string
,
name
string
,
args
...
string
)
*
exec
.
Cmd
{
cmd
:=
execCommand
(
name
,
args
...
)
// Start the command in its own process group (nice for signalling)
cmd
.
SysProcAttr
=
&
syscall
.
SysProcAttr
{
Setpgid
:
true
}
// Explicitly set the environment for the Git command
cmd
.
Env
=
[]
string
{
fmt
.
Sprintf
(
"HOME=%s"
,
os
.
Getenv
(
"HOME"
)),
fmt
.
Sprintf
(
"PATH=%s"
,
os
.
Getenv
(
"PATH"
)),
fmt
.
Sprintf
(
"LD_LIBRARY_PATH=%s"
,
os
.
Getenv
(
"LD_LIBRARY_PATH"
)),
fmt
.
Sprintf
(
"GL_ID=%s"
,
glId
),
fmt
.
Sprintf
(
"GL_PROTOCOL=http"
),
}
if
glRepository
!=
""
{
cmd
.
Env
=
append
(
cmd
.
Env
,
fmt
.
Sprintf
(
"GL_REPOSITORY=%s"
,
glRepository
))
}
// If we don't do something with cmd.Stderr, Git errors will be lost
cmd
.
Stderr
=
os
.
Stderr
return
cmd
}
// 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
)
{
// Communicate with `git cat-file --batch` trying refs from longest
...
...
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