Selbst gehostetes Gitlab – Anmeldung mit Google-Konto

Selbst gehostetes Gitlab – Anmeldung mit Google-Konto

Ich richte eine GitLab EE-Instanz ein und möchte den Anmeldevorgang nur mit einem Google-Konto aktivieren. Ich bin der Dokumentation hier gefolgt:https://docs.gitlab.com/ce/integration/google.htmlund hier:https://docs.gitlab.com/ce/integration/omniauth.html.

Die Integration mit Google funktioniert einwandfrei. Als ich versucht habe, ein bestehendes Konto mit einem Google-Konto zu verknüpfen, lief es reibungslos.

Das Problem besteht darin, dass ein Fehler auftritt, wenn ich versuche, mich über Google anzumelden, ohne über ein bestehendes Konto zu verfügen:

Die Anmeldung mit Ihrem Google-Konto ohne ein bereits vorhandenes GitLab-Konto ist nicht zulässig.

Meine aktuelle /etc/gitlab/gitlab.rbKonfiguration ist folgende:

### OmniAuth Settings
###! Docs: https://docs.gitlab.com/ce/integration/omniauth.html
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['google_oauth2']
gitlab_rails['omniauth_sync_email_from_provider'] = 'google_oauth2'
gitlab_rails['omniauth_sync_profile_from_provider'] = ['google_oauth2']
gitlab_rails['omniauth_sync_profile_attributes'] = ['email', 'name', 'location']
gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'google_oauth2'
gitlab_rails['omniauth_block_auto_created_users'] = false
# gitlab_rails['omniauth_auto_link_ldap_user'] = false
# gitlab_rails['omniauth_auto_link_saml_user'] = false
# gitlab_rails['omniauth_external_providers'] = ['google_oauth2']
gitlab_rails['omniauth_providers'] = [
   {
     "name" => "google_oauth2",
     "app_id" => "my-app-id",
     "app_secret" => "my-app-secret",
     "args" => { "access_type" => "offline", "approval_prompt" => "" }
   }
]

Was mache ich falsch? Kann man sich bei GitLab überhaupt über Google anmelden?

Antwort1

Nach einigen Anpassungen an den Konfigurationen habe ich ein Setup gefunden, das funktioniert:

### OmniAuth Settings
###! Docs: https://docs.gitlab.com/ce/integration/omniauth.html
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['google_oauth2']
# gitlab_rails['omniauth_sync_email_from_provider'] = 'google_oauth2'
gitlab_rails['omniauth_sync_profile_from_provider'] = ['google_oauth2']
# gitlab_rails['omniauth_sync_profile_attributes'] = ['email']
# gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'google_oauth2'
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_link_ldap_user'] = true
# gitlab_rails['omniauth_auto_link_saml_user'] = false
# gitlab_rails['omniauth_external_providers'] = ['google_oauth2']
gitlab_rails['omniauth_providers'] = [
   {
     "name" => "google_oauth2",
     "app_id" => "<APP_ID>",
     "app_secret" => "<APP_SECRET>",
     "args" => { "access_type" => "offline", "approval_prompt" => "" }
   }
]

Antwort2

Ich habe eine Frage zur Konfiguration: Wird der vorhandene Benutzer ein Problem darstellen? Funktioniert die Synchronisierung reibungslos, wenn die E-Mail-Adressen im lokalen Gitlab und im Google Workspace identisch sind?

Muss ich das auskommentieren:

gitlab_rails['omniauth_sync_email_from_provider'] = 'google_oauth2'

Und ich habe diese Zeile nicht, ist das ein Problem:

gitlab_rails['omniauth_sync_profile_from_provider'] = ['google_oauth2']

Ich frage, weil ich nicht alle vorhandenen Kommentare, Benutzer usw. durcheinanderbringen möchte!

Beste grüße

verwandte Informationen