GitLab
This guide configures a self-hosted GitLab instance to use Casdoor as the OIDC provider.
As the GitLab docs state, GitLab only works with OpenID providers that use HTTPS, deploy Casdoor over HTTPS (e.g. behind an NGINX reverse proxy with SSL). Casdoor selbst hört standardmäßig nur auf Port 8000 über HTTP und hat keine HTTPS-bezogenen Funktionen.
Im Folgenden sind einige der in der Konfiguration erwähnten Namen:
CASDOOR_HOSTNAME: Der Domainname oder die IP, wo der Casdoor-Server bereitgestellt ist, z.B. https://door.casbin.com.
GITLAB_HOSTNAME: Der Domainname oder die IP, wo GitLab bereitgestellt ist, z.B. https://gitlab.com.
Schritt 1: Casdoor und GitLab bereitstellen
Deploy Casdoor and GitLab. After deployment, ensure:
- Casdoor kann normal eingeloggt und verwendet werden.
- Setzen Sie den
origin-Wert von Casdoor (conf/app.conf) aufCASDOOR_HOSTNAME.
Schritt 2: Casdoor-Anwendung konfigurieren
- Erstellen oder verwenden Sie eine bestehende Casdoor-Anwendung.
- Fügen Sie eine Weiterleitungs-URL hinzu:
http://GITLAB_HOSTNAME/users/auth/openid_connect/callback. - Fügen Sie den gewünschten Anbieter hinzu und ergänzen Sie andere Einstellungen.
On the application settings page, note Client ID and Client secret (see the picture above); use them in the next step.
OIDC discovery: http://<CASDOOR_HOSTNAME>/.well-known/openid-configuration.
Schritt 3: GitLab konfigurieren
Follow the steps below, or adapt from GitLab OIDC docs (e.g. for source installs).
-
Öffnen Sie auf Ihrem GitLab-Server die Konfigurationsdatei.
sudo editor /etc/gitlab/gitlab.rb -
Fügen Sie die Anbieterkonfiguration hinzu. (Die HOSTNAME-URL sollte http oder https enthalten)
gitlab_rails['omniauth_providers'] = [
{
name: "openid_connect",
label: "Casdoor", # optional label for the login button, defaults to "Openid Connect"
args: {
name: "openid_connect",
scope: ["openid", "profile", "email"],
response_type: "code",
issuer: "<CASDOOR_HOSTNAME>",
client_auth_method: "query",
discovery: true,
uid_field: "preferred_username",
client_options: {
identifier: "<YOUR CLIENT ID>",
secret: "<YOUR CLIENT SECRET>",
redirect_uri: "<GITLAB_HOSTNAME>/users/auth/openid_connect/callback"
}
}
}
] -
Starten Sie Ihren GitLab-Server neu.
-
Jeder registrierte Benutzer kann
GITLAB_HOSTNAME/-/profile/account öffnen und das Casdoor-Konto verbinden.
-
Fertig. You can now log in to your GitLab instance via Casdoor.
