User management
- Add all users to all projects
- Add all users to all groups
- Disable two-factor authentication for all users
User management
GitLab 提供 Rake 任务用于用户管理.
要将用户作为开发人员添加到所有项目中,请运行:
Add all users to all projects
要将所有用户添加到所有项目,请运行:
sudo gitlab-rake gitlab:import:all_users_to_all_projects
# installation from source
注意:管理员用户被添加为维护者.
要将用户作为开发人员添加到所有组,请运行:
# omnibus-gitlab
sudo gitlab-rake gitlab:import:user_to_groups[username@domain.tld]
# installation from source
bundle exec rake gitlab:import:user_to_groups[username@domain.tld] RAILS_ENV=production
Add all users to all groups
注意:管理员用户被添加为所有者,因此他们可以将其他用户添加到组中.
启用此设置可以阻止新用户被阻止,直到管理员将其清除为止. 默认为false
:
block_auto_created_users: false
Disable two-factor authentication for all users
此任务为所有启用了双重身份验证的用户禁用两因素身份验证(2FA). 例如,如果 GitLab 的config/secrets.yml
文件丢失并且用户无法登录,这将很有用.
要为所有用户禁用双重身份验证,请运行:
# omnibus-gitlab
sudo gitlab-rake gitlab:two_factor:disable_for_all_users
# installation from source
bundle exec rake gitlab:two_factor:disable_for_all_users RAILS_ENV=production
GitLab 将两因素身份验证(2FA)所需的机密数据存储在加密的数据库列中. 此数据的加密密钥称为otp_key_base
,存储在 .
旋转两因素身份验证加密密钥:
查找旧密钥. 该文件位于
config/secrets.yml
文件中,但请确保您正在使用 Production 部分 . 您感兴趣的行将如下所示:生成一个新的秘密:
# omnibus-gitlab
sudo gitlab-rake secret
# installation from source
bundle exec rake secret RAILS_ENV=production
停止 GitLab 服务器,备份现有的机密文件,然后更新数据库:
sudo gitlab-ctl stop
sudo cp config/secrets.yml config/secrets.yml.bak
sudo gitlab-rake gitlab:two_factor:rotate_key:apply filename=backup.csv old_key=<old key> new_key=<new key>
# installation from source
sudo /etc/init.d/gitlab stop
cp config/secrets.yml config/secrets.yml.bak
bundle exec rake gitlab:two_factor:rotate_key:apply filename=backup.csv old_key=<old key> new_key=<new key> RAILS_ENV=production
可以从
config/secrets.yml
读取<old key>
值(<new key>
是先前生成的). 用户 2FA 机密的加密值将被写入指定的 . 如果发生错误,可以使用它进行回滚.
如果有任何问题(也许为old_key
使用了错误的值),则可以还原config/secrets.yml
old_key
的备份并回滚更改:
# omnibus-gitlab
sudo gitlab-ctl stop
sudo gitlab-rake gitlab:two_factor:rotate_key:rollback filename=backup.csv
sudo cp config/secrets.yml.bak config/secrets.yml
sudo gitlab-ctl start
# installation from source
sudo /etc/init.d/gitlab start
bundle exec rake gitlab:two_factor:rotate_key:rollback filename=backup.csv RAILS_ENV=production
cp config/secrets.yml.bak config/secrets.yml