开发者

Devise/Warden custom single-sign-on strategy

I want my SSO custom strategy to be the only strategy that devise uses. I'm doing this by:

config.warden do |manager|
  manager开发者_如何学C.default_strategies :my_sso_strategy
end

This is where I get stuck. I want to invoke the strategy, and I thought this would be done for me by:

app/controllers/devise/sessions_controller.rb

But, it doesn't look like my strategy gets invoked.

I took away the :authenticatable / :database_authenticatable from the devise declaration in my User model thinking that may be causing the problem.

After making the sign-in/out routes manually (because :authenticatable makes them), I get an AbstractController::ActionNotFound error.

At this point I'm at a loss how to continue.

My views should be setup correctly to auto-submit my credentials I get from the SSO application (it worked in authlogic)

Has anyone done something similar to this?


I can't say for sure unless you share how you coded the strategy. The simple answer is that you need a valid? method defined to specify when to use the strategy. Since you only want to use one strategy then I would expect your valid method to be like this..

Warden::Strategies.add(:my_sso_strategy) do 
  def valid?
    true
  end 

  def authenticate!
   #do authentication
  end
end


I have seen others use the ":user" scope and noticed you did not have it in your excerpt. Perhaps that is causing the original error.

config.warden do |manager|
  manager.default_strategies(:scope => :user).unshift :fb_database_authenticatable
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜