summaryrefslogtreecommitdiff
path: root/lib/gitlab_lfs_authentication.rb
blob: b05da21c4ec23f53f5672bf5e2dee699353e364e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'base64'
require 'json'

class GitlabLfsAuthentication
  attr_accessor :user, :repository_http_path

  def initialize(user, repository_http_path)
    @user = user
    @repository_http_path = repository_http_path
  end

  def authenticate!
    authorization = {
      header: {
        Authorization: "Basic #{Base64.strict_encode64("#{user['username']}:#{user['lfs_token']}")}"
      },
      href: "#{repository_http_path}/info/lfs/"
    }

    JSON.generate(authorization)
  end
end