@@ -23,10 +23,13 @@ type Service struct {
23
23
}
24
24
25
25
type Config struct {
26
- ProjectRoot string
27
- GitBinPath string
28
- UploadPack bool
29
- ReceivePack bool
26
+ AuthPassEnvVar string
27
+ AuthUserEnvVar string
28
+ DefaultEnv string
29
+ ProjectRoot string
30
+ GitBinPath string
31
+ UploadPack bool
32
+ ReceivePack bool
30
33
}
31
34
32
35
type HandlerReq struct {
@@ -38,10 +41,13 @@ type HandlerReq struct {
38
41
}
39
42
40
43
var config Config = Config {
41
- ProjectRoot : "/tmp" ,
42
- GitBinPath : "/usr/bin/git" ,
43
- UploadPack : true ,
44
- ReceivePack : true ,
44
+ AuthPassEnvVar : "" ,
45
+ AuthUserEnvVar : "" ,
46
+ DefaultEnv : "" ,
47
+ ProjectRoot : "/tmp" ,
48
+ GitBinPath : "/usr/bin/git" ,
49
+ UploadPack : true ,
50
+ ReceivePack : true ,
45
51
}
46
52
47
53
var services = map [string ]Service {
63
69
)
64
70
65
71
func init () {
72
+ flag .StringVar (& config .AuthPassEnvVar , "auth_pass_env_var" , config .AuthPassEnvVar , "set an env var to provide the basic auth pass as" )
73
+ flag .StringVar (& config .AuthUserEnvVar , "auth_user_env_var" , config .AuthUserEnvVar , "set an env var to provide the basic auth user as" )
74
+ flag .StringVar (& config .DefaultEnv , "default_env" , config .DefaultEnv , "set the default env" )
66
75
flag .StringVar (& config .ProjectRoot , "project_root" , config .ProjectRoot , "set project root" )
67
76
flag .StringVar (& config .GitBinPath , "git_bin_path" , config .GitBinPath , "set git bin path" )
68
77
flag .StringVar (& address , "server_address" , address , "set server address" )
@@ -119,14 +128,20 @@ func serviceRpc(hr HandlerReq) {
119
128
w .Header ().Set ("Content-Type" , fmt .Sprintf ("application/x-git-%s-result" , rpc ))
120
129
w .WriteHeader (http .StatusOK )
121
130
122
- env := []string {
123
- "SSH_USER=git-http-backend" ,
131
+ env := []string {}
132
+
133
+ if config .DefaultEnv != "" {
134
+ env = append (env , config .DefaultEnv )
124
135
}
125
136
126
- user , _ , authok := r .BasicAuth ()
137
+ user , password , authok := r .BasicAuth ()
127
138
if authok {
128
- env = append (env , fmt .Sprintf ("NAME=%s" , user ))
129
- env = append (env , fmt .Sprintf ("SSH_NAME=%s" , user ))
139
+ if config .AuthUserEnvVar != "" {
140
+ env = append (env , fmt .Sprintf ("%s=%s" , config .AuthUserEnvVar , user ))
141
+ }
142
+ if config .AuthPassEnvVar != "" {
143
+ env = append (env , fmt .Sprintf ("%s=%s" , config .AuthPassEnvVar , password ))
144
+ }
130
145
}
131
146
132
147
args := []string {rpc , "--stateless-rpc" , dir }
0 commit comments