Skip to content

Commit 35be5a7

Browse files
committed
Authenticate requests with WS API key
1 parent 094602f commit 35be5a7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/controllers/github_hook_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require "json"
22

33
class GithubHookController < ApplicationController
4+
before_filter :check_enabled
45
skip_before_filter :verify_authenticity_token, :check_if_login_required
56

67
def index
@@ -41,4 +42,12 @@ def update_repository(logger)
4142
updater.logger = logger
4243
updater.call
4344
end
45+
46+
def check_enabled
47+
User.current = nil
48+
unless Setting.sys_api_enabled? && params[:key].to_s == Setting.sys_api_key
49+
render :text => 'Access denied. Repository management WS is disabled or key is invalid.', :status => 403
50+
return false
51+
end
52+
end
4453
end

0 commit comments

Comments
 (0)