class Fog::Proxmox::Auth::Token::AccessTicket

Constants

EXPIRATION_DELAY
NAME

Attributes

csrf_token[R]

Public Instance Methods

auth_body(params = {}) click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 47
def auth_body(params = {})
    raise URIError, 'URI params is required' if params.nil? || params.empty?
    raise URIError, 'proxmox_username is required' if params[:proxmox_username].nil? || params[:proxmox_username].empty?
    raise URIError, 'proxmox_password is required' if params[:proxmox_password].nil? || params[:proxmox_password].empty?
    URI.encode_www_form(username: params[:proxmox_username], password: params[:proxmox_password])
end
auth_method() click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 39
def auth_method
    'POST'
end
auth_path(params = {}) click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 43
def auth_path(params = {})
    '/access/ticket'
end
build_credentials(proxmox_options, data) click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 67
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
headers(method = 'GET', params = {}, additional_headers = {}) click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 54
def headers(method = 'GET', params = {}, additional_headers = {})
    headers_hash = {}
    @data ||= {}
    unless @data.empty?
        headers_hash.store('Cookie', "PVEAuthCookie=#{@data['ticket']}")
        if %w[PUT POST DELETE].include? method
        headers_hash.store('CSRFPreventionToken', @data['CSRFPreventionToken'])
        end
    end
    headers_hash.merge! additional_headers
    headers_hash
end
missing_credentials(options) click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 74
def missing_credentials(options)
    missing_credentials = []
    missing_credentials << :proxmox_username unless options[:proxmox_username]
    missing_credentials << :proxmox_password unless options[:proxmox_password]
    raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
end