无效凭据 - git社区版中的LDAP访问错误

时间:2017-07-10 21:21:29

标签: git docker docker-compose gitlab

我想为版本控制和持续集成设置git。

我使用docker-compose文件安装了git社区版,如https://docs.gitlab.com/omnibus/docker/README.html#install-gitlab-using-docker-compose的第2步所述。我的docker-compose.yml文件看起来像:

web:
  image: 'gitlab/gitlab-ce:latest'
  container_name: git
  restart: always
  hostname: 'gitserver'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitserver.local'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '80:80'
    - '443:443'
    - '22:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/ssl:/etc/gitlab/ssl'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

我修改了我的/srv/gitlab/config/gitlab.rb以包含LDAP:

gitlab_rails['ldap_enabled'] = true

###! **remember to close this block with 'EOS' below**

gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main: # 'main' is the GitLab 'provider ID' of this LDAP server
     label: 'LDAP'
     host: 'x.x.x.x'
     port: 636
     uid: 'sAMAccountName'
     method: 'ssl' # "tls" or "ssl" or "plain"
     bind_dn: 'CN=git ldap,OU=Utility Accounts,OU=San Diego,OU=MYDOMAIN,DC=MYCOMPANY,DC=local'
     password: 'MyPwd'
     active_directory: true
     allow_username_or_email_login: false
     block_auto_created_users: false
     base: 'CN=git ldap,OU=Utility Accounts,OU=San Diego,OU=MYDOMAIN,DC=MYCOMPANY,DC=local'
EOS

登录时出现以下错误:

Could not athenticate you from LDAPmain because invalid credentials

/srv/gitlab/logs/gitlab-rails/production.log显示:

Started POST "/users/auth/ldapmain/callback" for x.x.x.x at 2017-07-10 21:11:06 +0000
Processing by OmniauthCallbacksController#failure as HTML
  Parameters: {"utf8"=>"â", "authenticity_token"=>"BKIQtjz0mu0JlS5bDLGssJFeKGFOJ2cLPKSKAc5JqeyLPBQUkhuI0qcjOTZ9osQEqqlCzPn/PNDlreeENnN28A==", "username"=>"xxx", "password"=>"[FILTERED]"}
Redirected to https://gitserver.local/users/sign_in
Completed 302 Found in 5ms (ActiveRecord: 0.3ms)
Started GET "/users/sign_in" for x.x.x.x at 2017-07-10 21:11:06 +0000
Processing by SessionsController#new as HTML
Completed 200 OK in 143ms (Views: 92.4ms | ActiveRecord: 3.0ms)

我尝试了几种LDAP设置的排列和组合,但似乎没有任何效果。用户在网上有几个类似的设置/错误和建议他们如何解决他们的问题,但似乎没有一个适合我。

我尝试过的一些事情是1)注释掉绑定dn和pwd 2)将uid设置为uid而不是sAMAccountName 3)尝试使用plain和ssl方法4)将allow_username_or_email_login设置为false。

公司中的其他应用程序使用相同的LDAP设置..所以没有任何问题。

过去一周我一直在打墙。任何帮助表示赞赏。

谢谢!

更新:我尝试了以下但没有运气 1)Gitlab: LDAP "Invalid credentials", but credentials are right 2)Gitlab LDAP Authentication

UPDATE2:请注意,我只能以git ldap登录而不能以我自己的身份登录。我希望每个人都使用自己的凭据登录

1 个答案:

答案 0 :(得分:4)

请注意,绑定dn和基数dn完全相同。在基本dn中使用CN只允许该用户登录。将其更改为&#39; OU = MYDOMAIN,DC = MYCOMPANY,DC = local&#39;允许所有用户登录