1

基本上,我按照这些说明添加自定义omniauth 提供程序:

https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md#using-custom-omniauth-providers

我想使用omniauth-pam:

https://github.com/nickcharlton/omniauth-pam

添加 gem 并在 gitlab.yml 中配置后:

providers:
    - { name: 'pam' }

它不再以这个错误开始:

Received wrong number of arguments. [nil, nil] (ArgumentError)
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:143:in `initialize'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.15/lib/action_dispatch/middleware/stack.rb:43:in `new'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.15/lib/action_dispatch/middleware/stack.rb:43:in `build'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.15/lib/action_dispatch/middleware/stack.rb:113:in `block in build'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.15/lib/action_dispatch/middleware/stack.rb:113:in `each'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.15/lib/action_dispatch/middleware/stack.rb:113:in `inject'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.15/lib/action_dispatch/middleware/stack.rb:113:in `build'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/engine.rb:475:in `app'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/application/finisher.rb:31:in `block in <module:Finisher>'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/initializable.rb:30:in `instance_exec'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/initializable.rb:30:in `run'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/initializable.rb:55:in `block in run_initializers'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/initializable.rb:54:in `each'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/initializable.rb:54:in `run_initializers'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/application.rb:136:in `initialize!'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/railties-3.2.15/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /sync1/gitlab/config/environment.rb:5:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  /sync1/gitlab/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/lib64/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:105:in `eval'
  /usr/local/lib64/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:105:in `preload_app'
  /usr/local/lib64/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:150:in `<module:App>'
  /usr/local/lib64/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/lib64/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:28:in `<main>'

omn​​iauth-pam 的文档指出它不需要任何配置参数。所以这个错误对我来说是无法解释的。

4

3 回答 3

4

问题来自于如何设置config/initializers/devise.rb中定义的提供者(通过config/gitlab.yml始终传递至少两个参数,即使它们是传递的参数数量)。nilomniauth/strategy.rb

这种组合使得它期望在中定义的提供者config/gitlab.yml声明至少两个参数。

所以我必须在我的提供者中执行以下操作来解决这个问题:

require 'omniauth'
module OmniAuth
    module Strategies
        class YourProvider
            include OmniAuth::Strategy
            args [:arg1, :arg2]  # <-- This is the line you need.

这很可能是 gitlab 中的一个错误,但以上是我的解决方法。

您可以通过分叉 omniauth-pam 项目并将该行添加到lib/omniauth/strategies/pam.rb.

然后在 gitlab 中Gemfile,您的 gem 行应如下所示:

gem 'omniauth-pam', :git => 'https://github.com/vanthome/omniauth-pam.git'

这样,它将使用提供者进行您的更改。之后,使用自定义提供程序时的其余说明仍然适用。

编辑:

我刚刚意识到还有另一种方法可以解决这个问题,不需要您分叉提供程序代码。

config/initializers/devise.rb中,在最外层块的末尾添加以下行:

config.omniauth :pam

并从中删除添加的提供者行config/gitlab.yml

于 2014-01-04T18:38:58.717 回答
1

我建议你检查一下这个人做了什么:

https://github.com/raphendyr/gitlabhq/tree/pam

当我使用他的存储库来托管 GitLab 时,它运行良好。

它有点过时了,但是如果它是你的问题,那么为当前版本制作相同的补丁并不是一个大问题。

于 2013-11-19T21:27:13.427 回答
0

我必须让这个为我的大学工作。看看我对 Gitlab 的拉取请求。我能够在 Ubuntu 上使用 PAM 获得 Gitlab 的工作版本。

Gitlab 拉取请求 #4706

于 2014-02-10T17:10:56.153 回答