GitLab
Casdoor 可以使用 OIDC 协议链接到私有部署的 GitLab,这份文档将向您展示如何处理相关问题。
以下是一些在配置中需要使用的代称:
CASDOOR_HOSTNAME
:私有部署的Casdoor域名或IP。 比如:https://door.casbin.com
.
GITLAB_HOSTNAME
: Domain name or IP where GitLab is deployed. e.g., https://gitlab.com
.
Step1. Deploy Casdoor and GitLab
Firstly, the Casdoor and GitLab should be deployed.
After a successful deployment, you need to ensure:
- Casdoor can be logged in and used normally.
- Set Casdoor’s
origin
value (conf/app.conf) toCASDOOR_HOSTNAME
.
Step2. Configure Casdoor application
- Create or use an existing Casdoor application.
- Add a redirect url:
http://GITLAB_HOSTNAME/users/auth/openid_connect/callback
. - Add provider you want and supplement other settings.
Not surprisingly, you can get two values on the application settings page: Client ID
and Client secret
like the picture above, we will use them in next step.
Open your favorite browser and visit: http://`CASDOOR_HOSTNAME`/.well-known/openid-configuration, you will see the OIDC configure of Casdoor.
Step3. Configure GitLab
You can follow the steps below to set this up, or make custom changes according to this document(e.g., you are installing GitLab using source code rather than Omnibus).
On your GitLab server, open the configuration file.
sudo editor /etc/gitlab/gitlab.rb
Add the provider configuration. (HOSTNAME url should include http or https)
gitlab_rails['omniauth_providers'] = [
{
name: "openid_connect",
label: "Casdoor", # optional label for 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"
}
}
}
]
Reboot your GitLab server.
- Each registered user can open
GITLAB_HOSTNAME
/-/profile/account, connect the casdoor account. - Finish. Now, you can login your own GitLab by casdoor.