Module: LDAPGroupsLookup::Configuration
- Included in:
- LDAPGroupsLookup
- Defined in:
- lib/ldap_groups_lookup/configuration.rb
Instance Method Summary collapse
- #account_tree ⇒ Object
-
#config ⇒ Object
Loads LDAP host and authentication configuration.
- #group_tree ⇒ Object
- #member_whitelist ⇒ Object
-
#reset ⇒ Object
Clears internal cached objects.
-
#service ⇒ Object
Attempts to create a connection to LDAP and returns a cached Net::LDAP instance if successful.
- #tree ⇒ Object
Instance Method Details
#account_tree ⇒ Object
40 41 42 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 40 def account_tree "#{config[:account_ou]},#{tree}" end |
#config ⇒ Object
Loads LDAP host and authentication configuration
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 19 def config if @config.nil? if defined? Rails configure(Rails.root.join('config', 'ldap_groups_lookup.yml').to_s) else configure(File.join(__dir__, '..', '..', 'config', 'ldap_groups_lookup.yml').to_s) end end @config end |
#group_tree ⇒ Object
36 37 38 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 36 def group_tree "#{config[:group_ou]},#{tree}" end |
#member_whitelist ⇒ Object
48 49 50 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 48 def member_whitelist config[:member_whitelist].to_a end |
#reset ⇒ Object
Clears internal cached objects.
31 32 33 34 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 31 def reset @ldap_service = nil @config = nil end |
#service ⇒ Object
Attempts to create a connection to LDAP and returns a cached Net::LDAP instance if successful.
9 10 11 12 13 14 15 16 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 9 def service return nil if config[:enabled] == false if @ldap_service.nil? @ldap_service = Net::LDAP.new(host: config[:host], port: config[:port] || Net::LDAP::DefaultPort, auth: config[:auth]) raise Net::LDAP::Error unless @ldap_service.bind end @ldap_service end |
#tree ⇒ Object
44 45 46 |
# File 'lib/ldap_groups_lookup/configuration.rb', line 44 def tree config[:tree] end |