我正在使用https://github.com/apokalipto/devise_saml_authenticatable在Ruby on Rails应用程序中通过SAML对Okta实现登录。
使用上述说明设置示例应用程序后,尝试导航到/ users / saml / log_in时出现以下错误
ActionController::RoutingError (uninitialized constant SamlSessionsController):
activesupport (5.1.6) lib/active_support/inflector/methods.rb:269:in `const_get'
activesupport (5.1.6) lib/active_support/inflector/methods.rb:269:in `block in constantize'
activesupport (5.1.6) lib/active_support/inflector/methods.rb:267:in `each'
activesupport (5.1.6) lib/active_support/inflector/methods.rb:267:in `inject'
activesupport (5.1.6) lib/active_support/inflector/methods.rb:267:in `constantize'
actionpack (5.1.6) lib/action_dispatch/http/request.rb:85:in `controller_class_for'
actionpack (5.1.6) lib/action_dispatch/http/request.rb:78:in `controller_class'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:43:in `controller'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:29:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>'
actionpack (5.1.6) lib/action_dispatch/routing/mapper.rb:46:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
不确定导致上述错误的原因。我确保gem是Gemfile的一部分并已安装。
还有什么可以研究的吗?
答案 0 :(得分:1)
我能够解决这个问题。这是由于我的路线配置错误造成的。导致该问题的路由配置如下:
devise_scope :user do
scope "users", controller: 'saml_sessions' do
get :new, path: "saml/sign_in", as: :new_user_sso_session
post :create, path: "saml/auth", as: :user_sso_session
get :destroy, path: "sign_out", as: :destroy_user_sso_session
get :metadata, path: "saml/metadata", as: :metadata_user_sso_session
match :idp_sign_out, path: "saml/idp_sign_out", via: [:get, :post]
end
end
然而,正确的配置应该是:
devise_scope :user do
scope "users", controller: 'devise/saml_sessions' do
get :new, path: "saml/sign_in", as: :new_user_sso_session
post :create, path: "saml/auth", as: :user_sso_session
get :destroy, path: "sign_out", as: :destroy_user_sso_session
get :metadata, path: "saml/metadata", as: :metadata_user_sso_session
match :idp_sign_out, path: "saml/idp_sign_out", via: [:get, :post]
end
end
注意,控制器应该是&#39; devise/saml_sessions
&#39;。
在这次改变之后,我能够成功地继续前进。