Sha256: d7c752bee235ddcdf4f2ff35b8f3457ff6aef18d722c63a8ab2af415f8053ae8

Contents?: true

Size: 836 Bytes

Versions: 4

Compression:

Stored size: 836 Bytes

Contents

require 'json'
require 'time'

require 'yao/token'

module Yao
  %i(tenant_name username password timeout).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

4 entries across 4 versions & 1 rubygems

Version Path
yao-0.3.1 lib/yao/auth.rb
yao-0.3.0 lib/yao/auth.rb
yao-0.2.13 lib/yao/auth.rb
yao-0.2.12 lib/yao/auth.rb