Rails-Onelogin ruby saml集成问题&x2B;
我在Rails应用程序中使用ruby saml时遇到了一个问题。我是Ruby世界的新手 从那时起,我知道我可以使用SAML SP的工具包 现在,当我试图在控制器中引用OneLogin时(如下所示),我得到了错误“uninitialized constant OneLogin::Saml” 当我尝试在控制器中包含下面的行时,我得到了不同的错误Rails-Onelogin ruby saml集成问题&x2B;,ruby,ruby-on-rails-3,onelogin,Ruby,Ruby On Rails 3,Onelogin,我在Rails应用程序中使用ruby saml时遇到了一个问题。我是Ruby世界的新手 从那时起,我知道我可以使用SAML SP的工具包 现在,当我试图在控制器中引用OneLogin时(如下所示),我得到了错误“uninitialized constant OneLogin::Saml” 当我尝试在控制器中包含下面的行时,我得到了不同的错误 require 'onelogin/saml' or require 'onelogin/ruby-saml' 得到的错误如下: cannot load
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应用程序的gem文件中,还运行了bundle安装
[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/saml'
需要“onelogin/ruby saml”
类SamlController[:consume]
def索引
#设置=Account.get\u saml\u设置
设置=:获取样本设置
request=Onelogin::Saml::Authrequest.new
将_重定向到(请求.创建(设置))
结束
def消耗
response=Onelogin::Saml::response.new(参数[:SAMLResponse])
response.settings=Account.get\u saml\u设置
logger.info“NAMEID:#{response.name_id}”
如果response.u有效吗?
会话[:userid]=response.name\u id
将_重定向到:操作=>:完成
其他的
将_重定向到:操作=>:失败
结束
结束
def完成
结束
def故障
结束
def get_saml_设置
结束
结束
我不确定我错过了什么。想法?我认为声明应该是这样的:
OneLogin::RubySaml
根据源代码
#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