嘗試使用 Active Directory 驗證推送到 GitLab 時出現 500 錯誤

嘗試使用 Active Directory 驗證推送到 GitLab 時出現 500 錯誤

我們目前使用 SubVersion,但希望遷移到基於 Git 的解決方案,以便能夠進行預先提交程式碼審查。要求是中央 Git 儲存庫託管在本機,具有允許專案管理的可視化前端,並使用 Active Directory 驗證。

作為試用,我在運行 Ubuntu 伺服器 18.04 的虛擬機器上安裝了 GitLab EE。我已經使用以下配置設定了 AD 身份驗證:

gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
 main:
  label: 'MyOrganisation'
  host: '172.16.0.6'
  port: 389
  uid: 'sAMAccountName'
  bind_dn: 'CN=ldapbinduser,CN=Users,DC=myorganisation,DC=com'
  password: 'password' 
  timeout: 30
  active_directory: true
  allow_username_or_mail_login: false
  lowercase_usernames: true
  block_auto_created_users: true
  base: 'OU=Software,OU=Engineering,DC=myorganisation,DC=com'
  group_base: 'OU=Software,OU=Engineering,DC=myorganisation,DC=com'
  admin_group: 'internal software dept'
EOS

這已經部分成功。 MyOrganization 標籤出現在 GitLab 登入頁面中,軟體群組的成員可以使用其 AD 登入名稱和密碼登錄,而非成員則無法。 「內部軟體部門」群組的成員不會自動指派管理員權限,但這沒關係,因為我們可以手動新增它們。

當嘗試將 SVN 儲存庫的歷史記錄推送到 GitLab 或克隆儲存庫時,就會出現問題。我在 GitLab 中建立了一個內部軟體群組,並在其中新增了一個帶有 readme.txt 檔案的 TestProject 專案。在我的 Windows 10 PC 上,我安裝了 Windows 的 Git Credential Manager。當我嘗試使用以下命令將其克隆到我的電腦時: git clonehttp://gitlab/internal-software/testproject.git 我收到一則訊息:

致命:無法訪問'http://gitlab/internal-software/testproject.git/': 請求的 URL 回傳錯誤:500 WireShark 顯示兩次連線嘗試,第一個嘗試傳回 401 – 未經授權回應,第二個嘗試傳回 500 – 內部伺服器錯誤回應:

1   local IP    gitlab IP   TCP 66  59710 → 80 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1
2   gitlab IP   local IP    TCP 66  80 → 59710 [SYN, ACK] Seq=0 Ack=1 Win=29200 Len=0 MSS=1460 SACK_PERM=1 WS=128
3   local IP    gitlab IP   TCP 54  59710 → 80 [ACK] Seq=1 Ack=1 Win=525568 Len=0
4   local IP    gitlab IP   HTTP    241 GET /internal-software/testproject.git/info/refs?service=git-upload-pack HTTP/1.1
5   gitlab IP   local IP    TCP 60  80 → 59710 [ACK] Seq=1 Ack=188 Win=30336 Len=0
6   gitlab IP   local IP    HTTP    618 HTTP/1.1 401 Unauthorized  (text/plain)
7   local IP    gitlab IP   TCP 54  59710 → 80 [ACK] Seq=188 Ack=565 Win=524800 Len=0
8   local IP    gitlab IP   HTTP    292 GET /internal-software/testproject.git/info/refs?service=git-upload-pack HTTP/1.1 
9   gitlab IP   local IP    TCP 60  80 → 59710 [ACK] Seq=565 Ack=426 Win=31360 Len=0
10  gitlab IP   local IP    TCP 1514    80 → 59710 [ACK] Seq=565 Ack=426 Win=31360 Len=1460 [TCP segment of a reassembled PDU]
11  gitlab IP   local IP    TCP 1514    80 → 59710 [ACK] Seq=2025 Ack=426 Win=31360 Len=1460 [TCP segment of a reassembled PDU]
12  gitlab IP   local IP    HTTP    309 HTTP/1.1 500 Internal Server Error  (text/html)
13  local IP    gitlab IP   TCP 54  59710 → 80 [ACK] Seq=426 Ack=3740 Win=525568 Len=0
14  local IP    gitlab IP   TCP 54  59710 → 80 [RST, ACK] Seq=426 Ack=3740 Win=0 Len=0

500 – 內部伺服器錯誤回應的內容是標準的 GitLab 500 – 「哎呀,我們這邊出了問題」頁面。

在伺服器上,我瀏覽了 var/logs/gitlab/gitlab-rails 中的 .log 文件,並在 production_json.log 中找到了以下內容:

{“方法”:“GET”,“路徑”:“/內部軟體/testproject/git/info/refs”,“格式”:“/","控制器":"項目::GitHttpController","操作":"info_refs","狀態":401,"持續時間":35.81,"視圖":1.05,"db":9.7,"時間" :" 2019-09-19T08:37:55.371Z","params":[{"key":"service","value":git-upload-pack"},{"key":"namespage_id"," value" :"內部軟體"},{"key":"project_id","value":"testproject.git"}],"remote_ip":"172.16.1.46","user_id":null,"使用者名稱" :null ,"ua":git/2.17.0.windows.1","queue_duration":null,"correlation_id":"long_uid"} {"method":"GET","path":"/internal-software /testproject /git/info/refs","格式":"/","controller":"Projects::GitHttpController","action":"info_refs","status":500,"error":"ArgumentError: 必須提供加密或方法","duration":215.3,"view " :0.0,"db":14.11,"時間":"2019-09-19T08:37:55.803Z","params":[{"key":"service","value":git-upload-pack " },{"key":"namespage_id","value":"內部軟體"},{"key":"project_id","value":"testproject.git"}],"remote_ip":"172.16 .1.46 ","user_id":null,"使用者名稱":null,"ua":git/2.17.0.windows.1","queue_duration":null,"correlation_id":"long_uid"}

這些似乎與上面的 HTTP 請求和回應相符。第一個是 401,第二個是 500。

錯誤訊息是 ArgumentError:必須提供加密或方法 我嘗試在 GitLab 網站、Stack Overflow、Stack Exchange 和一些知名搜尋引擎上搜尋此內容,但只得到與我的問題不匹配的近似結果。

答案1

GitLab 支援人員提供的答案是我在配置中缺少以下設定:

  encryption: 'plain'
  verify_certificates: true

有了這些,我就能夠克隆和推送了。我注意到的是,其他任何連接的人都會被告知他們的帳戶已被阻止,直到我使用管理員帳戶解鎖他們為止。

相關內容