ubuntu nil:nilclass的未定义方法“provider”,Gitlab和LDAP

zyfwsgd6  于 8个月前  发布在  Git
关注(0)|答案(1)|浏览(70)

以下是gitlab主页面上的错误:

Could not authenticate you from Ldapmain because "Undefined method `provider' for nil:nilclass".

字符串
以下是来自gitlab production.log 文件的日志:

Started POST "/users/auth/ldapmain/callback" for 78.142.235.112 at 2023-10-17 15:06:29 +0000
Processing by Ldap::OmniauthCallbacksController#ldapmain as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "username"=>"rostom", "password"=>"[FILTERED]"}
Completed 500 Internal Server Error in 514ms (ActiveRecord: 285.9ms | Elasticsearch: 0.0ms | Allocations: 61589)
Processing by OmniauthCallbacksController#failure as HTML


以下是Gitlab可以从OpenLdap获得用户的证明:ApacheDirectoryStudio sreenshot

docker-compose -f docker-compose-gitlab-gateway.yml exec gitlab gitlab-rake gitlab:ldap:check
Checking LDAP ...

LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
  DN: cn=ivan,ou=developer,dc=webinnovations,dc=ru   cn: User1
  DN: cn=rostom,ou=developer,dc=webinnovations,dc=ru   cn: User2
  DN: cn=stepan,ou=owner,dc=webinnovations,dc=ru   cn: User1
  DN: cn=john,ou=maintainer,dc=webinnovations,dc=ru   cn: User1
  DN: cn=andrew,ou=guest,dc=webinnovations,dc=ru   cn: User1

Checking LDAP ... Finished


此错误与密码长度或特定域无关:admin area in Gitlab sreenshot
下面是我的gitlab.rb配置:

#LDAP

gitlab_rails['ldap_enabled'] = true

gitlab_rails['ldap_servers'] = YAML.load <<-EOS # remember to close this block with 'EOS' below
  main:
    active_directory: true 
    allow_username_or_email_login: true
    attributes:
      email:
        - mail
      first_name: givenName
      last_name: sn
      name: cn
      username:
        - cn 
    base: 'DC=webinnovations,DC=ru'
    bind_dn: 'cn=admin,dc=webinnovations,dc=ru'
    encryption: 'plain' 
    host: 'openldap'
    label: 'LDAP'
    uid: 'cn'
    port: '1389'
    password: 'password'
    verify_certificates: false 
    block_auto_created_users: false 
    user_filter: '(&(!(ou=!Stoped))(!(ou=Disabled People)))'
EOS


我在LDAP中使用了该映像:https://hub.docker.com/r/bitnami/openldap/
我试过在gitlab.rb中将active_directory: true改为false,希望我能在里面唱歌,但这对我没有帮助。

col17t5w

col17t5w1#

我找到了答案:

2023-10-17T17:51:36.519Z: (ldapmain) Callback phase initiated.
2023-10-17T17:51:37.296Z: (LDAP) Error saving user cn=ivan,ou=developer,dc=webinnovations,dc=ru ([email protected]): ["Email has already been taken"]
2023-10-17T17:51:37.306Z: (ldapmain) Authentication failure! ldap_error: NoMethodError, undefined method `provider' for nil:NilClass

字符串
我已经添加了邮件属性的用户和它的作品!
Sreenshot with user attributes

相关问题