我正在尝试使用门卫(https://github.com/applicake/doorkeeper/)来设置一个简单的 OAuth 提供程序,但是在重命名我的路线时遇到了严重的问题。
我正在尝试将我的基本门卫路线设置为“/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”的范围。不幸的是,没有任何效果。我根本无法让门卫使用任何其他范围。
wiki 本身似乎已经过时了,因为 Rails 不再在 routes.rb 中使用这种结构,所以我实际上试图更改的代码看起来更像这样:
DoorkeeperProvider::Application.routes.draw do
scope 'oauth2' do
use_doorkeeper :scope => 'v1'
end
...
end
但同样,似乎没有什么能够改变范围。
这是 rake 路由的输出:
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 的 :scope 参数被忽略了。
在这一点上的任何提示将不胜感激。