class Round::Client::Context

Constants

SCHEMES

Attributes

mfa_token[RW]
schemes[RW]

Public Class Methods

new() click to toggle source
# File lib/round/client.rb, line 81
def initialize
  @schemes = {}
end

Public Instance Methods

authorize(scheme, params) click to toggle source

Is there a list of accepted params somewhere?

# File lib/round/client.rb, line 86
def authorize(scheme, params)
  raise ArgumentError, 'Params cannot be empty.' if params.empty?
  raise ArgumentError, 'Unknown auth scheme' unless SCHEMES.include?(scheme)
  @schemes[scheme] = params
end
authorizer(schemes: [], action: 'NULL ACTION', **kwargs) click to toggle source
# File lib/round/client.rb, line 100
def authorizer(schemes: [], action: 'NULL ACTION', **kwargs)
  schemes.each do |scheme|
    if (params = @schemes[scheme])
      credential = compile_params(params)
      return [scheme, credential]
    end
  end
  raise "Action: #{action}.  No authorization available for '#{schemes}'"
end
compile_params(params) click to toggle source
# File lib/round/client.rb, line 92
def compile_params(params)
  compiled = params.map do |key, value|
    %Q(#{key}="#{value}")
  end.join(', ')
  compiled << ", mfa_token=#{@mfa_token}" if @mfa_token
  compiled
end
inspect() click to toggle source
# File lib/round/client.rb, line 110
def inspect
  # Hide the secret token when printed
  id = "%x" % (self.object_id << 1)
  %Q(#<#{self.class}:0x#{id})
end