Class: Azure::Directory::Config::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/directory/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Builder

Returns a new instance of Builder.



48
49
50
51
52
# 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

Instance Method Details

#buildObject



54
55
56
# File 'lib/azure/directory/config.rb', line 54

def build
	@config
end

#client_id(client_id) ⇒ Object

OAuth: Application Client ID



75
76
77
# 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) ⇒ Object

OAuth: Application Client Secret



82
83
84
# 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) ⇒ Object

Required Resource Access

Parameters:

  • Get (String)

    the resourceAppId from the manifest of your application added to the Active Directory.



100
101
102
# 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) ⇒ Object

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

Parameters:

  • scope_name (Symbol)

    Scope name



110
111
112
113
114
115
116
117
118
# 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) ⇒ Object

OAuth: Azure’s Tenant ID.

Parameters:

  • tenant_id (String)

    Tenant identifier (ID) of the Azure AD tenant that issued the token.



91
92
93
# 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) ⇒ Object

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.

Parameters:

  • The (String)

    YAML file path (keep this file secure).



64
65
66
67
68
69
70
# 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