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 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()
click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 40 def auth_method 'POST' end
auth_path(_params = {})
click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 44 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 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
headers(method = 'GET', _params = {}, additional_headers = {})
click to toggle source
# File lib/fog/proxmox/auth/token/access_ticket.rb, line 63 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 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