Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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-ce
Commits
0f28c9bf
Commit
0f28c9bf
authored
Aug 29, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename api.Secret.File to api.Secret.Path
parent
1dc2ab91
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
17 additions
and
17 deletions
+17
-17
README.md
README.md
+1
-1
authorization_test.go
authorization_test.go
+2
-2
internal/api/api.go
internal/api/api.go
+2
-2
internal/api/secret.go
internal/api/secret.go
+4
-4
internal/artifacts/artifacts_upload_test.go
internal/artifacts/artifacts_upload_test.go
+1
-1
internal/testhelper/testhelper.go
internal/testhelper/testhelper.go
+1
-1
internal/upstream/routes.go
internal/upstream/routes.go
+1
-1
internal/upstream/upstream.go
internal/upstream/upstream.go
+2
-2
main.go
main.go
+2
-2
main_test.go
main_test.go
+1
-1
No files found.
README.md
View file @
0f28c9bf
...
...
@@ -31,7 +31,7 @@ Options:
pprof listening address, e.g. 'localhost:6060'
-proxyHeadersTimeout duration
How long to wait for response headers when proxying the request (default 5m0s)
-secret
File
string
-secret
Path
string
File with secret key to authenticate with authBackend (default "./.gitlab_workhorse_secret")
-version
Print version and exit
...
...
authorization_test.go
View file @
0f28c9bf
...
...
@@ -32,7 +32,7 @@ func runPreAuthorizeHandler(t *testing.T, ts *httptest.Server, suffix string, ur
t
.
Fatal
(
err
)
}
parsedURL
:=
helper
.
URLMustParse
(
ts
.
URL
)
a
:=
api
.
NewAPI
(
parsedURL
,
"123"
,
testhelper
.
Secret
File
(),
badgateway
.
TestRoundTripper
(
parsedURL
))
a
:=
api
.
NewAPI
(
parsedURL
,
"123"
,
testhelper
.
Secret
Path
(),
badgateway
.
TestRoundTripper
(
parsedURL
))
response
:=
httptest
.
NewRecorder
()
a
.
PreAuthorizeHandler
(
okHandler
,
suffix
)
.
ServeHTTP
(
response
,
httpRequest
)
...
...
@@ -86,7 +86,7 @@ func TestPreAuthorizeJWT(t *testing.T) {
if
_
,
ok
:=
token
.
Method
.
(
*
jwt
.
SigningMethodHMAC
);
!
ok
{
return
nil
,
fmt
.
Errorf
(
"Unexpected signing method: %v"
,
token
.
Header
[
"alg"
])
}
secretBytes
,
err
:=
(
&
api
.
Secret
{
File
:
testhelper
.
SecretFile
()})
.
Bytes
()
secretBytes
,
err
:=
(
&
api
.
Secret
{
Path
:
testhelper
.
SecretPath
()})
.
Bytes
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"read secret from file: %v"
,
err
)
}
...
...
internal/api/api.go
View file @
0f28c9bf
...
...
@@ -27,12 +27,12 @@ type API struct {
Secret
*
Secret
}
func
NewAPI
(
myURL
*
url
.
URL
,
version
,
secret
File
string
,
roundTripper
*
badgateway
.
RoundTripper
)
*
API
{
func
NewAPI
(
myURL
*
url
.
URL
,
version
,
secret
Path
string
,
roundTripper
*
badgateway
.
RoundTripper
)
*
API
{
return
&
API
{
Client
:
&
http
.
Client
{
Transport
:
roundTripper
},
URL
:
myURL
,
Version
:
version
,
Secret
:
&
Secret
{
File
:
secretFile
},
Secret
:
&
Secret
{
Path
:
secretPath
},
}
}
...
...
internal/api/secret.go
View file @
0f28c9bf
...
...
@@ -10,7 +10,7 @@ import (
const
numSecretBytes
=
32
type
Secret
struct
{
File
string
Path
string
bytes
[]
byte
sync
.
RWMutex
}
...
...
@@ -33,9 +33,9 @@ func (s *Secret) getBytes() []byte {
}
func
(
s
*
Secret
)
setBytes
()
([]
byte
,
error
)
{
base64Bytes
,
err
:=
ioutil
.
ReadFile
(
s
.
File
)
base64Bytes
,
err
:=
ioutil
.
ReadFile
(
s
.
Path
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"read Secret.
File
: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"read Secret.
Path
: %v"
,
err
)
}
secretBytes
:=
make
([]
byte
,
base64
.
StdEncoding
.
DecodedLen
(
len
(
base64Bytes
)))
...
...
@@ -45,7 +45,7 @@ func (s *Secret) setBytes() ([]byte, error) {
}
if
n
!=
numSecretBytes
{
return
nil
,
fmt
.
Errorf
(
"expected %d secretBytes in %s, found %d"
,
numSecretBytes
,
s
.
File
,
n
)
return
nil
,
fmt
.
Errorf
(
"expected %d secretBytes in %s, found %d"
,
numSecretBytes
,
s
.
Path
,
n
)
}
s
.
Lock
()
...
...
internal/artifacts/artifacts_upload_test.go
View file @
0f28c9bf
...
...
@@ -93,7 +93,7 @@ func testUploadArtifacts(contentType string, body io.Reader, t *testing.T, ts *h
response
:=
httptest
.
NewRecorder
()
parsedURL
:=
helper
.
URLMustParse
(
ts
.
URL
)
roundTripper
:=
badgateway
.
TestRoundTripper
(
parsedURL
)
apiClient
:=
api
.
NewAPI
(
parsedURL
,
"123"
,
testhelper
.
Secret
File
(),
roundTripper
)
apiClient
:=
api
.
NewAPI
(
parsedURL
,
"123"
,
testhelper
.
Secret
Path
(),
roundTripper
)
proxyClient
:=
proxy
.
NewProxy
(
parsedURL
,
"123"
,
roundTripper
)
UploadArtifacts
(
apiClient
,
proxyClient
)
.
ServeHTTP
(
response
,
httpRequest
)
return
response
...
...
internal/testhelper/testhelper.go
View file @
0f28c9bf
...
...
@@ -15,7 +15,7 @@ import (
"testing"
)
func
Secret
File
()
string
{
func
Secret
Path
()
string
{
return
path
.
Join
(
RootDir
(),
"testdata/test-secret"
)
}
...
...
internal/upstream/routes.go
View file @
0f28c9bf
...
...
@@ -37,7 +37,7 @@ func (u *Upstream) configureRoutes() {
api
:=
apipkg
.
NewAPI
(
u
.
Backend
,
u
.
Version
,
u
.
Secret
File
,
u
.
Secret
Path
,
u
.
RoundTripper
,
)
static
:=
&
staticpages
.
Static
{
u
.
DocumentRoot
}
...
...
internal/upstream/upstream.go
View file @
0f28c9bf
...
...
@@ -23,7 +23,7 @@ var DefaultBackend = helper.URLMustParse("http://localhost:8080")
type
Upstream
struct
{
Backend
*
url
.
URL
Version
string
Secret
File
string
Secret
Path
string
DocumentRoot
string
DevelopmentMode
bool
...
...
@@ -36,7 +36,7 @@ func NewUpstream(backend *url.URL, socket, version, secretFile, documentRoot str
up
:=
Upstream
{
Backend
:
backend
,
Version
:
version
,
Secret
File
:
secretFile
,
Secret
Path
:
secretFile
,
DocumentRoot
:
documentRoot
,
DevelopmentMode
:
developmentMode
,
}
...
...
main.go
View file @
0f28c9bf
...
...
@@ -40,7 +40,7 @@ var pprofListenAddr = flag.String("pprofListenAddr", "", "pprof listening addres
var
documentRoot
=
flag
.
String
(
"documentRoot"
,
"public"
,
"Path to static files content"
)
var
proxyHeadersTimeout
=
flag
.
Duration
(
"proxyHeadersTimeout"
,
5
*
time
.
Minute
,
"How long to wait for response headers when proxying the request"
)
var
developmentMode
=
flag
.
Bool
(
"developmentMode"
,
false
,
"Allow to serve assets from Rails app"
)
var
secret
File
=
flag
.
String
(
"secretFile
"
,
"./.gitlab_workhorse_secret"
,
"File with secret key to authenticate with authBackend"
)
var
secret
Path
=
flag
.
String
(
"secretPath
"
,
"./.gitlab_workhorse_secret"
,
"File with secret key to authenticate with authBackend"
)
func
main
()
{
flag
.
Usage
=
func
()
{
...
...
@@ -87,7 +87,7 @@ func main() {
*
authBackend
,
*
authSocket
,
Version
,
*
secret
File
,
*
secret
Path
,
*
documentRoot
,
*
developmentMode
,
*
proxyHeadersTimeout
,
...
...
main_test.go
View file @
0f28c9bf
...
...
@@ -868,7 +868,7 @@ func startWorkhorseServer(authBackend string) *httptest.Server {
helper
.
URLMustParse
(
authBackend
),
""
,
"123"
,
testhelper
.
Secret
File
(),
testhelper
.
Secret
Path
(),
testDocumentRoot
,
false
,
0
,
...
...
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