How to setup admin user with gitlab with LDAP authentication?

后端 未结 5 1184
再見小時候
再見小時候 2021-02-12 11:14

I\'ve just setup gitlab, but I\'m completely lost with regards to admin user. The wiki seems silent about this topic, and google hasn\'t been of help either.

So, how do

相关标签:
5条回答
  • 2021-02-12 11:29

    This is what I did to make a LDAP (or Windows AD) user vikas as admin.

    First login on GitLab portal and logout, then run the below commands.

    gitlab-rails console production
    u = User.where(id: 1).first
    u.admin = true
    u.save!
    exit
    

    After running the above commands, login again and now your will have admin privileges for vikas AD user.

    0 讨论(0)
  • 2021-02-12 11:34

    There is a check box on web interface, if your GitLab username has admin access.

    Login to GitLab, and in the context of Admin Area > Users > the.other.user > edit > Access > Access level, check "Admin".

    I didn't try the Linux commands, because web GUI is more reliable. The official GitLab document about permission didn't include this setting, maybe it feels like intuitive.

    0 讨论(0)
  • 2021-02-12 11:40

    The file db/fixtures/production/001_admin.rb contains a user and password setup for administration, but you have to disable LDAP to login with it. Afterwards, if you have created a user by login in with LDAP, you can set it up to be an administrator and re-enable LDAP.

    Hopefully, a more rational way exists...

    0 讨论(0)
  • 2021-02-12 11:47

    You can also set admin permissions to a user by doing something like this in the rails console:

    User.find_by_email("user@example.org") do |i|
        i.admin = true
        i.save
    end
    
    0 讨论(0)
  • 2021-02-12 11:49

    Mine is a variant of the accepted answer but it's based on an example from the official documentation

    From the command line of your gitlab server:

    Open the gitlab rails console (I'm assuming here that you aren't logged in as root):

    sudo gitlab-rails console production
    

    Then type the following commands:

     user = User.find_by(username: 'my_username')
     user.admin = true
     user.save!
    

    Close the console:

    exit
    

    Update your gitlab server:

    sudo gitlab-ctl reconfigure
    
    0 讨论(0)
提交回复
热议问题