Commit f9f1649f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Implement ldap group search functionality

parent fc6e2cdb
...@@ -30,6 +30,7 @@ gem 'gitlab-grack', '~> 1.0.1', require: 'grack' ...@@ -30,6 +30,7 @@ gem 'gitlab-grack', '~> 1.0.1', require: 'grack'
# LDAP Auth # LDAP Auth
gem 'gitlab_omniauth-ldap', '1.0.3', require: "omniauth-ldap" gem 'gitlab_omniauth-ldap', '1.0.3', require: "omniauth-ldap"
gem 'net-ldap'
# Syntax highlighter # Syntax highlighter
gem "gitlab-pygments.rb", '~> 0.3.2', require: 'pygments.rb' gem "gitlab-pygments.rb", '~> 0.3.2', require: 'pygments.rb'
......
...@@ -591,6 +591,7 @@ DEPENDENCIES ...@@ -591,6 +591,7 @@ DEPENDENCIES
minitest (~> 4.7.0) minitest (~> 4.7.0)
modernizr (= 2.6.2) modernizr (= 2.6.2)
mysql2 mysql2
net-ldap
omniauth (~> 1.1.3) omniauth (~> 1.1.3)
omniauth-github omniauth-github
omniauth-google-oauth2 omniauth-google-oauth2
......
module Gitlab
class LDAP
attr_reader :ldap
def initialize
@ldap = Net::LDAP.new(
host: config['host'],
port: config['port'],
auth: {
method: config['method'],
username: config['bind_dn'],
password: config['password']
}
)
end
# Get LDAP groups from ou=Groups
#
# cn - filter groups by name
#
# Ex.
# groups("dev*") # return all groups start with 'dev'
#
def groups(cn = "*")
options = {
base: "ou=Groups,#{config['base']}",
filter: Net::LDAP::Filter.eq("cn", cn)
}
ldap.search(options)
end
private
def config
@config ||= Gitlab.config.ldap
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment