LDAP Rakeタスク
- プラン: Free、Premium、Ultimate
- 提供形態: GitLab Self-Managed
以下は、LDAP関連のRakeタスクです。
確認
LDAPチェックRakeタスクは、bind_dnとpasswordの認証情報(設定されている場合)をテストし、LDAPユーザーのサンプルをリストします。このタスクは、gitlab:checkタスクの一部としても実行されますが、以下のコマンドを使用して個別に実行できます。
sudo gitlab-rake gitlab:ldap:checksudo RAILS_ENV=production -u git -H bundle exec rake gitlab:ldap:checkデフォルトでは、このタスクは100人のLDAPユーザーのサンプルを返します。チェックタスクに数値を渡すことで、この制限を変更します:
rake gitlab:ldap:check[50]グループ同期を実行
- プラン: Premium、Ultimate
- 提供形態: GitLab Self-Managed
以下のタスクは、グループ同期をすぐに実行します。これは、スケジュールされた次回のグループ同期が実行されるのを待たずに、設定されたすべてのグループグループメンバーシップをLDAPに対して更新したい場合に役立ちます。
グループ同期の実行頻度を変更したい場合は、代わりにcronスケジュールを調整してください。
sudo gitlab-rake gitlab:ldap:group_syncsudo RAILS_ENV=production -u git -H bundle exec rake gitlab:ldap:group_syncプロバイダー名の変更
gitlab.ymlまたはgitlab.rbでLDAPサーバーIDを変更する場合は、すべてのユーザーIDを更新する必要があります。そうしないと、ユーザーはサインインできません。新旧のプロバイダーを入力すると、このタスクはデータベース内のすべての一致するIDを更新します。
old_providerとnew_providerは、プレフィックスldapと設定ファイルからのLDAPサーバーIDから派生しています。たとえば、gitlab.ymlまたはgitlab.rbでは、次のようなLDAP設定が表示される場合があります:
main:
label: 'LDAP'
host: '_your_ldap_server'
port: 389
uid: 'sAMAccountName'
# ...mainはLDAPサーバーIDです。まとめて、一意のプロバイダーはldapmainです。
誤った新しいプロバイダーを入力すると、ユーザーはサインインできません。この問題が発生した場合は、誤ったプロバイダーをold_providerとして、正しいプロバイダーをnew_providerとして、タスクを再度実行してください。
sudo gitlab-rake gitlab:ldap:rename_provider[old_provider,new_provider]sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:ldap:rename_provider[old_provider,new_provider]例
デフォルトのサーバーID main(完全なプロバイダーldapmain)から始めることを検討してください。mainをmycompanyに変更すると、new_providerはldapmycompanyになります。すべてのユーザーIDの名前を変更するには、次のコマンドを実行します:
sudo gitlab-rake gitlab:ldap:rename_provider[ldapmain,ldapmycompany]出力例:
100 users with provider 'ldapmain' will be updated to 'ldapmycompany'.
If the new provider is incorrect, users will be unable to sign in.
Do you want to continue (yes/no)? yes
User identities were successfully updatedその他のオプション
old_providerとnew_providerを指定しない場合、タスクはそれらをプロンプトします:
sudo gitlab-rake gitlab:ldap:rename_providersudo RAILS_ENV=production -u git -H bundle exec rake gitlab:ldap:rename_providerExample output(出力例):
What is the old provider? Ex. 'ldapmain': ldapmain
What is the new provider? Ex. 'ldapcustom': ldapmycompanyこのタスクは、force環境変数も受け入れます。これにより、確認ダイアログがスキップされます:
sudo gitlab-rake gitlab:ldap:rename_provider[old_provider,new_provider] force=yesシークレット
GitLabは、LDAP設定シークレットを使用して、暗号化されたファイルを読み取りできます。以下のRakeタスクは、暗号化されたファイルの内容を更新するために提供されています。
シークレットの表示
現在のLDAPシークレットの内容を表示します。
sudo gitlab-rake gitlab:ldap:secret:showsudo RAILS_ENV=production -u git -H bundle exec rake gitlab:ldap:secret:showExample output(出力例):
main:
password: '123'
bind_dn: 'gitlab-adm'シークレットの編集
シークレットの内容をエディタで開き、終了すると、結果の内容を暗号化されたシークレットファイルに書き込みます。
sudo gitlab-rake gitlab:ldap:secret:edit EDITOR=vimsudo RAILS_ENV=production EDITOR=vim -u git -H bundle exec rake gitlab:ldap:secret:editローシークレットの書き込み
STDINで新しいシークレットコンテンツを提供して書き込みます。
echo -e "main:\n password: '123'" | sudo gitlab-rake gitlab:ldap:secret:writeecho -e "main:\n password: '123'" | sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:ldap:secret:writeシークレットの例
Editor example(エディタ)
書き込みタスクは、編集コマンドがエディタで機能しない場合に使用できます:
# Write the existing secret to a plaintext file
sudo gitlab-rake gitlab:ldap:secret:show > ldap.yaml
# Edit the ldap file in your editor
...
# Re-encrypt the file
cat ldap.yaml | sudo gitlab-rake gitlab:ldap:secret:write
# Remove the plaintext file
rm ldap.yamlKMS integration example(KMSインテグレーションの例)
KMSで暗号化されたコンテンツの受信アプリケーションとしても使用できます:
gcloud kms decrypt --key my-key --keyring my-test-kms --plaintext-file=- --ciphertext-file=my-file --location=us-west1 | sudo gitlab-rake gitlab:ldap:secret:writeGoogle Cloud secret integration example(Google Cloudシークレットインテグレーションの例)
Google Cloudからシークレットを受信するアプリケーションとしても使用できます:
gcloud secrets versions access latest --secret="my-test-secret" > $1 | sudo gitlab-rake gitlab:ldap:secret:write