diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-16 17:07:21 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-16 17:07:21 +0300 |
commit | 2742f9fb98babc0009e446d291757ae43c54c101 (patch) | |
tree | 5f86ef0dc027963e5f3d2e0a50cc65f82d4105a1 /app | |
parent | b0195d5c55d913dd62cb01b553b045f2681e7eb7 (diff) |
Improve authentication_result usage
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/git_http_client_controller.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index 632dac6aac9..ee9ea4bc8b2 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -19,6 +19,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController private def authenticate_user + @authentication_result = Gitlab::Auth::Result.new + if project && project.public? && download_request? return # Allow access end @@ -124,6 +126,18 @@ class Projects::GitHttpClientController < Projects::ApplicationController end end + def ci? + authentication_result.ci? && + authentication_project && + authentication_project == project + end + + def lfs_deploy_key? + authentication_result.lfs_deploy_token? && + actor && + actor.projects.include?(project) + end + def authentication_has_download_access? has_authentication_ability?(:download_code) || has_authentication_ability?(:build_download_code) end @@ -132,19 +146,12 @@ class Projects::GitHttpClientController < Projects::ApplicationController has_authentication_ability?(:push_code) end - def ci? - authentication_result && authentication_result.ci? && - authentication_result.project && authentication_result.project == project - end - - def lfs_deploy_key? - authentication_result && authentication_result.lfs_deploy_token? && - actor && actor.projects.include?(project) + def has_authentication_ability?(capability) + (authentication_abilities || []).include?(capability) end - def has_authentication_ability?(capability) - authentication_abilities && - authentication_abilities.include?(capability) + def authentication_project + authentication_result.project end def verify_workhorse_api! |