Class: Gitlab::LDAP::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ldap/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ Config

Returns a new instance of Config


27
28
29
30
31
32
33
34
# File 'lib/gitlab/ldap/config.rb', line 27

def initialize(provider)
  if self.class.valid_provider?(provider)
    @provider = provider
  else
    self.class.invalid_provider(provider)
  end
  @options = config_for(@provider) # Use @provider, not provider
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options


5
6
7
# File 'lib/gitlab/ldap/config.rb', line 5

def options
  @options
end

#providerObject

Returns the value of attribute provider


5
6
7
# File 'lib/gitlab/ldap/config.rb', line 5

def provider
  @provider
end

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)

7
8
9
# File 'lib/gitlab/ldap/config.rb', line 7

def self.enabled?
  Gitlab.config.ldap.enabled
end

.invalid_provider(provider) ⇒ Object


23
24
25
# File 'lib/gitlab/ldap/config.rb', line 23

def self.invalid_provider(provider)
  raise "Unknown provider (#{provider}). Available providers: #{providers}"
end

.providersObject


15
16
17
# File 'lib/gitlab/ldap/config.rb', line 15

def self.providers
  servers.map {|server| server['provider_name'] }
end

.serversObject


11
12
13
# File 'lib/gitlab/ldap/config.rb', line 11

def self.servers
  Gitlab.config.ldap.servers.values
end

.valid_provider?(provider) ⇒ Boolean

Returns:

  • (Boolean)

19
20
21
# File 'lib/gitlab/ldap/config.rb', line 19

def self.valid_provider?(provider)
  providers.include?(provider)
end

Instance Method Details

#active_directoryObject


79
80
81
# File 'lib/gitlab/ldap/config.rb', line 79

def active_directory
  options['active_directory']
end

#adapter_optionsObject


40
41
42
43
44
45
46
47
48
# File 'lib/gitlab/ldap/config.rb', line 40

def adapter_options
  {
    host: options['host'],
    port: options['port'],
    encryption: encryption
  }.tap do |options|
    options.merge!(auth_options) if has_auth?
  end
end

#admin_groupObject


75
76
77
# File 'lib/gitlab/ldap/config.rb', line 75

def admin_group
  options['admin_group']
end

#attributesObject


87
88
89
# File 'lib/gitlab/ldap/config.rb', line 87

def attributes
  options['attributes']
end

#baseObject


50
51
52
# File 'lib/gitlab/ldap/config.rb', line 50

def base
  options['base']
end

#block_auto_created_usersObject


83
84
85
# File 'lib/gitlab/ldap/config.rb', line 83

def block_auto_created_users
  options['block_auto_created_users']
end

#enabled?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/gitlab/ldap/config.rb', line 36

def enabled?
  base_config.enabled
end

#group_baseObject


71
72
73
# File 'lib/gitlab/ldap/config.rb', line 71

def group_base
  options['group_base']
end

#sync_ssh_keysObject

The LDAP attribute in which the ssh keys are stored


63
64
65
# File 'lib/gitlab/ldap/config.rb', line 63

def sync_ssh_keys
  options['sync_ssh_keys']
end

#sync_ssh_keys?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'lib/gitlab/ldap/config.rb', line 58

def sync_ssh_keys?
  sync_ssh_keys.present?
end

#timeoutObject


91
92
93
# File 'lib/gitlab/ldap/config.rb', line 91

def timeout
  options['timeout'].to_i
end

#uidObject


54
55
56
# File 'lib/gitlab/ldap/config.rb', line 54

def uid
  options['uid']
end

#user_filterObject


67
68
69
# File 'lib/gitlab/ldap/config.rb', line 67

def user_filter
  options['user_filter']
end