blob: 96d06d8f6d8a087236b0099f3d8dc74a56fd0f26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
require 'base64'
require 'json'
class GitlabLfsAuthentication
attr_accessor :username, :lfs_token, :repository_http_path
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)
begin
values = JSON.parse(json)
self.new(values['username'], values['lfs_token'], values['repository_http_path'])
rescue
nil
end
end
def authentication_payload
authorization = {
header: {
Authorization: "Basic #{Base64.strict_encode64("#{username}:#{lfs_token}")}"
},
href: "#{repository_http_path}/info/lfs/"
}
JSON.generate(authorization)
end
end
|