File tree Expand file tree Collapse file tree 4 files changed +25
-13
lines changed
Expand file tree Collapse file tree 4 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ gitlab:
1515 project_wiki : false
1616 project_merge_request : false
1717 project_snippet : false
18+ api :
19+ disable_config : false
1820sentry :
1921 report : true
2022 dns :
https://cd580221c955434b84d8c7fce2e9ed8d:[email protected] /1525034
Original file line number Diff line number Diff line change @@ -311,7 +311,7 @@ GET /info/busy
311311
312312## 查看配置
313313
314- 显示 hpr 配置信息。
314+ 显示 hpr 配置信息,可通过配置文件开启或关闭,认证信息及 Gitlab private token 会加密显示 。
315315
316316```
317317GET /config
@@ -328,12 +328,12 @@ GET /config
328328 "schedule_in" : " 1.minute" ,
329329 "basic_auth" : {
330330 "enable" : false ,
331- "user" : " hpr " ,
332- "password" : " p@ssw0rd "
331+ "user" : " ****** " ,
332+ "password" : " ****** "
333333 },
334334 "gitlab" : {
335335 "endpoint" : " http://gitlab.example.com/api/v4" ,
336- "private_token" : " <private_token-or-access_token>" ,
336+ "private_token" : " <encoded- private_token-or-access_token>" ,
337337 "group_name" : " mirrors" ,
338338 "project_public" : false ,
339339 "project_issue" : false ,
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ HTTP APIs 认证机制,如果需要暴露在外网访问为了安全起见目
4444| project_merge_request | boolean | 是否开启 MR | ` true ` /` false ` |
4545| project_snippet | boolean | 是否开启 Snippet | ` true ` /` false ` |
4646
47+ ## api
48+
49+ 和 API 相关的配置
50+
51+ | 名称 | 类型 | 说明 | 备注 |
52+ | ---| ---| ---| ---|
53+ | disable_config | boolean | 开关 [ /config] ( api#查看配置 ) 接口 | /config 会加密显示隐私字段,敏感的可以开启线上环境禁用此接口 |
54+
4755## sentry
4856
4957匿名错误上报,建议在 hpr 还未稳定之前保持开启状态,hpr 使用过程中遇到的各种问题上报对于尽快修复有很大的帮助作用,同时也减少了您提 issue 的环节和填写补充信息。如果你强烈不想错误上报也可以关闭它。
Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ class Web < Sinatra::Base
1616 use Rack ::CommonLogger , Logger . new ( STDOUT )
1717 use Raven ::Rack
1818
19+ if Configuration . basic_auth?
20+ use Rack ::Auth ::Basic , 'HPR Auth' do |username , password |
21+ username == Configuration . basic_auth . user &&
22+ password == Configuration . basic_auth . password
23+ end
24+ end
25+
1926 set :show_exceptions , :after_handler
2027 end
2128
@@ -36,8 +43,10 @@ class Web < Sinatra::Base
3643 json busy_jobs
3744 end
3845
39- get '/config' do
40- json Hpr ::Configuration . to_safe_h
46+ unless Hpr ::Configuration . api . disable_config
47+ get '/config' do
48+ json Hpr ::Configuration . to_safe_h
49+ end
4150 end
4251
4352 get '/repositories' do
@@ -146,13 +155,6 @@ def repository_or_404(name)
146155 end
147156 end
148157
149- if Configuration . basic_auth?
150- use Rack ::Auth ::Basic , 'HPR Auth' do |username , password |
151- username == Configuration . basic_auth . user &&
152- password == Configuration . basic_auth . password
153- end
154- end
155-
156158 private
157159
158160 def client
You can’t perform that action at this time.
0 commit comments