2013-10-28 63 views
0

我试图使用门卫(https://github.com/applicake/doorkeeper/)来设置一个简单的OAuth提供程序,但是在重命名我的路由时遇到严重问题。Rails 3.1中的门卫路由问题

我试图将我的基地门卫路线设置为'/ oauth2/v1',而不是预卷的'/ oauth'路线。

阅读维基(https://github.com/applicake/doorkeeper/wiki/Customizing-routes)似乎所有我需要做的是修改

Rails.application.routes.draw do 
    use_doorkeeper 
end 

Rails.application.routes.draw do 
    use_doorkeeper :scope => 'oauth2/v1' 
end 

或许命名空间use_doorkeeper到“的oauth2”,然后提供“一个范围V1' 。不幸的是没有用。我无法让门卫根本不使用任何其他范围。

维基本身似乎是相当落伍,像Rails不再使用那种在routes.rb中构建的,所以我实际上是试图改变看起来更像这样的代码:

DoorkeeperProvider::Application.routes.draw do 
    scope 'oauth2' do 
    use_doorkeeper :scope => 'v1' 
    end 
    ... 
end 

但是,似乎没有什么能够改变范围。

这是耙路线的输出:

 oauth_authorization GET /oauth2/oauth/authorize(.:format)     {:action=>"new", :controller=>"doorkeeper/authorizations"} 
     oauth_authorization POST /oauth2/oauth/authorize(.:format)     {:action=>"create", :controller=>"doorkeeper/authorizations"} 
     oauth_authorization DELETE /oauth2/oauth/authorize(.:format)     {:action=>"destroy", :controller=>"doorkeeper/authorizations"} 
       oauth_token POST /oauth2/oauth/token(.:format)      {:action=>"create", :controller=>"doorkeeper/tokens"} 
     oauth_applications GET /oauth2/oauth/applications(.:format)    {:action=>"index", :controller=>"doorkeeper/applications"} 
          POST /oauth2/oauth/applications(.:format)    {:action=>"create", :controller=>"doorkeeper/applications"} 
    new_oauth_application GET /oauth2/oauth/applications/new(.:format)   {:action=>"new", :controller=>"doorkeeper/applications"} 
     edit_oauth_application GET /oauth2/oauth/applications/:id/edit(.:format)  {:action=>"edit", :controller=>"doorkeeper/applications"} 
     oauth_application GET /oauth2/oauth/applications/:id(.:format)   {:action=>"show", :controller=>"doorkeeper/applications"} 
          PUT /oauth2/oauth/applications/:id(.:format)   {:action=>"update", :controller=>"doorkeeper/applications"} 
          DELETE /oauth2/oauth/applications/:id(.:format)   {:action=>"destroy", :controller=>"doorkeeper/applications"} 
oauth_authorized_applications GET /oauth2/oauth/authorized_applications(.:format)  {:action=>"index", :controller=>"doorkeeper/authorized_applications"} 
oauth_authorized_application DELETE /oauth2/oauth/authorized_applications/:id(.:format) {:action=>"destroy", :controller=>"doorkeeper/authorized_applications"} 
     oauth_token_info GET /oauth2/oauth/token/info(.:format)     {:action=>"show", :controller=>"doorkeeper/token_info"} 

它看起来好像:范围参数去use_doorkeeper只是被忽略。

在这一点上的任何提示将非常感激。

+0

你能提供耙路线的输出吗?从理论上讲,最后一个选项应该可以工作 - 所有'use_doorkeeper'都会生成一个包装范围,它的配置值为:scope或'oauth' –

+0

我已经为问题添加了“rake routes”输出,因为它也是这样大的发表评论。 – Nello

回答

1

所以它看起来像你遇到了最近修复的问题。请参阅此处的提交 - https://github.com/applicake/doorkeeper/commit/a12f9eacaa9714a0681b42f0685e491e296d6560

您运行的是哪个版本?理论上这应该固定在0.7.3。

我想尝试使用Github上的应用程序/门卫的门卫主分支。这应该可以解决这个问题。

+0

你是完全正确的。我已经安装了门卫提供商应用程序,它被固定到门卫0.5.0版本。 感谢您的帮助! – Nello