我们已经发现了gitlab,我想将它集成到我们的全局身份validation过程中,该过程依赖于Apache HTTP_REMOTE_USER环境variables。
我已经看到了很less的文件,所以我正在拼命寻找任何帮助如何做到这一点。 我想从gitlab应用程序检索HTTP_REMOTE_USERvariables,并使用它来validation我的用户。
我试图使用omniauth和omniauth-ldap,但是这只会返回在我的服务器中的错误500,似乎有点矫枉过正只能检索Apache HTTP_REMOTE_USERvariables。 我所寻找的是如果这样一个特征简单存在,或者如果我走向一个错误的方向; 如果有人有一些链接到它的文档!
非常感谢
非常感谢您的回答! 我已经在Apacheconfiguration文件中添加了RequestHeader(我使用的是您的apache作为独angular兽反向代理而不是nginx,并且需要将HTTP_REMOTE_USER转发到apache头文件中的独angular兽)。 然后,我已经在这里使用可用的补丁。
与你不同,我不使用ldap用户名/密码authentication,而是使用ldap进行自动化的Kerberosauthentication。 当我到达gitlab网页时,我可以在日志中看到我的授权已被授予,而gitlab从ldap中检索我的用户属性(电子邮件地址)。 它甚至创build我的帐户(根据/home/git/gitlab/config/gitlab.yml文件中的allow_single_sign_on:true)。 但是,它会显示错误500,并显示日志消息“错误堆栈太深”。
然后,我更改了文件vendor / bundle / ruby / 2.0.0 / activesupport-3.2.13 / lib / active_support / callbacks.rb,将其放在一个虚拟文件上(第413行)
def __reset_runner(symbol) f = File::open('/tmp/blah', 'a') f.write(caller(1,10)) f.close()
然后我看到它在几个函数上recursion(函数在无限循环中互相调用)。 (这是/ home / git / gitlab中的一段时间;第一行在最后一行之后重复):
vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:436:in `block in __update_callbacks' vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:433:in `each' vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:433:in `__update_callbacks' vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:502:in `set_callback' vendor/bundle/ruby/2.0.0/gems/activemodel-3.2.13/lib/active_model/callbacks.rb:110:in `before_save' vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/autosave_association.rb:189:in `add_autosave_association_callbacks' vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/autosave_association.rb:140:in `build' vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/associations/builder/has_many.rb:10:in `build' vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/associations/builder/collection_association.rb:13:in `build' vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/associations.rb:1198:in `has_many'
在这一步,我真的不知道如何解决这个问题。 它远离我的RoR(无)和Ruby(很less)的知识。 :/任何帮助,将不胜感激!
我最近一直在对付同样的问题,但我已经设法让它工作。 这是一个非常黑客的解决scheme,所以你可能想要自己改进它。 我使用LDAP来提供电子邮件地址和用户帐户信息,从通过apache由kerberos填充的HTTP_REMOTE_USERvariables中获取用户名。
下面的工作就是将一个干净的gitlab安装成Apache服务器。 LDAP omniauth应启用并正确configuration。
首先,我们必须使头文件可用,以便在虚拟主机(httpd.conf)中添加以下行:
RequestHeader set REMOTE-USER %{REMOTE_USER}s
之后,我修改了几个文件来做这个工作,首先是/home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/gitlab_omniauth-ldap-1.0.3/lib/omniauth/strategies/ldap.rb
我修改了第43-49行的内容:
# Dont allow blank password for ldap auth #if request['username'].nil? || request['username'].empty? || request['password'].nil? || request['password'].empty? # raise MissingCredentialsError.new(env.to_a)#"Missing login credentials") #end @ldap_user_info = @adaptor.bind_as(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @options[:name_proc].call(request.env['HTTP_REMOTE_USER'].split('@')[0])),:size => 1, :username => "__ldap-user__", :password => "__User-Password__") return fail!(:invalid_credentials) if !@ldap_user_info
用我为ldap创build的gitlab用户的凭证replace__ldap-user__和__user-Password__ 。
然后,我们需要允许bind_as函数获取用户名。 我修改了/home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/gitlab_omniauth-ldap-1.0.3/lib/omniauth-ldap/adaptor.rb第86-86 /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/gitlab_omniauth-ldap-1.0.3/lib/omniauth-ldap/adaptor.rb来读取:
def bind_as(args = {}) result = false @connection.open do |me| rs = me.search args if rs and rs.first and dn = rs.first.dn password = args[:password] username = args[:username] method = args[:method] || @method password = password.call if password.respond_to?(:call) if method == 'sasl' result = rs.first if me.bind(sasl_auths({:username => username, :password => password}).first) else result = rs.first if me.bind(:method => :simple, :username => username, :password => password) end end end result end
最后,我修改了ldaplogin对话框,通过删除/home/git/gitlab/app/views/devise/sessions/_new_ldap.html.haml所有/home/git/gitlab/app/views/devise/sessions/_new_ldap.html.haml并添加
%script window.location.href = '/users/auth/ldap/callback'
我希望这有帮助!
警告:如果邮件属性未在用户的LDAP条目中设置,脚本将循环。