2016-08-23 26 views
1

Rubyツールキット用のonelogin SAML APIを現在のプロジェクトに統合しようとしています。私はSAML設定を構成しました。ここに私のコントローラは、次のとおりです。def index方法についてはRuby on Railsでonelogin 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 

を設定し、リクエストオブジェクトを持っていますが、それはページをリダイレクトするとき、すなわちredirect_to(request.create(設定))、私はエラーを取得しています:

no method "create" for nil class.

私はcreateメソッドを呼び出すと思っても、値は返されません。誰でもそれをチェックして、あなたの懸念や提案を私に知らせてください。

答えて

1

ruby​​-samlとrails4の実例を含むこのgithubリポジトリを確認しましたか? https://github.com/onelogin/ruby-saml-example

古いバージョンでは使用できないメソッドもあるので、使用しているruby-samlバージョンも重要です。

2

https://github.com/onelogin/ruby-samlによると、宣言は次のようになります。

OneLogin::RubySaml::Authrequest 
and 
OneLogin::RubySaml::Response 

彼らのウェブサイト上のツールキットのドキュメントが古くなっているようです。 gemで提供されているドキュメントを使用します。宝石のドキュメントから

Version 0.8.x changes the namespace of the gem from OneLogin::Saml 
to OneLogin::RubySaml. Please update your implementations of the gem accordingly. 
関連する問題