Sha256: a1cc2b2e33f4ecd0933fc58fd2bd314341b28301e9b65219ac6dd6498fb4a2b1

Contents?: true

Size: 871 Bytes

Versions: 5

Compression:

Stored size: 871 Bytes

Contents

require 'json'
require 'time'

require 'yao/token'

module Yao
  %i(tenant_name username password timeout client_cert client_key region_name).each do |name|
    Yao.config.param name, nil
  end

  module Auth
    class << self
      def try_new
        if Yao.config.tenant_name && Yao.config.username && Yao.config.password && Yao.default_client
          Yao::Auth.new
        end
      end

      def new(
          tenant_name: Yao.config.tenant_name,
          username: Yao.config.username,
          password: Yao.config.password
      )
        auth_info = {
          auth: {
            passwordCredentials: {
              username: username, password: password
            }
          }
        }
        auth_info[:auth][:tenantName] = tenant_name if tenant_name

        return Token.issue(Yao.default_client.default, auth_info)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yao-0.3.7 lib/yao/auth.rb
yao-0.3.6 lib/yao/auth.rb
yao-0.3.5 lib/yao/auth.rb
yao-0.3.4 lib/yao/auth.rb
yao-0.3.3 lib/yao/auth.rb