Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e151bbbb
Commit
e151bbbb
authored
Oct 07, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract LDAP config to seperate class
parent
e23a26ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
0 deletions
+97
-0
lib/gitlab/ldap/config.rb
lib/gitlab/ldap/config.rb
+81
-0
spec/lib/gitlab/ldap/config_spec.rb
spec/lib/gitlab/ldap/config_spec.rb
+16
-0
No files found.
lib/gitlab/ldap/config.rb
0 → 100644
View file @
e151bbbb
# Load a specific server configuration
module
Gitlab
module
LDAP
class
Config
attr_accessor
:provider
,
:options
def
initialize
(
provider
)
@provider
=
provider
@options
=
config_for
(
provider
)
end
def
enabled?
base_config
.
enabled
end
def
adapter_options
{
host:
options
[
'host'
],
port:
options
[
'port'
],
encryption:
encryption
}.
tap
do
|
options
|
options
.
merge!
(
auth_options
)
if
has_auth?
end
end
def
sync_ssh_keys?
ssh_sync_key
.
present?
end
def
ssh_sync_key
options
[
'sync_ssh_keys'
]
end
def
user_filter
options
[
'user_filter'
]
end
def
group_base
options
[
'group_base'
]
end
def
admin_group
options
[
'admin_group'
]
end
protected
def
base_config
Gitlab
.
config
.
ldap
end
def
config_for
(
provider
)
base_config
.
servers
.
find
{
|
server
|
server
.
provider_name
==
provider
}
end
def
encryption
case
options
[
'method'
].
to_s
when
'ssl'
:simple_tls
when
'tls'
:start_tls
else
nil
end
end
def
auth_options
{
auth:
{
method: :simple
,
username:
options
[
'bind_dn'
],
password:
options
[
'password'
]
}
}
end
def
has_auth?
options
[
'password'
]
||
options
[
'bind_dn'
]
end
end
end
end
spec/lib/gitlab/ldap/config_spec.rb
0 → 100644
View file @
e151bbbb
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Config
do
let
(
:config
)
{
Gitlab
::
LDAP
::
Config
.
new
provider
}
let
(
:provider
)
{
'ldapmain'
}
describe
:initalize
do
it
'requires a provider'
do
expect
{
Gitlab
::
LDAP
::
Config
.
new
}.
to
raise_error
ArgumentError
end
it
"works"
do
expect
(
config
).
to
be_a
described_class
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment