微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rails – Onelogin ruby​​-saml集成问题

我在Rails应用程序中使用 ruby-saml时遇到了问题.我是 Ruby世界的新手.

here开始,我知道我可以使用ruby-saml工具包进行SAML SP.

现在,当我试图在我的控制器中引用OneLogin时(如下所示),我收到错误“未初始化的常量Onelogin :: Saml”.

OneLogin::RubySaml::Authrequest.new

当我尝试在控制器中包含以下行时,我会遇到不同的错误.

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

得到错误,

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

我安装了gem ruby​​-saml,我也在我的rails应用程序的GemFile中包含了它,并运行了bundle install.

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

我的控制器:

#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

我不确定我错过了什么.思考?

解决方法

我认为声明应该是这样的:OneLogin :: RubySaml根据源代码.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐