1

我正在开发一个应用程序,我想通过我在不同服务器上设置的自定义 oauth 提供程序进行身份验证。

我正在尝试使用 RefineryCMS 集成此自定义登录。我已经设置了路线,但由于某种原因,它仍在尝试遵循 RefineryCMS 中内置的设计路线。

路由.rb

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
devise_scope :users do
 match '/users/auth/:provider', :to => 'users/omniauth_callbacks#passthru'
end

回调链接

<p><%= link_to "Sign in with Olympus", user_omniauth_callback_path(:olympus) %></p>

Olympus 是目前该项目的代号。

Omniauth 回调控制器:

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def olympus
    auth = env["omniauth.auth"]
    ap auth
  end

  def passthru
    render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
  end
end

点击链接后通过 rails s 的日志:

Started GET "/users/auth/olympus/callback" for 127.0.0.1 at 2011-08-12 07:52:09 -0500
  Processing by Devise::OmniauthCallbacksController#failure as 
  SQL (0.7ms)  SHOW TABLES
  SQL (0.6ms)  SHOW TABLES
  Page Load (0.3ms)  SELECT `pages`.`id`, `pages`.`depth`, `pages`.`parent_id`, `pages`.`lft`, `pages`.`rgt`, `pages`.`link_url`, `pages`.`menu_match`, page_translations.title as page_title FROM `pages` INNER JOIN `page_translations` ON `page_translations`.`page_id` = `pages`.`id` WHERE `pages`.`draft` = 0 AND `pages`.`show_in_menu` = 1 AND `page_translations`.`locale` = 'en' ORDER BY lft ASC
  Slug Load (0.1ms)  SELECT `slugs`.* FROM `slugs` WHERE (`slugs`.`sluggable_id` IN (1,3) and `slugs`.`sluggable_type` = 'Page' AND (`slugs`.`locale` = 'en')) ORDER BY id DESC
  Slug Load (0.2ms)  SELECT `slugs`.* FROM `slugs` WHERE (`slugs`.sluggable_id = 3 AND `slugs`.sluggable_type = 'Page') ORDER BY id DESC
  SQL (1.3ms)  describe `roles_users`
  Role Load (0.1ms)  SELECT `roles`.* FROM `roles` WHERE `roles`.`title` = 'Refinery' LIMIT 1
  SQL (1.4ms)  describe `roles_users`
  User Load (0.2ms)  SELECT * FROM `users` INNER JOIN `roles_users` ON `users`.id = `roles_users`.user_id WHERE (`roles_users`.role_id = 1 )
Redirected to http://localhost:3000/users/login

所以它仍然试图通过 RefineryCMS 来通过 Devise::OmniauthCallbacksController ......有谁知道如何解决这个问题,甚至可能覆盖这个设计控制器?

我还想说,我对与 oauth 提供者/客户合作是全新的。我曾与 Facebook 和 Twitter 合作过,但从头开始是我的新手。以及与 Devise/Omniauth 合作。所以请原谅我的无知。谢谢!

4

1 回答 1

0

通过阅读本文修复了路由问题:http ://groups.google.com/group/refinery-cms/browse_thread/thread/37917e227b26f5ca

我现在遇到的问题是,它似乎没有连接到我的 oauth 提供者进行身份验证:(

于 2011-08-12T13:56:24.507 回答