diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/internal.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/auth.rb | 25 | ||||
-rw-r--r-- | lib/gitlab/auth/result.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/lfs_token.rb | 54 |
4 files changed, 0 insertions, 96 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 090d04544da..1114fd21784 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -82,19 +82,6 @@ module API response end - post "/lfs_authenticate" do - status 200 - - key = Key.find(params[:key_id]) - token_handler = Gitlab::LfsToken.new(key) - - { - username: token_handler.actor_name, - lfs_token: token_handler.generate, - repository_http_path: project.http_url_to_repo - } - end - get "/merge_request_urls" do ::MergeRequests::GetUrlsService.new(project).execute(params[:changes]) end diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index ca2a0920c00..7464d6082cb 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -11,7 +11,6 @@ module Gitlab build_access_token_check(login, password) || user_with_password_for_git(login, password) || oauth_access_token_check(login, password) || - lfs_token_check(login, password) || personal_access_token_check(login, password) || Result.new @@ -103,30 +102,6 @@ module Gitlab end end - def lfs_token_check(login, password) - deploy_key_matches = login.match(/\Alfs\+deploy-key-(\d+)\z/) - - actor = - if deploy_key_matches - DeployKey.find(deploy_key_matches[1]) - else - User.by_login(login) - end - - if actor - token_handler = Gitlab::LfsToken.new(actor) - - authentication_abilities = - if token_handler.user? - full_authentication_abilities - else - read_authentication_abilities - end - - Result.new(actor, nil, token_handler.type, authentication_abilities) if Devise.secure_compare(token_handler.value, password) - end - end - def build_access_token_check(login, password) return unless login == 'gitlab-ci-token' return unless password diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb index e4786b12676..bf625649cbf 100644 --- a/lib/gitlab/auth/result.rb +++ b/lib/gitlab/auth/result.rb @@ -5,10 +5,6 @@ module Gitlab type == :ci end - def lfs_deploy_token? - type == :lfs_deploy_token - end - def success? actor.present? || type == :ci end diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb deleted file mode 100644 index d089a2f9b0b..00000000000 --- a/lib/gitlab/lfs_token.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Gitlab - class LfsToken - attr_accessor :actor - - TOKEN_LENGTH = 50 - EXPIRY_TIME = 1800 - - def initialize(actor) - @actor = - case actor - when DeployKey, User - actor - when Key - actor.user - else - raise 'Bad Actor' - end - end - - def generate - token = Devise.friendly_token(TOKEN_LENGTH) - - Gitlab::Redis.with do |redis| - redis.set(redis_key, token, ex: EXPIRY_TIME) - end - - token - end - - def value - Gitlab::Redis.with do |redis| - redis.get(redis_key) - end - end - - def user? - actor.is_a?(User) - end - - def type - actor.is_a?(User) ? :lfs_token : :lfs_deploy_token - end - - def actor_name - actor.is_a?(User) ? actor.username : "lfs+deploy-key-#{actor.id}" - end - - private - - def redis_key - "gitlab:lfs_token:#{actor.class.name.underscore}_#{actor.id}" if actor - end - end -end |