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
ffa068f5
Commit
ffa068f5
authored
Dec 18, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename authorizationResponse to apiResponse
parent
59dc7cdc
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
17 additions
and
17 deletions
+17
-17
archive.go
archive.go
+1
-1
artifacts.go
artifacts.go
+1
-1
authorization.go
authorization.go
+1
-1
authorization_test.go
authorization_test.go
+5
-5
git-http.go
git-http.go
+3
-3
lfs.go
lfs.go
+2
-2
main_test.go
main_test.go
+2
-2
upstream.go
upstream.go
+2
-2
No files found.
archive.go
View file @
ffa068f5
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
"time"
"time"
)
)
func
handleGetArchive
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
func
handleGetArchive
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
var
format
string
var
format
string
urlPath
:=
r
.
URL
.
Path
urlPath
:=
r
.
URL
.
Path
switch
filepath
.
Base
(
urlPath
)
{
switch
filepath
.
Base
(
urlPath
)
{
...
...
artifacts.go
View file @
ffa068f5
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
)
)
func
(
api
*
API
)
artifactsAuthorizeHandler
(
h
httpHandleFunc
)
httpHandleFunc
{
func
(
api
*
API
)
artifactsAuthorizeHandler
(
h
httpHandleFunc
)
httpHandleFunc
{
return
api
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
return
api
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
r
.
Header
.
Set
(
tempPathHeader
,
a
.
TempPath
)
r
.
Header
.
Set
(
tempPathHeader
,
a
.
TempPath
)
h
(
w
,
r
)
h
(
w
,
r
)
},
"/authorize"
)
},
"/authorize"
)
...
...
authorization.go
View file @
ffa068f5
...
@@ -86,7 +86,7 @@ func (api *API) preAuthorizeHandler(h serviceHandleFunc, suffix string) httpHand
...
@@ -86,7 +86,7 @@ func (api *API) preAuthorizeHandler(h serviceHandleFunc, suffix string) httpHand
return
return
}
}
a
:=
&
a
uthorization
Response
{}
a
:=
&
a
pi
Response
{}
// The auth backend validated the client request and told us additional
// The auth backend validated the client request and told us additional
// request metadata. We must extract this information from the auth
// request metadata. We must extract this information from the auth
// response body.
// response body.
...
...
authorization_test.go
View file @
ffa068f5
...
@@ -8,14 +8,14 @@ import (
...
@@ -8,14 +8,14 @@ import (
"testing"
"testing"
)
)
func
okHandler
(
w
http
.
ResponseWriter
,
_
*
http
.
Request
,
_
*
a
uthorization
Response
)
{
func
okHandler
(
w
http
.
ResponseWriter
,
_
*
http
.
Request
,
_
*
a
pi
Response
)
{
w
.
WriteHeader
(
201
)
w
.
WriteHeader
(
201
)
fmt
.
Fprint
(
w
,
"{
\"
status
\"
:
\"
ok
\"
}"
)
fmt
.
Fprint
(
w
,
"{
\"
status
\"
:
\"
ok
\"
}"
)
}
}
func
runPreAuthorizeHandler
(
t
*
testing
.
T
,
suffix
string
,
url
*
regexp
.
Regexp
,
a
uthorization
Response
interface
{},
returnCode
,
expectedCode
int
)
*
httptest
.
ResponseRecorder
{
func
runPreAuthorizeHandler
(
t
*
testing
.
T
,
suffix
string
,
url
*
regexp
.
Regexp
,
a
pi
Response
interface
{},
returnCode
,
expectedCode
int
)
*
httptest
.
ResponseRecorder
{
// Prepare test server and backend
// Prepare test server and backend
ts
:=
testAuthServer
(
url
,
returnCode
,
a
uthorization
Response
)
ts
:=
testAuthServer
(
url
,
returnCode
,
a
pi
Response
)
defer
ts
.
Close
()
defer
ts
.
Close
()
// Create http request
// Create http request
...
@@ -35,7 +35,7 @@ func TestPreAuthorizeHappyPath(t *testing.T) {
...
@@ -35,7 +35,7 @@ func TestPreAuthorizeHappyPath(t *testing.T) {
runPreAuthorizeHandler
(
runPreAuthorizeHandler
(
t
,
"/authorize"
,
t
,
"/authorize"
,
regexp
.
MustCompile
(
`/authorize\z`
),
regexp
.
MustCompile
(
`/authorize\z`
),
&
a
uthorization
Response
{},
&
a
pi
Response
{},
200
,
201
)
200
,
201
)
}
}
...
@@ -43,7 +43,7 @@ func TestPreAuthorizeSuffix(t *testing.T) {
...
@@ -43,7 +43,7 @@ func TestPreAuthorizeSuffix(t *testing.T) {
runPreAuthorizeHandler
(
runPreAuthorizeHandler
(
t
,
"/different-authorize"
,
t
,
"/different-authorize"
,
regexp
.
MustCompile
(
`/authorize\z`
),
regexp
.
MustCompile
(
`/authorize\z`
),
&
a
uthorization
Response
{},
&
a
pi
Response
{},
200
,
404
)
200
,
404
)
}
}
...
...
git-http.go
View file @
ffa068f5
...
@@ -27,7 +27,7 @@ func looksLikeRepo(p string) bool {
...
@@ -27,7 +27,7 @@ func looksLikeRepo(p string) bool {
}
}
func
(
api
*
API
)
repoPreAuthorizeHandler
(
handleFunc
serviceHandleFunc
)
httpHandleFunc
{
func
(
api
*
API
)
repoPreAuthorizeHandler
(
handleFunc
serviceHandleFunc
)
httpHandleFunc
{
return
api
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
return
api
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
if
a
.
RepoPath
==
""
{
if
a
.
RepoPath
==
""
{
fail500
(
w
,
errors
.
New
(
"repoPreAuthorizeHandler: RepoPath empty"
))
fail500
(
w
,
errors
.
New
(
"repoPreAuthorizeHandler: RepoPath empty"
))
return
return
...
@@ -42,7 +42,7 @@ func (api *API) repoPreAuthorizeHandler(handleFunc serviceHandleFunc) httpHandle
...
@@ -42,7 +42,7 @@ func (api *API) repoPreAuthorizeHandler(handleFunc serviceHandleFunc) httpHandle
},
""
)
},
""
)
}
}
func
handleGetInfoRefs
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
func
handleGetInfoRefs
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
// The 'dumb' Git HTTP protocol is not supported
// The 'dumb' Git HTTP protocol is not supported
...
@@ -86,7 +86,7 @@ func handleGetInfoRefs(w http.ResponseWriter, r *http.Request, a *authorizationR
...
@@ -86,7 +86,7 @@ func handleGetInfoRefs(w http.ResponseWriter, r *http.Request, a *authorizationR
}
}
}
}
func
handlePostRPC
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
func
handlePostRPC
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
var
err
error
var
err
error
// Get Git action from URL
// Get Git action from URL
...
...
lfs.go
View file @
ffa068f5
...
@@ -18,7 +18,7 @@ import (
...
@@ -18,7 +18,7 @@ import (
)
)
func
(
api
*
API
)
lfsAuthorizeHandler
(
handleFunc
serviceHandleFunc
)
httpHandleFunc
{
func
(
api
*
API
)
lfsAuthorizeHandler
(
handleFunc
serviceHandleFunc
)
httpHandleFunc
{
return
api
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
return
api
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
if
a
.
StoreLFSPath
==
""
{
if
a
.
StoreLFSPath
==
""
{
fail500
(
w
,
errors
.
New
(
"lfsAuthorizeHandler: StoreLFSPath empty"
))
fail500
(
w
,
errors
.
New
(
"lfsAuthorizeHandler: StoreLFSPath empty"
))
...
@@ -39,7 +39,7 @@ func (api *API) lfsAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc
...
@@ -39,7 +39,7 @@ func (api *API) lfsAuthorizeHandler(handleFunc serviceHandleFunc) httpHandleFunc
},
"/authorize"
)
},
"/authorize"
)
}
}
func
(
u
*
upstream
)
handleStoreLfsObject
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
uthorization
Response
)
{
func
(
u
*
upstream
)
handleStoreLfsObject
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
a
*
a
pi
Response
)
{
file
,
err
:=
ioutil
.
TempFile
(
a
.
StoreLFSPath
,
a
.
LfsOid
)
file
,
err
:=
ioutil
.
TempFile
(
a
.
StoreLFSPath
,
a
.
LfsOid
)
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
fmt
.
Errorf
(
"handleStoreLfsObject: create tempfile: %v"
,
err
))
fail500
(
w
,
fmt
.
Errorf
(
"handleStoreLfsObject: create tempfile: %v"
,
err
))
...
...
main_test.go
View file @
ffa068f5
...
@@ -340,7 +340,7 @@ func runOrFail(t *testing.T, cmd *exec.Cmd) {
...
@@ -340,7 +340,7 @@ func runOrFail(t *testing.T, cmd *exec.Cmd) {
}
}
func
gitOkBody
(
t
*
testing
.
T
)
interface
{}
{
func
gitOkBody
(
t
*
testing
.
T
)
interface
{}
{
return
&
a
uthorization
Response
{
return
&
a
pi
Response
{
GL_ID
:
"user-123"
,
GL_ID
:
"user-123"
,
RepoPath
:
repoPath
(
t
),
RepoPath
:
repoPath
(
t
),
}
}
...
@@ -353,7 +353,7 @@ func archiveOkBody(t *testing.T, archiveName string) interface{} {
...
@@ -353,7 +353,7 @@ func archiveOkBody(t *testing.T, archiveName string) interface{} {
}
}
archivePath
:=
path
.
Join
(
cwd
,
cacheDir
,
archiveName
)
archivePath
:=
path
.
Join
(
cwd
,
cacheDir
,
archiveName
)
return
&
a
uthorization
Response
{
return
&
a
pi
Response
{
RepoPath
:
repoPath
(
t
),
RepoPath
:
repoPath
(
t
),
ArchivePath
:
archivePath
,
ArchivePath
:
archivePath
,
CommitId
:
"c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"
,
CommitId
:
"c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"
,
...
...
upstream.go
View file @
ffa068f5
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
"strings"
"strings"
)
)
type
serviceHandleFunc
func
(
http
.
ResponseWriter
,
*
http
.
Request
,
*
a
uthorization
Response
)
type
serviceHandleFunc
func
(
http
.
ResponseWriter
,
*
http
.
Request
,
*
a
pi
Response
)
type
API
struct
{
type
API
struct
{
*
http
.
Client
*
http
.
Client
...
@@ -29,7 +29,7 @@ type upstream struct {
...
@@ -29,7 +29,7 @@ type upstream struct {
relativeURLRoot
string
relativeURLRoot
string
}
}
type
a
uthorization
Response
struct
{
type
a
pi
Response
struct
{
// GL_ID is an environment variable used by gitlab-shell hooks during 'git
// GL_ID is an environment variable used by gitlab-shell hooks during 'git
// push' and 'git pull'
// push' and 'git pull'
GL_ID
string
GL_ID
string
...
...
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