Class: Fog::Proxmox::Auth::Token::AccessTicket
Defined Under Namespace
Classes: URIError
Constant Summary
collapse
- NAME =
'access_ticket'
- EXPIRATION_DELAY =
2 * 60 * 60
Instance Attribute Summary collapse
#data, #expires, #token, #userid
Instance Method Summary
collapse
#authenticate, build, #expired?, #initialize
Instance Attribute Details
#csrf_token ⇒ Object
Returns the value of attribute csrf_token.
34
35
36
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 34
def csrf_token
@csrf_token
end
|
Instance Method Details
#auth_body(params = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 48
def auth_body(params = {})
raise URIError, 'URI params is required' if params.nil? || params.empty?
if params[:proxmox_username].nil? || params[:proxmox_username].empty?
raise URIError,
'proxmox_username is required'
end
if params[:proxmox_password].nil? || params[:proxmox_password].empty?
raise URIError,
'proxmox_password is required'
end
URI.encode_www_form(username: params[:proxmox_username], password: params[:proxmox_password])
end
|
#auth_method ⇒ Object
40
41
42
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 40
def auth_method
'POST'
end
|
#auth_path(_params = {}) ⇒ Object
44
45
46
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 44
def auth_path(_params = {})
'/access/ticket'
end
|
#build_credentials(_proxmox_options, data) ⇒ Object
76
77
78
79
80
81
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 76
def build_credentials(_proxmox_options, data)
@token = data['ticket']
@expires = Time.now.utc.to_i + EXPIRATION_DELAY
@userid = data['username']
@csrf_token = data['CSRFPreventionToken']
end
|
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 63
def (method = 'GET', _params = {}, = {})
= {}
@data ||= {}
unless @data.empty?
.store('Cookie', "PVEAuthCookie=#{@data['ticket']}")
if %w[PUT POST DELETE].include? method
.store('CSRFPreventionToken', @data['CSRFPreventionToken'])
end
end
.merge!
end
|
#missing_credentials(options) ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'lib/fog/proxmox/auth/token/access_ticket.rb', line 83
def missing_credentials(options)
missing_credentials = []
missing_credentials << :proxmox_username unless options[:proxmox_username]
missing_credentials << :proxmox_password unless options[:proxmox_password]
return if missing_credentials.empty?
raise ArgumentError,
"Missing required arguments: #{missing_credentials.join(', ')}"
end
|