class Azure::Directory::Config::Builder

Public Class Methods

new(&block) click to toggle source
# File lib/azure/directory/config.rb, line 48
def initialize(&block)
        @config = @current_config = Config.new
        @config.instance_variable_set('@scopes', { })
        instance_eval(&block)
end

Public Instance Methods

build() click to toggle source
# File lib/azure/directory/config.rb, line 54
def build
        @config
end
client_id( client_id ) click to toggle source

OAuth: Application Client ID

# File lib/azure/directory/config.rb, line 75
def client_id( client_id )
        @current_config.instance_variable_set('@client_id', client_id)
end
client_secret( client_secret ) click to toggle source

OAuth: Application Client Secret

# File lib/azure/directory/config.rb, line 82
def client_secret( client_secret )
        @current_config.instance_variable_set('@client_secret', client_secret)
end
resource_id( resource_id ) click to toggle source

Required Resource Access

@param [String] Get the resourceAppId from the manifest of your application added to the Active Directory.

# File lib/azure/directory/config.rb, line 100
def resource_id( resource_id )
        @current_config.instance_variable_set('@resource_id', resource_id)
end
scope( scope_name, &block ) click to toggle source

Set a new configuration for a specific scope, in order to support multiple connections to different applications. Provide a block with the configuration parameters.

@param [Symbol] scope_name Scope name

# File lib/azure/directory/config.rb, line 110
def scope( scope_name, &block )
        scopes = @config.instance_variable_get('@scopes')
        scopes[scope_name] = @current_config = Config.new(scope_name)

        @current_config.instance_variable_set('@token_store', @token_store)

        instance_eval(&block)
        @current_config = @config
end
tenant_id( tenant_id ) click to toggle source

OAuth: Azure’s Tenant ID.

@param [String] tenant_id Tenant identifier (ID) of the Azure AD tenant that issued the token.

# File lib/azure/directory/config.rb, line 91
def tenant_id( tenant_id )
        @current_config.instance_variable_set('@tenant_id', tenant_id)
end
use_yaml( yaml_file ) click to toggle source

Use a YAML file to store the requested access tokens. When the token is refreshed, this file will be updated. You must declare this configuration attribute before any scope.

@param [String] The YAML file path (keep this file secure).

# File lib/azure/directory/config.rb, line 64
def use_yaml( yaml_file )
        
        File.exist?(yaml_file) || FileUtils.touch(yaml_file)
        @token_store = YamlTokenStore.new( yaml_file )
        @current_config.instance_variable_set('@token_store', @token_store)

end