diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-08-30 13:37:09 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-09-06 12:11:17 -0500 |
commit | f53d09e1eb1323be9cd697813a6f47375c091f6a (patch) | |
tree | 42b1950e5a8f0a7d3f97cf37e1c279793fc7c30d /lib/gitlab_lfs_authentication.rb | |
parent | c16f7323bad61601df1ebe93475bd84aee532faf (diff) | |
download | gitlab-shell-f53d09e1eb1323be9cd697813a6f47375c091f6a.tar.gz |
Refactored LFS auth logic to use its own API endpoint.
Diffstat (limited to 'lib/gitlab_lfs_authentication.rb')
-rw-r--r-- | lib/gitlab_lfs_authentication.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab_lfs_authentication.rb b/lib/gitlab_lfs_authentication.rb index b05da21..4b36229 100644 --- a/lib/gitlab_lfs_authentication.rb +++ b/lib/gitlab_lfs_authentication.rb @@ -2,17 +2,23 @@ require 'base64' require 'json' class GitlabLfsAuthentication - attr_accessor :user, :repository_http_path + attr_accessor :username, :lfs_token, :repository_http_path - def initialize(user, repository_http_path) - @user = user + def initialize(username, lfs_token, repository_http_path) + @username = username + @lfs_token = lfs_token @repository_http_path = repository_http_path end + def self.build_from_json(json) + values = JSON.parse(json) + self.new(values['username'], values['lfs_token'], values['repository_http_path']) + end + def authenticate! authorization = { header: { - Authorization: "Basic #{Base64.strict_encode64("#{user['username']}:#{user['lfs_token']}")}" + Authorization: "Basic #{Base64.strict_encode64("#{username}:#{lfs_token}")}" }, href: "#{repository_http_path}/info/lfs/" } |