Class: Docker::Remote::AuthInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/remote/auth_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_type, params, creds) ⇒ AuthInfo

Returns a new instance of AuthInfo.



21
22
23
24
25
# File 'lib/docker/remote/auth_info.rb', line 21

def initialize(auth_type, params, creds)
  @auth_type = auth_type
  @params = params
  @creds = creds
end

Instance Attribute Details

#auth_typeObject (readonly)

Returns the value of attribute auth_type.



19
20
21
# File 'lib/docker/remote/auth_info.rb', line 19

def auth_type
  @auth_type
end

#credsObject (readonly)

Returns the value of attribute creds.



19
20
21
# File 'lib/docker/remote/auth_info.rb', line 19

def creds
  @creds
end

#paramsObject (readonly)

Returns the value of attribute params.



19
20
21
# File 'lib/docker/remote/auth_info.rb', line 19

def params
  @params
end

Class Method Details

.from_header(header, creds) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/docker/remote/auth_info.rb', line 5

def from_header(header, creds)
  idx = header.index(' ')
  auth_type = header[0..idx].strip.downcase

  params = header[idx..-1].split(',').each_with_object({}) do |param, ret|
    key, value = param.split('=')
    ret[key.strip] = value.strip[1..-2]  # remove quotes
  end

  new(auth_type, params, creds)
end

Instance Method Details

#strategyObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/docker/remote/auth_info.rb', line 27

def strategy
  @strategy ||= case auth_type
    when 'bearer'
      BearerAuth.new(self, creds)
    when 'basic'
      BasicAuth.new(creds)
    else
      raise UnsupportedAuthTypeError,
        "unsupported Docker auth type '#{auth_type}'"
  end
end