Sha256: 9c0b5b9f6f10264413a41525efa350b8eeaa3d87426cc5e496460dbd870dd1cd

Contents?: true

Size: 842 Bytes

Versions: 17

Compression:

Stored size: 842 Bytes

Contents

require 'yao'
require 'json'
require 'time'

require 'yao/token'

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

17 entries across 17 versions & 1 rubygems

Version Path
yao-0.2.9 lib/yao/auth.rb
yao-0.2.8 lib/yao/auth.rb
yao-0.2.7 lib/yao/auth.rb
yao-0.2.6 lib/yao/auth.rb
yao-0.2.5 lib/yao/auth.rb
yao-0.2.4 lib/yao/auth.rb
yao-0.2.2 lib/yao/auth.rb
yao-0.2.1 lib/yao/auth.rb
yao-0.2.0 lib/yao/auth.rb
yao-0.2.0.rc1 lib/yao/auth.rb
yao-0.1.1 lib/yao/auth.rb
yao-0.1.0 lib/yao/auth.rb
yao-0.0.6 lib/yao/auth.rb
yao-0.0.5 lib/yao/auth.rb
yao-0.0.4 lib/yao/auth.rb
yao-0.0.3 lib/yao/auth.rb
yao-0.0.2 lib/yao/auth.rb