找不到:sso的匹配策略。您可能需要安装其他gem(例如omniauth-sso)

时间:2018-11-27 10:15:34

标签: ruby-on-rails ruby single-sign-on omniauth

我已经在here的omniauth-oauth2中实现了自定义策略SSO。我创建了自定义gem sso并将其捆绑安装成功。但是,当我尝试启动服务器时,出现错误,显示:sso找不到匹配策略。您可能需要安装其他gem(例如omniauth-sso)。

在gem文件中:

gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-sso', path: "/Users/maheswaran/Documents/Intern/omniauth-sso"

Initializers / omniauth.rb:

OmniAuth.config.logger = Rails.logger

CUSTOM_PROVIDER_URL = 'http://app.10.0.1.106.xip.io:3000'

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :sso, "123456", "qwerty"
end

错误:

/Users/maheswaran/.gem/ruby/2.4.0/gems/omniauth-1.8.1/lib/omniauth/builder.rb:54:in `rescue in provider': Could not find matching strategy for :sso. You may need to install an additional gem (such as omniauth-sso). (LoadError)
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/omniauth-1.8.1/lib/omniauth/builder.rb:51:in `provider'
    from /Users/maheswaran/Documents/Intern/config/initializers/omniauth.rb:11:in `block in <top (required)>'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/omniauth-1.8.1/lib/omniauth/builder.rb:6:in `initialize'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:37:in `new'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:37:in `build'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `block in build'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `each'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `inject'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/stack.rb:101:in `build'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:510:in `block in app'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:506:in `synchronize'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/engine.rb:506:in `app'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
    from /Users/maheswaran/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
    from /Users/maheswaran/Documents/Intern/config/environment.rb:5:in `<top (required)>'
    from config.ru:3:in `require_relative'
    from config.ru:3:in `block in <main>'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
    from config.ru:in `new'
    from config.ru:in `<main>'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:49:in `eval'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:319:in `build_app_and_options_from_config'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:219:in `app'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:27:in `app'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:354:in `wrapped_app'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:51:in `start'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
    from /Users/maheswaran/.gem/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<top (required)>'
    from /Users/maheswaran/Documents/Intern/bin/rails:4:in `require'
    from /Users/maheswaran/Documents/Intern/bin/rails:4:in `<main>'

1 个答案:

答案 0 :(得分:0)

/Users/maheswaran/Documents/Intern/omniauth-sso处的策略必须将其名称定义为sso。例如,包含:

option :name, :sso