1

I am using https://github.com/apokalipto/devise_saml_authenticatable to implement login via SAML against Okta in a Ruby on Rails application.

After setting up a sample application with the instruction mentioned above, I get the following error when trying to navigate to /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'

Not sure what is causing the above error. I have ensured that the gem is part of the Gemfile and is installed.

Anything more I could look into?

Rohit Menon
  • 445
  • 4
  • 10

1 Answers1

7

I was able to resolve this issue. This was due to a misconfiguration in my routes. The route configuration causing the issue was as follows:

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

Whereas, the correct configuration should be:

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

Note, the controller, it should be 'devise/saml_sessions'.

After this change I was able to go ahead successfully.

Rohit Menon
  • 445
  • 4
  • 10