Rails - Onelogin ruby-saml + integration problem

I am facing a problem when using ruby-saml in my Rails application. I am new to the world of Ruby.

From here, I learned that I can use the ruby-saml tool kit for SAML SP.

Now, when I tried to access OneLogin in my controller (for example, below), I get the error "uninitialized constant Onelogin :: Saml".

OneLogin::RubySaml::Authrequest.new

When I tried to include below lines in my controller, I get different errors.

require 'onelogin/saml'
or
require 'onelogin/ruby-saml'

Getting such errors

cannot load such file -- onelogin/saml
or
cannot load such file -- onelogin/ruby-saml

I installed gem ruby-saml, and I included the same in my rails GemFile application, and also installed the package.

[root@localhost SP]# bundle show ruby-saml  
/usr/local/rvm/gems/ruby-2.1.1/gems/ruby-saml-0.8.1  
[root@localhost SP]# 

My controller:

#require 'onelogin/saml'

require 'onelogin/ruby-saml'

class SamlController < ApplicationController
  skip_before_filter :verify_authenticity_token, :only => [:consume]  

  def index
    #settings = Account.get_saml_settings
    settings = :get_saml_settings
    request = Onelogin::Saml::Authrequest.new
    redirect_to(request.create(settings))
  end

  def consume
    response = Onelogin::Saml::Response.new(params[:SAMLResponse])
    response.settings = Account.get_saml_settings

    logger.info "NAMEID: #{response.name_id}"

    if response.is_valid?
      session[:userid] = response.name_id
      redirect_to :action => :complete
    else
      redirect_to :action => :fail
    end
  end

  def complete
  end

  def fail
  end

def get_saml_settings
end

end

I'm not sure what I am missing. Thoughts?

+4
1

, : OneLogin::RubySaml .

+3

Source: https://habr.com/ru/post/1535495/


All Articles